| 1 | #cxx . . $ `<file>/tests/xml_reporter_tests.c`/include <cgreen/cgreen.h>cxx . . $ `<file>/include/cgreen/cgreen.h`/ |
| 2 | #include <cgreen/breadcrumb.h>cxx . . $ `<file>/include/cgreen/breadcrumb.h`/ |
| 3 | #include <cgreen/messaging.h>cxx . . $ `<file>/include/cgreen/messaging.h`/ |
| 4 | |
| 5 | #include <stdio.h> |
| 6 | #include <string.h> |
| 7 | #include <unistd.h> |
| 8 | |
| 9 | #ifdef __cpluspluscxx . . $ `<built-in>:440:9`! |
| 10 | using namespace cgreen; |
| 11 | #endif |
| 12 | |
| 13 | |
| 14 | #include "xml_reporter_internal.h"cxx . . $ `<file>/src/xml_reporter_internal.h`/ |
| 15 | |
| 16 | |
| 17 | static const int linecxx . . $ line.=666; |
| 18 | static char *outputcxx . . $ output. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 19 | |
| 20 | static void clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(void) |
| 21 | { |
| 22 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! != outputcxx . . $ output.) { |
| 23 | freecxx . . $ free(5d22bdacc48458e8).(outputcxx . . $ output.); |
| 24 | } |
| 25 | |
| 26 | outputcxx . . $ output. = (char*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(1); |
| 27 | *outputcxx . . $ output. = '\0'; |
| 28 | } |
| 29 | |
| 30 | static char *concatcxx . . $ concat(5bd1a890f71b1efd).(char *output, char *buffer) { |
| 31 | output = (char *) realloccxx . . $ realloc(417ab160f6baadc6).(output, strlencxx . . $ strlen(751346f8406fd082).(output)+strlencxx . . $ strlen(751346f8406fd082).(buffer)+1); |
| 32 | strcatcxx . . $ strcat(b7b3a83273496486).(output, buffer); |
| 33 | return output; |
| 34 | } |
| 35 | |
| 36 | static char* pointer_to_substringcxx . . $ pointer_to_substring(b7b3a83273496486).(char* haystack, const char* needle) { |
| 37 | return strstrcxx . . $ strstr(a713fe7b9a57cf96).(haystack,needle); |
| 38 | } |
| 39 | |
| 40 | static char* pointer_to_second_substringcxx . . $ pointer_to_second_substring(b7b3a83273496486).(char* haystack, const char* needle) { |
| 41 | return strstrcxx . . $ strstr(a713fe7b9a57cf96).(strstrcxx . . $ strstr(a713fe7b9a57cf96).(haystack,needle)+1,needle); |
| 42 | } |
| 43 | |
| 44 | static int mocked_printfcxx . . $ mocked_printf(bc216f8e5b1ebeac).(FILEcxx . . $ FILE# *file, const char *format, ...) { |
| 45 | char buffer[10000]; |
| 46 | va_listcxx . . $ va_list# ap; |
| 47 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, format); |
| 48 | vsnprintfcxx . . $ vsnprintf(a85eea89d1bd834f).(buffer, sizeof(buffer), format, ap); |
| 49 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap); |
| 50 | |
| 51 | (void)file; |
| 52 | outputcxx . . $ output. = concatcxx . . $ concat(5bd1a890f71b1efd).(outputcxx . . $ output., buffer); |
| 53 | return strlencxx . . $ strlen(751346f8406fd082).(outputcxx . . $ output.); |
| 54 | } |
| 55 | |
| 56 | static TestReportercxx . . $ TestReporter# *reportercxx . . $ reporter.; |
| 57 | |
| 58 | static void setup_xml_reporter_testscxx . . $ setup_xml_reporter_tests(49f6e7a06ebc5aa8).(void) { |
| 59 | reportercxx . . $ reporter. = create_xml_reportercxx . . $ create_xml_reporter(7e5a2d32a0879f75).("PREFIX"); |
| 60 | |
| 61 | // We can not use setup_reporting() since we are running |
| 62 | // inside a test suite which needs the real reporting |
| 63 | // So we'll have to set up the messaging explicitly |
| 64 | reportercxx . . $ reporter.->ipccxx . . $ TestReporter_#ipc. = start_cgreen_messagingcxx . . $ start_cgreen_messaging(7864480464b09eea).(667); |
| 65 | |
| 66 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 67 | set_xml_reporter_printercxx . . $ set_xml_reporter_printer(5ae1a2e3eabb5e05).(reportercxx . . $ reporter., mocked_printfcxx . . $ mocked_printf(bc216f8e5b1ebeac).); |
| 68 | } |
| 69 | |
| 70 | static void teardown_xml_reporter_testscxx . . $ teardown_xml_reporter_tests(49f6e7a06ebc5aa8).(void) { |
| 71 | //bad mojo when running tests in same process, as destroy_reporter also sets |
| 72 | //context.reporter = NULL, thus breaking the next test to run |
| 73 | destroy_reportercxx . . $ destroy_reporter(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 74 | if (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`! != outputcxx . . $ output.) { |
| 75 | freecxx . . $ free(5d22bdacc48458e8).(outputcxx . . $ output.); |
| 76 | //need to set output to NULL to avoid second free in |
| 77 | //subsequent call to setup_xml_reporter_tests->clear_output |
| 78 | //when running tests in same process |
| 79 | outputcxx . . $ output. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | |
| 84 | Describecxx . . $ setupXmlReporter(49f6e7a06ebc5aa8).(XmlReporter); |
| 85 | BeforeEachcxx . . $ BeforeEach_For_XmlReporter_Function(49f6e7a06ebc5aa8).(XmlReporter) { |
| 86 | setup_xml_reporter_testscxx . . $ setup_xml_reporter_tests(49f6e7a06ebc5aa8).(); |
| 87 | } |
| 88 | AfterEachcxx . . $ AfterEach_For_XmlReporter.(XmlReporter) { |
| 89 | teardown_xml_reporter_testscxx . . $ teardown_xml_reporter_tests(49f6e7a06ebc5aa8).(); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | Ensurecxx . . $ CgreenTest#(XmlReporter, will_report_beginning_of_suite) { |
| 94 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 2); |
| 95 | assert_thatcxx . . $ output.(output, begins_with_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:45:9`!("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n<testsuite name=\"suite_name")); |
| 96 | } |
| 97 | |
| 98 | |
| 99 | Ensurecxx . . $ CgreenSpec__XmlReporter__will_report_beginning_and_successful_finishing_of_passing_test__.(XmlReporter, will_report_beginning_and_successful_finishing_of_passing_test) { |
| 100 | va_listcxx . . $ va_list# null_arguments; |
| 101 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&null_arguments, 0, sizeof(null_arguments)); |
| 102 | |
| 103 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 104 | assert_thatcxx . . $ cgreen/(output, begins_with_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:45:9`!("<testcase classname=\"\"")); |
| 105 | assert_thatcxx . . $ intptr_t#(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("name=\"test_name\"")); |
| 106 | |
| 107 | clear_outputcxx . . $ clear_output(49f6e7a06ebc5aa8).(); |
| 108 | |
| 109 | reportercxx . . $ reporter.->show_passcxx . . $ TestReporter_#show_pass.(reportercxx . . $ reporter., "file", 2, "test_name", null_arguments); |
| 110 | assert_thatcxx . . $ output.(strlen(output), is_equal_tocxx . . $ `include/cgreen/constraint_syntax_helpers.h:26:9`!(0)); |
| 111 | |
| 112 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 113 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("</testcase>")); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | Ensurecxx . . $ XmlReporter__will_report_a_failing_test(49f6e7a06ebc5aa8).(XmlReporter, will_report_a_failing_test) { |
| 118 | va_listcxx . . $ va_list# null_arguments; |
| 119 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&null_arguments, 0, sizeof(null_arguments)); |
| 120 | |
| 121 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 122 | reportercxx . . $ reporter.->show_failcxx . . $ TestReporter_#show_fail.(reportercxx . . $ reporter., "file", 2, "test_name", null_arguments); |
| 123 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:416:9`!); |
| 124 | |
| 125 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<failure message=\"test_name\">")); |
| 126 | assert_thatcxx . . $ intptr_t#(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<location file=\"file\" line=\"2\"/>")); |
| 127 | assert_thatcxx . . $ intptr_t#(strstr(output, "time="), is_less_thancxx . . $ `include/cgreen/constraint_syntax_helpers.h:36:9`!(strstr(output, "<failure"))); |
| 128 | } |
| 129 | |
| 130 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(XmlReporter, will_report_a_failing_test_only_once) { |
| 131 | va_listcxx . . $ va_list# null_arguments; |
| 132 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&null_arguments, 0, sizeof(null_arguments)); |
| 133 | |
| 134 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 135 | reportercxx . . $ reporter.->show_failcxx . . $ TestReporter_#show_fail.(reportercxx . . $ reporter., "file", 2, "test_failure_message", null_arguments); |
| 136 | reportercxx . . $ reporter.->show_failcxx . . $ TestReporter_#show_fail.(reportercxx . . $ reporter., "file", 2, "other_message", null_arguments); |
| 137 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", linecxx . . $ line., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 138 | |
| 139 | assert_thatcxx . . $ pointer_to_substring(b7b3a83273496486).(pointer_to_substring(output, "<failure message=\"test_failure_message\">"), is_not_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:30:9`!); |
| 140 | assert_thatcxx . . $ pointer_to_substring(b7b3a83273496486).(pointer_to_substring(output, "<failure message=\"other_message\">"), is_not_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:30:9`!); |
| 141 | assert_thatcxx . . $ cgreen/(pointer_to_second_substring(output, "<failure message=\"test_failure_message\">"), is_nullcxx . . $ `include/cgreen/constraint_syntax_helpers.h:31:9`!); |
| 142 | } |
| 143 | |
| 144 | |
| 145 | Ensurecxx . . $ CgreenTest#(XmlReporter, will_report_finishing_of_suite) { |
| 146 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 1); |
| 147 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", linecxx . . $ line.); |
| 148 | |
| 149 | assert_thatcxx . . $ cgreen/(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("</testsuite>")); |
| 150 | } |
| 151 | |
| 152 | |
| 153 | Ensurecxx . . $ contextForXmlReporter.(XmlReporter, will_mark_ignored_test_as_skipped) { |
| 154 | const int line = 666; |
| 155 | |
| 156 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 1); |
| 157 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "skipped_test_name"); |
| 158 | send_reporter_skipped_notificationcxx . . $ send_reporter_skipped_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 159 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", line, "message"); |
| 160 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", line); |
| 161 | |
| 162 | assert_thatcxx . . $ cgreen/assert_that_(b064aa216885589).(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("<skipped />")); |
| 163 | assert_thatcxx . . $ cgreen/(strstr(output, "time="), is_less_thancxx . . $ `include/cgreen/constraint_syntax_helpers.h:36:9`!(strstr(output, "<skipped"))); |
| 164 | } |
| 165 | |
| 166 | |
| 167 | Ensurecxx . . $ `include/cgreen/unit.h:25:9`!(XmlReporter, will_report_non_finishing_test) { |
| 168 | const int line = 666; |
| 169 | |
| 170 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 1); |
| 171 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 172 | send_reporter_exception_notificationcxx . . $ send_reporter_exception_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 173 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", line, "message"); |
| 174 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", line); |
| 175 | |
| 176 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("error type=\"Fatal\"")); |
| 177 | assert_thatcxx . . $ output.(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("message=\"message\"")); |
| 178 | } |
| 179 | |
| 180 | Ensurecxx . . $ CgreenTest#(XmlReporter, will_report_time_correctly_for_non_finishing_test) { |
| 181 | const int line = 666; |
| 182 | |
| 183 | reportercxx . . $ reporter.->start_suitecxx . . $ TestReporter_#start_suite.(reportercxx . . $ reporter., "suite_name", 1); |
| 184 | reportercxx . . $ reporter.->start_testcxx . . $ TestReporter_#start_test.(reportercxx . . $ reporter., "test_name"); |
| 185 | send_reporter_exception_notificationcxx . . $ send_reporter_exception_notification(1083e9dac9de8fd0).(reportercxx . . $ reporter.); |
| 186 | reportercxx . . $ reporter.->finish_testcxx . . $ TestReporter_#finish_test.(reportercxx . . $ reporter., "filename", line, "message"); |
| 187 | reportercxx . . $ reporter.->finish_suitecxx . . $ TestReporter_#finish_suite.(reportercxx . . $ reporter., "filename", line); |
| 188 | |
| 189 | assert_thatcxx . . $ `include/cgreen/assertions.h:30:9`!(output, contains_stringcxx . . $ `include/cgreen/constraint_syntax_helpers.h:43:9`!("name=\"test_name\" time=\"")); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | TestSuitecxx . . $ TestSuite# *xml_reporter_testscxx . . $ xml_reporter_tests(564401a81ded3a53).(void) { |
| 194 | TestSuitecxx . . $ TestSuite# *suite = create_test_suitecxx . . $ `include/cgreen/suite.h:20:9`!(); |
| 195 | set_setupcxx . . $ set_setup(375347ed146b1459).(suite, setup_xml_reporter_testscxx . . $ setup_xml_reporter_tests(49f6e7a06ebc5aa8).); |
| 196 | |
| 197 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_beginning_of_suite); |
| 198 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_beginning_and_successful_finishing_of_passing_test); |
| 199 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_a_failing_test); |
| 200 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_a_failing_test_only_once); |
| 201 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_mark_ignored_test_as_skipped); |
| 202 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_finishing_of_suite); |
| 203 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_non_finishing_test); |
| 204 | add_test_with_contextcxx . . $ `include/cgreen/suite.h:23:9`!(suite, XmlReporter, will_report_time_correctly_for_non_finishing_test); |
| 205 | |
| 206 | set_teardowncxx . . $ set_teardown(375347ed146b1459).(suite, teardown_xml_reporter_testscxx . . $ teardown_xml_reporter_tests(49f6e7a06ebc5aa8).); |
| 207 | return suite; |
| 208 | } |