summaryrefslogtreecommitdiff
path: root/src/tests/eet_cxx/eet_cxx_suite.cc
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-04-01 19:08:07 +0900
committerCedric BAIL <cedric.bail@free.fr>2014-04-01 22:00:13 +0900
commitab3eb4b2d350d017eab6683202663244e11aa518 (patch)
tree076e50c43b9f9784bd707ef974e753a21def1123 /src/tests/eet_cxx/eet_cxx_suite.cc
parentb218c13fb798edaccb7bc8cfdf9ac3905e2d86a7 (diff)
eet-cxx: add implementation for eet C++.
Usage example: struct type { int foo; float bar; }; type t0; auto descriptor = make_descriptor("type", &type::ofo, &type::bar); eet_data_write(file, descriptor.native_handle(), "type", &t0, false); std::unique_ptr<type> p = read_by_ptr(file, "type", descriptor); type t = read(file, "type", descriptor); @feature Reviewers: cedric, smohanty Reviewed By: cedric CC: savio, cedric Differential Revision: https://phab.enlightenment.org/D659 Signed-off-by: Cedric BAIL <cedric.bail@free.fr>
Diffstat (limited to 'src/tests/eet_cxx/eet_cxx_suite.cc')
-rw-r--r--src/tests/eet_cxx/eet_cxx_suite.cc104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/tests/eet_cxx/eet_cxx_suite.cc b/src/tests/eet_cxx/eet_cxx_suite.cc
new file mode 100644
index 0000000..26e658b
--- /dev/null
+++ b/src/tests/eet_cxx/eet_cxx_suite.cc
@@ -0,0 +1,104 @@
1
2#include "Eet.hh"
3#include <Eina.h>
4
5#include <cassert>
6#include <algorithm>
7
8#include <check.h>
9
10void eet_test_descriptors(TCase* tc);
11
12typedef struct _Eet_Test_Case Eet_Test_Case;
13struct _Eet_Test_Case
14{
15 const char *test_case;
16 void (*build)(TCase *tc);
17};
18
19static const Eet_Test_Case etc[] = {
20 { "Descriptors", eet_test_descriptors },
21 { NULL, NULL }
22};
23
24static void
25_list_tests(void)
26{
27 const Eet_Test_Case *itr = etc;
28 fputs("Available Test Cases:\n", stderr);
29 for (; itr->test_case; itr++)
30 fprintf(stderr, "\t%s\n", itr->test_case);
31}
32
33static Eina_Bool
34_use_test(int argc, const char **argv, const char *test_case)
35{
36 if (argc < 1)
37 return 1;
38
39 for (; argc > 0; argc--, argv++)
40 if (strcmp(test_case, *argv) == 0)
41 return 1;
42
43 return 0;
44}
45
46Suite *
47eet_build_suite(int argc, const char **argv)
48{
49 TCase *tc;
50 Suite *s;
51 int i;
52
53 s = suite_create("Eet C++");
54
55 for (i = 0; etc[i].test_case; ++i)
56 {
57 if (!_use_test(argc, argv, etc[i].test_case))
58 continue;
59
60 tc = tcase_create(etc[i].test_case);
61 tcase_set_timeout(tc, 0);
62
63 etc[i].build(tc);
64 suite_add_tcase(s, tc);
65 }
66
67 return s;
68}
69
70int main(int argc, char* argv[])
71{
72 Suite *s;
73 SRunner *sr;
74 int i, failed_count;
75
76 for (i = 1; i < argc; i++)
77 if ((strcmp(argv[i], "-h") == 0) ||
78 (strcmp(argv[i], "--help") == 0))
79 {
80 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
81 argv[0]);
82 _list_tests();
83 return 0;
84 }
85 else if ((strcmp(argv[i], "-l") == 0) ||
86 (strcmp(argv[i], "--list") == 0))
87 {
88 _list_tests();
89 return 0;
90 }
91
92 putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
93
94 s = eet_build_suite(argc - 1, (const char **)argv + 1);
95 sr = srunner_create(s);
96
97 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
98
99 srunner_run_all(sr, CK_ENV);
100 failed_count = srunner_ntests_failed(sr);
101 srunner_free(sr);
102
103 return (failed_count == 0) ? 0 : 255;
104}