1 /*
2 * Simple example of a CUnit unit test.
3 *
4 * This program (crudely) demonstrates a very simple "black box"
5 * test of the standard library functions fprintf() and fread().
6 * It uses suite initialization and cleanup functions to open
7 * and close a common temporary file used by the test functions.
8 * The test functions then write to and read from the temporary
9 * file in the course of testing the library functions.
10 *
11 * The 2 test functions are added to a single CUnit suite, and
12 * then run using the CUnit Basic interface. The output of the
13 * program (on CUnit version 2.0-2) is:
14 *
15 * CUnit : A Unit testing framework for C.
16 * http://cunit.sourceforge.net/
17 *
18 * Suite: Suite_1
19 * Test: test of fprintf() ... passed
20 * Test: test of fread() ... passed
21 *
22 * --Run Summary: Type Total Ran Passed Failed
23 * suites 1 1 n/a 0
24 * tests 2 2 2 0
25 * asserts 5 5 5 0
26 */
27
28 #include "test-fo-enum-factory.h"
29 #include <libfo/datatype/fo-enum-factory.h>
30
31 /* The suite initialization function.
32 * Returns zero on success, non-zero otherwise.
33 */
34 static int
init_suite(void)35 init_suite (void)
36 {
37 fo_libfo_init ();
38
39 return 0;
40 }
41
42 /* The suite cleanup function.
43 * Returns zero on success, non-zero otherwise.
44 */
45 static int
clean_suite(void)46 clean_suite (void)
47 {
48 fo_libfo_shutdown ();
49
50 return 0;
51 }
52
53 static void
test_fo_enum_factory_new(void)54 test_fo_enum_factory_new (void)
55 {
56 FoEnumFactory *factory1 = fo_enum_factory_new ();
57 FoEnumFactory *factory2 = fo_enum_factory_new ();
58
59 CU_ASSERT_PTR_EQUAL (factory1, factory2);
60
61 g_object_unref (factory2);
62 g_object_unref (factory1);
63 }
64
65 static CU_TestInfo test_array[] = {
66 { "test ref counting of FoEnumFactory", test_fo_enum_factory_new },
67 CU_TEST_INFO_NULL,
68 };
69
70 static CU_SuiteInfo suites[] = {
71 { "fo-enum_factory", init_suite, clean_suite, test_array },
72 CU_SUITE_INFO_NULL,
73 };
74
75 CU_SuiteInfo *
test_fo_enum_factory_get_suites(void)76 test_fo_enum_factory_get_suites (void)
77 {
78 return suites;
79 }
80
81