Debian Codegraph @

src/suite.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/suite.c`/include <cgreen/filename.h>cxx . . $ `<file>/include/cgreen/filename.h`/
2 #include <cgreen/suite.h>cxx . . $ `<file>/include/cgreen/suite.h`/
3 #include <cgreen/unit.h>cxx . . $ `<file>/include/cgreen/unit.h`/
4 #include <cgreen/vector.h>cxx . . $ `<file>/include/cgreen/vector.h`/
5 #ifndef __cplusplus
6 #include <stdbool.h>
7 #endif
8 #include <stddef.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include "parameters.h"cxx . . $ `<file>/src/parameters.h`/
13
14
15 CgreenContextcxx . . $ CgreenContext# defaultContextcxx . . $ defaultContext. = {
16 /* name */ "",
17 /* filename */ FILENAMEcxx . . $ `<built-in>:418:9`!,
18 /* setup */ &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).,
19 /* teardown */ &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).
20 };
21
22 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! has_testcxx . . $ has_test(af8bda7240bc769a).(TestSuitecxx . . $ TestSuite# *suite, const char *name) {
23 int i;
24 for (i = 0; i < suite->sizecxx . . $ TestSuite_#size.; i++) {
25 if (suite->testscxx . . $ TestSuite_#tests.[i].typecxx . . $ $anonymous_type_8d37910ccb4823a7_1#type. == test_functioncxx . . $ test_function.) {
26 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(suite->testscxx . . $ TestSuite_#tests.[i].namecxx . . $ $anonymous_type_8d37910ccb4823a7_1#name., name) == 0) {
27 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
28 }
29 } else if (has_testcxx . . $ has_test(af8bda7240bc769a).(suite->testscxx . . $ TestSuite_#tests.[i].Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..suitecxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#suite., name)) {
30 return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
31 }
32 }
33
34 return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
35 }
36
37 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! has_setupcxx . . $ has_setup(f644169072b4999c).(TestSuitecxx . . $ TestSuite# *suite) {
38 return (suite->setupcxx . . $ TestSuite_#setup. != &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).);
39 }
40
41 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! has_teardowncxx . . $ has_teardown(f644169072b4999c).(TestSuitecxx . . $ TestSuite# *suite) {
42 return (suite->teardowncxx . . $ TestSuite_#teardown. != &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).);
43 }
44
45 void do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).(void) {
46 }
47
48 TestSuitecxx . . $ TestSuite# *create_named_test_suite_cxx . . $ create_named_test_suite_(77de4fc75973812d).(const char *name, const char *filename, int line) {
49 TestSuitecxx . . $ TestSuite# *suite = (TestSuitecxx . . $ TestSuite# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(TestSuitecxx . . $ TestSuite#));
50 suite->namecxx . . $ TestSuite_#name. = name;
51 suite->filenamecxx . . $ TestSuite_#filename. = filename;
52 suite->linecxx . . $ TestSuite_#line. = line;
53 suite->testscxx . . $ TestSuite_#tests. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
54 suite->setupcxx . . $ TestSuite_#setup. = &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).;
55 suite->teardowncxx . . $ TestSuite_#teardown. = &do_nothingcxx . . $ do_nothing(49f6e7a06ebc5aa8).;
56 suite->sizecxx . . $ TestSuite_#size. = 0;
57 return suite;
58 }
59
60 void destroy_test_suitecxx . . $ destroy_test_suite(8fc5cbd6a65ffd2d).(TestSuitecxx . . $ TestSuite# *suiteToDestroy) {
61 int i;
62 for (i = 0; i < suiteToDestroy->sizecxx . . $ TestSuite_#size.; i++) {
63 UnitTestcxx . . $ UnitTest# test = suiteToDestroy->testscxx . . $ TestSuite_#tests.[i];
64 TestSuitecxx . . $ TestSuite#* suite = test.Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..suitecxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#suite.;
65 if (test_suitecxx . . $ test_suite. == test.typecxx . . $ $anonymous_type_8d37910ccb4823a7_1#type. && suite != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
66 suiteToDestroy->testscxx . . $ TestSuite_#tests.[i].Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..suitecxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#suite. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
67 destroy_test_suitecxx . . $ destroy_test_suite(8fc5cbd6a65ffd2d).(suite);
68 }
69 }
70
71 if (suiteToDestroy->testscxx . . $ TestSuite_#tests. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!)
72 freecxx . . $ free(5d22bdacc48458e8).(suiteToDestroy->testscxx . . $ TestSuite_#tests.);
73
74 freecxx . . $ free(5d22bdacc48458e8).(suiteToDestroy);
75 }
76
77 void add_test_cxx . . $ add_test_(1a7f31c2865e427e).(TestSuitecxx . . $ TestSuite# *suite, const char *name, CgreenTestcxx . . $ CgreenTest# *test) {
78 suite->sizecxx . . $ TestSuite_#size.++;
79 suite->testscxx . . $ TestSuite_#tests. = (UnitTestcxx . . $ UnitTest# *)realloccxx . . $ realloc(417ab160f6baadc6).(suite->testscxx . . $ TestSuite_#tests., sizeof(UnitTestcxx . . $ UnitTest#) * suite->sizecxx . . $ TestSuite_#size.);
80 suite->testscxx . . $ TestSuite_#tests.[suite->sizecxx . . $ TestSuite_#size. - 1].typecxx . . $ $anonymous_type_8d37910ccb4823a7_1#type. = test_functioncxx . . $ test_function.;
81 suite->testscxx . . $ TestSuite_#tests.[suite->sizecxx . . $ TestSuite_#size. - 1].namecxx . . $ $anonymous_type_8d37910ccb4823a7_1#name. = name;
82 suite->testscxx . . $ TestSuite_#tests.[suite->sizecxx . . $ TestSuite_#size. - 1].Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..testcxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#test. = test;
83 }
84
85 void add_tests_cxx . . $ add_tests_(7f1d89b9caa963a8).(TestSuitecxx . . $ TestSuite# *suite, const char *names, ...) {
86 CgreenVectorcxx . . $ CgreenVector# *test_names = create_vector_of_namescxx . . $ create_vector_of_names(d5a3278d3d52ae11).(names);
87 int i;
88 va_listcxx . . $ va_list# tests;
89 va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(tests, names);
90 for (i = 0; i < cgreen_vector_sizecxx . . $ cgreen_vector_size(d6a9fa4a29061fe2).(test_names); i++) {
91 add_test_cxx . . $ add_test_(1a7f31c2865e427e).(suite, (char *)(cgreen_vector_getcxx . . $ cgreen_vector_get(3d562d97df0b0b67).(test_names, i)), va_argcxx . . $ `<external>/8293021631987149590/stdarg.h:54:9`!(tests, CgreenTest *));
92 }
93 va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(tests);
94 destroy_cgreen_vectorcxx . . $ destroy_cgreen_vector(fe9e7a16718af6c0).(test_names);
95 }
96
97 void add_suite_cxx . . $ add_suite_(b1565dee450d547c).(TestSuitecxx . . $ TestSuite# *owner, const char *name, TestSuitecxx . . $ TestSuite# *suite) {
98 owner->sizecxx . . $ TestSuite_#size.++;
99 owner->testscxx . . $ TestSuite_#tests. = (UnitTestcxx . . $ UnitTest# *)realloccxx . . $ realloc(417ab160f6baadc6).(owner->testscxx . . $ TestSuite_#tests., sizeof(UnitTestcxx . . $ UnitTest#) * owner->sizecxx . . $ TestSuite_#size.);
100 owner->testscxx . . $ TestSuite_#tests.[owner->sizecxx . . $ TestSuite_#size. - 1].typecxx . . $ $anonymous_type_8d37910ccb4823a7_1#type. = test_suitecxx . . $ test_suite.;
101 owner->testscxx . . $ TestSuite_#tests.[owner->sizecxx . . $ TestSuite_#size. - 1].namecxx . . $ $anonymous_type_8d37910ccb4823a7_1#name. = name;
102 owner->testscxx . . $ TestSuite_#tests.[owner->sizecxx . . $ TestSuite_#size. - 1].Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..suitecxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#suite. = suite;
103 }
104
105 void set_setupcxx . . $ set_setup(375347ed146b1459).(TestSuitecxx . . $ TestSuite# *suite, void (*set_up)(void)) {
106 suite->setupcxx . . $ TestSuite_#setup. = set_up;
107 }
108
109 void set_teardowncxx . . $ set_teardown(375347ed146b1459).(TestSuitecxx . . $ TestSuite# *suite, void (*tear_down)(void)) {
110 suite->teardowncxx . . $ TestSuite_#teardown. = tear_down;
111 }
112
113 int count_testscxx . . $ count_tests(e967fa3a12241ee1).(TestSuitecxx . . $ TestSuite# *suite) {
114 int count = 0;
115 int i;
116 for (i = 0; i < suite->sizecxx . . $ TestSuite_#size.; i++) {
117 if (suite->testscxx . . $ TestSuite_#tests.[i].typecxx . . $ $anonymous_type_8d37910ccb4823a7_1#type. == test_functioncxx . . $ test_function.) {
118 count++;
119 } else {
120 count += count_testscxx . . $ count_tests(e967fa3a12241ee1).(suite->testscxx . . $ TestSuite_#tests.[i].Runnablecxx . . $ $anonymous_type_8d37910ccb4823a7_1#Runnable..suitecxx . . $ $anonymous_type_8d37910ccb4823a7_1#$anonymous_type_2#suite.);
121 }
122 }
123 return count;
124 }
125