1/* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
2
3#include <stdio.h>
4#include "unity.h"
5#include "Defs.h"
6
7#ifdef USE_CEXCEPTION
8#include "CException.h"
9#endif
10
11/* Notes about prefixes:
12   test     - normal default prefix. these are "always run" tests for this procedure
13   spec     - normal default prefix. required to run default setup/teardown calls.
14   should   - normal default prefix.
15   qwiktest - custom prefix for when tests skip all setup/teardown calls.
16   custtest - custom prefix for when tests use custom setup/teardown calls.
17   paratest - custom prefix for when we want to verify parameterized tests.
18   extest   - custom prefix only used during cexception
19   suitetest- custom prefix for when we want to use custom suite setup/teardown
20*/
21
22/* Support for Meta Test Rig */
23#define TEST_CASE(a)
24void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
25
26/* Global Variables Used During These Tests */
27int CounterSetup = 0;
28int CounterTeardown = 0;
29int CounterSuiteSetup = 0;
30
31void setUp(void)
32{
33    CounterSetup = 1;
34}
35
36void tearDown(void)
37{
38    CounterTeardown = 1;
39}
40
41void custom_setup(void)
42{
43    CounterSetup = 2;
44}
45
46void custom_teardown(void)
47{
48    CounterTeardown = 2;
49}
50
51/*
52void test_OldSchoolCommentsShouldBeIgnored(void)
53{
54    TEST_ASSERT_FAIL("Old-School Comments Should Be Ignored");
55}
56*/
57
58void test_ThisTestAlwaysPasses(void)
59{
60    TEST_PASS();
61}
62
63void test_ThisTestAlwaysFails(void)
64{
65    TEST_FAIL_MESSAGE("This Test Should Fail");
66}
67
68void test_ThisTestAlwaysIgnored(void)
69{
70    TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
71}
72
73void qwiktest_ThisTestPassesWhenNoSetupRan(void)
74{
75    TEST_ASSERT_EQUAL_MESSAGE(0, CounterSetup, "Setup Was Unexpectedly Run");
76}
77
78void qwiktest_ThisTestPassesWhenNoTeardownRan(void)
79{
80    TEST_ASSERT_EQUAL_MESSAGE(0, CounterTeardown, "Teardown Was Unexpectedly Run");
81}
82
83void spec_ThisTestPassesWhenNormalSuiteSetupAndTeardownRan(void)
84{
85    TEST_ASSERT_EQUAL_MESSAGE(0, CounterSuiteSetup, "Suite Setup Was Unexpectedly Run");
86}
87
88void spec_ThisTestPassesWhenNormalSetupRan(void)
89{
90    TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
91}
92
93void spec_ThisTestPassesWhenNormalTeardownRan(void)
94{
95    TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
96}
97
98void custtest_ThisTestPassesWhenCustomSetupRan(void)
99{
100    TEST_ASSERT_EQUAL_MESSAGE(2, CounterSetup, "Custom Setup Wasn't Run");
101}
102
103void custtest_ThisTestPassesWhenCustomTeardownRan(void)
104{
105    TEST_ASSERT_EQUAL_MESSAGE(2, CounterTeardown, "Custom Teardown Wasn't Run");
106}
107
108//void test_NewStyleCommentsShouldBeIgnored(void)
109//{
110//    TEST_ASSERT_FAIL("New Style Comments Should Be Ignored");
111//}
112
113void test_NotBeConfusedByLongComplicatedStrings(void)
114{
115    const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
116
117    TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are The Same");
118}
119
120void test_NotDisappearJustBecauseTheTestBeforeAndAfterHaveCrazyStrings(void)
121{
122    TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
123}
124
125void test_StillNotBeConfusedByLongComplicatedStrings(void)
126{
127    const char* crazyString = "GET / HTTP/1.1\r\nHost: 127.0.0.1:8081\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36\r\nPostman-Token: 768c7149-c3fb-f704-71a2-63918d9195b2\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: en-GB,en-US;q=0.8,en;q=0.6\r\n\r\n";
128
129    TEST_ASSERT_EQUAL_STRING_MESSAGE(crazyString, crazyString, "These Strings Are Still The Same");
130}
131
132void should_RunTestsStartingWithShouldByDefault(void)
133{
134    TEST_ASSERT_TRUE_MESSAGE(1, "1 Should be True");
135}
136
137TEST_CASE(25)
138TEST_CASE(125)
139TEST_CASE(5)
140void paratest_ShouldHandleParameterizedTests(int Num)
141{
142    TEST_ASSERT_EQUAL_MESSAGE(0, (Num % 5), "All The Values Are Divisible By 5");
143}
144
145TEST_CASE(7)
146void paratest_ShouldHandleParameterizedTests2(int Num)
147{
148    TEST_ASSERT_EQUAL_MESSAGE(7, Num, "The Only Call To This Passes");
149}
150
151void paratest_ShouldHandleNonParameterizedTestsWhenParameterizationValid(void)
152{
153    TEST_PASS();
154}
155
156TEST_CASE(17)
157void paratest_ShouldHandleParameterizedTestsThatFail(int Num)
158{
159    TEST_ASSERT_EQUAL_MESSAGE(3, Num, "This call should fail");
160}
161
162#ifdef USE_CEXCEPTION
163void extest_ShouldHandleCExceptionInTest(void)
164{
165    TEST_ASSERT_EQUAL_MESSAGE(1, CEXCEPTION_BEING_USED, "Should be pulling in CException");
166}
167#endif
168
169#ifdef USE_ANOTHER_MAIN
170int custom_main(void);
171
172int main(void)
173{
174    return custom_main();
175}
176#endif
177
178void suitetest_ThisTestPassesWhenCustomSuiteSetupAndTeardownRan(void)
179{
180    TEST_ASSERT_EQUAL_MESSAGE(1, CounterSuiteSetup, "Suite Setup Should Have Run");
181}
182
183
184