[libdmapsharing] Add first unit test to daap-share.c



commit a6253e11f8406acb3f1a4410e24552f094aa7bb1
Author: W. Michael Petullo <mike flyn org>
Date:   Tue Dec 5 23:15:55 2017 -0500

    Add first unit test to daap-share.c
    
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/Makefile.am                         |   12 ++++--
 libdmapsharing/daap-share.c                        |   37 ++++++++++++++++++++
 {tests => libdmapsharing}/test-dmap-container-db.c |    0
 {tests => libdmapsharing}/test-dmap-container-db.h |    0
 .../test-dmap-container-record.c                   |    0
 .../test-dmap-container-record.h                   |    0
 tests/Makefile.am                                  |    6 ---
 tests/test-dmap-server.c                           |    5 +--
 8 files changed, 47 insertions(+), 13 deletions(-)
---
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index d2cdfd5..d591462 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -29,9 +29,11 @@ if HAVE_CHECK
 libdmapsharing_4_0_la_SOURCES += \
        test-daap-record.c \
        test-daap-record-factory.c \
+       test-dmap-container-db.c \
+       test-dmap-container-record.c \
+       test-dmap-db.c \
        test-dpap-record.c \
-       test-dpap-record-factory.c \
-       test-dmap-db.c
+       test-dpap-record-factory.c
 endif
 
 if USE_HOWL
@@ -120,9 +122,11 @@ noinst_HEADERS = \
        gst-util.h \
        test-daap-record-factory.h \
        test-daap-record.h \
+       test-dmap-container-db.h \
+       test-dmap-container-record.h \
+       test-dmap-db.h \
        test-dpap-record-factory.h \
-       test-dpap-record.h \
-       test-dmap-db.h
+       test-dpap-record.h
 
 BUILT_SOURCES = dmap-marshal.c dmap-marshal.h dmap-enums.c dmap-enums.h unit-test.stamp
 
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 064fa22..ee9e97d 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -886,3 +886,40 @@ get_meta_data_map (DMAPShare * share)
 {
        return meta_data_map;
 }
+
+#ifdef HAVE_CHECK
+
+#include <check.h>
+#include <libdmapsharing/test-dmap-db.h>
+#include <libdmapsharing/test-dmap-container-db.h>
+#include <libdmapsharing/test-dmap-container-record.h>
+
+START_TEST(daap_share_get_desired_port_test)
+{
+       DMAPDb *db;
+       DMAPContainerRecord *container_record;
+       DMAPContainerDb *container_db;
+       DMAPShare *share;
+
+       db = DMAP_DB(test_dmap_db_new());
+       container_record = DMAP_CONTAINER_RECORD (test_dmap_container_record_new ());
+       container_db = DMAP_CONTAINER_DB(test_dmap_container_db_new(container_record));
+
+       share  = DMAP_SHARE(daap_share_new("daap_share_get_desired_port_test",
+                                           NULL,
+                                           db,
+                                           container_db,
+                                           NULL));
+
+       ck_assert_int_eq(DAAP_PORT, daap_share_get_desired_port(share));
+
+       g_object_unref(db);
+       g_object_unref(container_record);
+       g_object_unref(container_db);
+       g_object_unref(share);
+}
+END_TEST
+
+#include "daap-share-suite.c"
+
+#endif
diff --git a/tests/test-dmap-container-db.c b/libdmapsharing/test-dmap-container-db.c
similarity index 100%
rename from tests/test-dmap-container-db.c
rename to libdmapsharing/test-dmap-container-db.c
diff --git a/tests/test-dmap-container-db.h b/libdmapsharing/test-dmap-container-db.h
similarity index 100%
rename from tests/test-dmap-container-db.h
rename to libdmapsharing/test-dmap-container-db.h
diff --git a/tests/test-dmap-container-record.c b/libdmapsharing/test-dmap-container-record.c
similarity index 100%
rename from tests/test-dmap-container-record.c
rename to libdmapsharing/test-dmap-container-record.c
diff --git a/tests/test-dmap-container-record.h b/libdmapsharing/test-dmap-container-record.h
similarity index 100%
rename from tests/test-dmap-container-record.h
rename to libdmapsharing/test-dmap-container-record.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fc24b5d..8b8478c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,8 +28,6 @@ test_dmap_client_LDADD = \
        $(MDNS_LIBS)
 
 test_dmap_server_SOURCES = \
-       test-dmap-container-record.c \
-       test-dmap-container-db.c \
        test-dmap-server.c
 
 test_dmap_server_LDADD = \
@@ -140,10 +138,6 @@ INCLUDES = \
        $(GTK_CFLAGS) \
        $(GEE_CFLAGS)
 
-noinst_HEADERS = \
-       test-dmap-container-record.h \
-       test-dmap-container-db.h
-
 EXTRA_DIST = \
        $(dacplisten_VALASOURCES) \
        $(dacplisten_VALABUILTSOURCES) \
diff --git a/tests/test-dmap-server.c b/tests/test-dmap-server.c
index bd0ccc5..a90a83d 100644
--- a/tests/test-dmap-server.c
+++ b/tests/test-dmap-server.c
@@ -29,9 +29,8 @@
 #include <libdmapsharing/test-daap-record-factory.h>
 #include <libdmapsharing/test-dpap-record-factory.h>
 #include <libdmapsharing/test-dmap-db.h>
-
-#include "test-dmap-container-record.h"
-#include "test-dmap-container-db.h"
+#include <libdmapsharing/test-dmap-container-record.h>
+#include <libdmapsharing/test-dmap-container-db.h>
 
 /* For use when deciding whether to test DAAP or DPAP. */
 enum {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]