This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository eradio.

View the commit online.

commit 8ff1dce5b2d8743f8aa17715e81005321a1a219f
Author: politebot <[email protected]>
AuthorDate: Tue Oct 21 18:13:05 2025 -0500

    Add basic tests
---
 .github/workflows/build.yml |   6 +++
 configure.ac                |   2 +-
 src/Makefile.am             |   9 +++-
 src/tests/test_basic.c      | 110 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f031b5e..cc51091 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -42,3 +42,9 @@ jobs:
 
     - name: Build application
       run: make
+
+    - name: Run tests
+      run: |
+        cd src
+        make test_basic
+        ./test_basic
diff --git a/configure.ac b/configure.ac
index 806a125..13de8e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_INIT([eradio], [0.0.14], [])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
 AC_PROG_CC
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile src/Makefile data/Makefile])
diff --git a/src/Makefile.am b/src/Makefile.am
index cc91526..6276766 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,4 +4,11 @@ eradio_SOURCES = main.c ui.c radio_player.c station_list.c http.c favorites.c \
                  appdata.h ui.h radio_player.h station_list.h http.h favorites.h
 
 eradio_CFLAGS = $(EFL_CFLAGS) $(LIBXML_CFLAGS)
-eradio_LDADD = $(EFL_LIBS) $(LIBXML_LIBS)
\ No newline at end of file
+eradio_LDADD = $(EFL_LIBS) $(LIBXML_LIBS)
+
+# Test program
+noinst_PROGRAMS = test_basic
+
+test_basic_SOURCES = tests/test_basic.c appdata.h
+test_basic_CFLAGS = $(EFL_CFLAGS)
+test_basic_LDADD = $(EFL_LIBS_NO_CON)
\ No newline at end of file
diff --git a/src/tests/test_basic.c b/src/tests/test_basic.c
new file mode 100644
index 0000000..aa7fd53
--- /dev/null
+++ b/src/tests/test_basic.c
@@ -0,0 +1,110 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Include the core data structures we want to test
+#include "../appdata.h"
+
+// Simple test framework macros
+#define TEST_ASSERT(condition, message) \
+    do { \
+        if (!(condition)) { \
+            printf("FAIL: %s\n", message); \
+            return 0; \
+        } else { \
+            printf("PASS: %s\n", message); \
+        } \
+    } while(0)
+
+// Test functions
+int test_station_creation() {
+    Station station = {0};
+
+    station.name = "Test Radio Station";
+    station.url = ""
+    station.bitrate = 128;
+    station.favorite = EINA_TRUE;
+
+    TEST_ASSERT(station.name != NULL, "Station name should be set");
+    TEST_ASSERT(strcmp(station.name, "Test Radio Station") == 0, "Station name should match");
+    TEST_ASSERT(station.bitrate == 128, "Station bitrate should be 128");
+    TEST_ASSERT(station.favorite == EINA_TRUE, "Station favorite should be true");
+
+    return 1;
+}
+
+int test_view_mode_enum() {
+    ViewMode search_mode = VIEW_SEARCH;
+    ViewMode favorites_mode = VIEW_FAVORITES;
+
+    TEST_ASSERT(search_mode == 0, "VIEW_SEARCH should be 0");
+    TEST_ASSERT(favorites_mode == 1, "VIEW_FAVORITES should be 1");
+    TEST_ASSERT(search_mode != favorites_mode, "View modes should be different");
+
+    return 1;
+}
+
+int test_appdata_structure() {
+    AppData appdata = {0};
+
+    // Initialize some basic fields
+    appdata.playing = EINA_FALSE;
+    appdata.filters_visible = EINA_TRUE;
+    appdata.view_mode = VIEW_SEARCH;
+    appdata.loading_requests = 5;
+
+    TEST_ASSERT(appdata.playing == EINA_FALSE, "Playing should be false initially");
+    TEST_ASSERT(appdata.filters_visible == EINA_TRUE, "Filters visible should be true");
+    TEST_ASSERT(appdata.view_mode == VIEW_SEARCH, "View mode should be SEARCH");
+    TEST_ASSERT(appdata.loading_requests == 5, "Loading requests should be 5");
+
+    return 1;
+}
+
+int test_station_string_fields() {
+    Station station = {0};
+
+    station.name = "Jazz FM";
+    station.url = ""
+    station.favicon = "http://jazz.fm/icon.png";
+    station.stationuuid = "1234-5678-91011";
+    station.country = "USA";
+    station.language = "English";
+    station.codec = "MP3";
+    station.tags = "jazz,music";
+
+    TEST_ASSERT(strcmp(station.name, "Jazz FM") == 0, "Station name should be Jazz FM");
+    TEST_ASSERT(strcmp(station.url, "http://jazz.fm/stream.mp3") == 0, "Station URL should match");
+    TEST_ASSERT(strcmp(station.country, "USA") == 0, "Station country should be USA");
+    TEST_ASSERT(strcmp(station.language, "English") == 0, "Station language should be English");
+    TEST_ASSERT(strcmp(station.codec, "MP3") == 0, "Station codec should be MP3");
+    TEST_ASSERT(strcmp(station.tags, "jazz,music") == 0, "Station tags should match");
+
+    return 1;
+}
+
+// Main test runner
+int main() {
+    printf("Running eradio basic tests...\n");
+    printf("================================\n");
+
+    int passed = 0;
+    int total = 0;
+
+    // Run tests
+    total++; passed += test_station_creation();
+    total++; passed += test_view_mode_enum();
+    total++; passed += test_appdata_structure();
+    total++; passed += test_station_string_fields();
+
+    printf("================================\n");
+    printf("Test Results: %d/%d tests passed\n", passed, total);
+
+    if (passed == total) {
+        printf("All tests PASSED!\n");
+        return EXIT_SUCCESS;
+    } else {
+        printf("Some tests FAILED!\n");
+        return EXIT_FAILURE;
+    }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to