You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

469 lines
12 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/component/test.component.log.1/test.component.log.1.cpp
  3. *
  4. * Purpose: Implementation file for the test.component.log.1 project.
  5. *
  6. * Created: 25th November 2007
  7. * Updated: 23rd March 2010
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2007-2010, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. #include <pantheios/util/test/compiler_warnings_suppression.first_include.h>
  20. /* xTests Header Files */
  21. #include <xtests/xtests.h>
  22. /* Pantheios Header Files */
  23. #include <pantheios/pantheios.hpp>
  24. #include <pantheios/backends/bec.test.h>
  25. #include <pantheios/frontends/stock.h>
  26. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  27. /* ////////////////////////////////////////////////////////////////////// */
  28. PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.component.log.1");
  29. /* ////////////////////////////////////////////////////////////////////// */
  30. #define PSTR(x) PANTHEIOS_LITERAL_STRING(x)
  31. /* /////////////////////////////////////////////////////////////////////////
  32. * Character encoding
  33. */
  34. #ifdef PANTHEIOS_USE_WIDE_STRINGS
  35. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_WIDE_STRING_EQUAL
  36. #else /* ? PANTHEIOS_USE_WIDE_STRINGS */
  37. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_MULTIBYTE_STRING_EQUAL
  38. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  39. /* /////////////////////////////////////////////////////////////////////////
  40. * Typedefs
  41. */
  42. typedef std::basic_string<PAN_CHAR_T> string_t;
  43. /* /////////////////////////////////////////////////////////////////////////
  44. * Forward Declarations
  45. */
  46. static void test_01();
  47. static void test_02();
  48. static void test_03();
  49. static void test_04();
  50. static void test_05();
  51. static void test_06();
  52. static void test_07();
  53. static void test_08();
  54. static void test_09();
  55. static void test_10();
  56. static void test_11();
  57. static void test_12();
  58. static void test_13();
  59. static void test_14();
  60. static void test_15();
  61. static void test_16();
  62. static void test_17();
  63. static void test_18();
  64. static void test_19();
  65. static void test_20();
  66. static void test_21();
  67. static void test_22();
  68. static void test_23();
  69. static void test_24();
  70. static void test_25();
  71. static void test_26();
  72. static void test_27();
  73. static void test_28();
  74. static void test_29();
  75. /* ////////////////////////////////////////////////////////////////////// */
  76. int main(int argc, char** argv)
  77. {
  78. int retCode = EXIT_SUCCESS;
  79. int verbosity = 2;
  80. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  81. if(XTESTS_START_RUNNER("test.component.log.1", verbosity))
  82. {
  83. XTESTS_RUN_CASE(test_01);
  84. XTESTS_RUN_CASE(test_02);
  85. XTESTS_RUN_CASE(test_03);
  86. XTESTS_RUN_CASE(test_04);
  87. XTESTS_RUN_CASE(test_05);
  88. XTESTS_RUN_CASE(test_06);
  89. XTESTS_RUN_CASE(test_07);
  90. XTESTS_RUN_CASE(test_08);
  91. XTESTS_RUN_CASE(test_09);
  92. XTESTS_RUN_CASE(test_10);
  93. XTESTS_RUN_CASE(test_11);
  94. XTESTS_RUN_CASE(test_12);
  95. XTESTS_RUN_CASE(test_13);
  96. XTESTS_RUN_CASE(test_14);
  97. XTESTS_RUN_CASE(test_15);
  98. XTESTS_RUN_CASE(test_16);
  99. XTESTS_RUN_CASE(test_17);
  100. XTESTS_RUN_CASE(test_18);
  101. XTESTS_RUN_CASE(test_19);
  102. XTESTS_RUN_CASE(test_20);
  103. XTESTS_RUN_CASE(test_21);
  104. XTESTS_RUN_CASE(test_22);
  105. XTESTS_RUN_CASE(test_23);
  106. XTESTS_RUN_CASE(test_24);
  107. XTESTS_RUN_CASE(test_25);
  108. XTESTS_RUN_CASE(test_26);
  109. XTESTS_RUN_CASE(test_27);
  110. XTESTS_RUN_CASE(test_28);
  111. XTESTS_RUN_CASE(test_29);
  112. XTESTS_PRINT_RESULTS();
  113. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  114. }
  115. else
  116. {
  117. retCode = EXIT_FAILURE;
  118. }
  119. return retCode;
  120. }
  121. /* ////////////////////////////////////////////////////////////////////// */
  122. static void test_01()
  123. {
  124. // 1. Setup
  125. pantheios::be::test::reset();
  126. // 2. Create test data
  127. // 3. Verification
  128. pantheios::be::test::Results results = pantheios::be::test::results();
  129. XTESTS_TEST_BOOLEAN_TRUE(results.empty());
  130. XTESTS_TEST_INTEGER_EQUAL(0u, results.size());
  131. }
  132. static void test_02()
  133. {
  134. // 1. Setup
  135. pantheios::be::test::reset();
  136. // 2. Create test data
  137. pantheios::log(pantheios::notice, PSTR(""));
  138. // 3. Verification
  139. pantheios::be::test::Results results = pantheios::be::test::results();
  140. XTESTS_TEST_BOOLEAN_FALSE(results.empty());
  141. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  142. XTESTS_TEST_STRING_EQUAL(PSTR(""), results[0].statement);
  143. XTESTS_TEST(pantheios::notice == results[0].severity);
  144. }
  145. static void test_03()
  146. {
  147. // 1. Setup
  148. pantheios::be::test::reset();
  149. // 2. Create test data
  150. pantheios::log(pantheios::notice, PSTR("abc"));
  151. // 3. Verification
  152. pantheios::be::test::Results results = pantheios::be::test::results();
  153. XTESTS_TEST_BOOLEAN_FALSE(results.empty());
  154. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  155. XTESTS_TEST_STRING_EQUAL(PSTR("abc"), results[0].statement);
  156. XTESTS_TEST(pantheios::notice == results[0].severity);
  157. }
  158. static void test_04()
  159. {
  160. // 1. Setup
  161. pantheios::be::test::reset();
  162. // 2. Create test data
  163. pantheios::log(pantheios::informational, PSTR("abc"), PSTR("def"));
  164. // 3. Verification
  165. pantheios::be::test::Results results = pantheios::be::test::results();
  166. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  167. XTESTS_TEST_STRING_EQUAL(PSTR("abcdef"), results[0].statement);
  168. XTESTS_TEST(pantheios::informational == results[0].severity);
  169. }
  170. static void test_05()
  171. {
  172. // 1. Setup
  173. pantheios::be::test::reset();
  174. // 2. Create test data
  175. pantheios::log(pantheios::informational, PSTR("abc"), PSTR("def"), PSTR("ghi"));
  176. // 3. Verification
  177. pantheios::be::test::Results results = pantheios::be::test::results();
  178. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  179. XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghi"), results[0].statement);
  180. XTESTS_TEST(pantheios::informational == results[0].severity);
  181. }
  182. static void test_06()
  183. {
  184. // 1. Setup
  185. pantheios::be::test::reset();
  186. // 2. Create test data
  187. pantheios::log(pantheios::informational, PSTR("abc"), PSTR("def"), PSTR("ghi"), PSTR("jk"), PSTR("lm"), PSTR("no"), PSTR("pq"), PSTR("rs"), PSTR("tu"), PSTR("vw"), PSTR("xy"), PSTR("z"));
  188. // 3. Verification
  189. pantheios::be::test::Results results = pantheios::be::test::results();
  190. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  191. XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyz"), results[0].statement);
  192. XTESTS_TEST(pantheios::informational == results[0].severity);
  193. }
  194. static void test_07()
  195. {
  196. // 1. Setup
  197. pantheios::be::test::reset();
  198. // 2. Create test data
  199. pantheios::log(pantheios::informational, PSTR("a"), PSTR("b"), PSTR("c"), PSTR("d"), PSTR("e"), PSTR("f"), PSTR("g"), PSTR("h"), PSTR("i"), PSTR("j"), PSTR("k"), PSTR("l"), PSTR("m"), PSTR("n"), PSTR("o"), PSTR("p"), PSTR("q"), PSTR("r"), PSTR("s"), PSTR("t"), PSTR("u"), PSTR("v"), PSTR("w"), PSTR("x"), PSTR("y"), PSTR("z"));
  200. // 3. Verification
  201. pantheios::be::test::Results results = pantheios::be::test::results();
  202. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  203. XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyz"), results[0].statement);
  204. XTESTS_TEST(pantheios::informational == results[0].severity);
  205. }
  206. static void test_08()
  207. {}
  208. static void test_09()
  209. {}
  210. static void test_10()
  211. {
  212. // 1. Setup
  213. pantheios::be::test::reset();
  214. // 2. Create test data
  215. pantheios::log(pantheios::informational, PSTR("a"), PSTR("b"), PSTR("c"), PSTR("d"), PSTR("e"), PSTR("f"), PSTR("g"), PSTR("h"), PSTR("i"), PSTR("j"), PSTR("k"), PSTR("l"), PSTR("m"), PSTR("n"), PSTR("o"), PSTR("p"), PSTR("q"), PSTR("r"), PSTR("s"), PSTR("t"), PSTR("u"), PSTR("v"), PSTR("w"), PSTR("x"), PSTR("y"), PSTR("z"));
  216. pantheios::log(pantheios::informational, PSTR("A"), PSTR("B"), PSTR("C"), PSTR("D"), PSTR("E"), PSTR("F"), PSTR("G"), PSTR("H"), PSTR("I"), PSTR("J"), PSTR("K"), PSTR("L"), PSTR("M"), PSTR("N"), PSTR("O"), PSTR("P"), PSTR("Q"), PSTR("R"), PSTR("S"), PSTR("T"), PSTR("U"), PSTR("V"), PSTR("W"), PSTR("X"), PSTR("Y"), PSTR("Z"));
  217. // 3. Verification
  218. pantheios::be::test::Results results = pantheios::be::test::results();
  219. XTESTS_TEST_INTEGER_EQUAL(2u, results.size());
  220. XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyz"), results[0].statement);
  221. XTESTS_TEST_STRING_EQUAL(PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), results[1].statement);
  222. }
  223. static void test_11()
  224. {
  225. // 1. Setup
  226. pantheios::be::test::reset();
  227. // 2. Create test data
  228. const size_t numEntries = 1000;
  229. { for(size_t i = 0; i < numEntries; ++i)
  230. {
  231. if(0 == (i % 2))
  232. {
  233. pantheios::log(pantheios::informational, PSTR("a"), PSTR("b"), PSTR("c"), PSTR("d"), PSTR("e"), PSTR("f"), PSTR("g"), PSTR("h"), PSTR("i"), PSTR("j"), PSTR("k"), PSTR("l"), PSTR("m"), PSTR("n"), PSTR("o"), PSTR("p"), PSTR("q"), PSTR("r"), PSTR("s"), PSTR("t"), PSTR("u"), PSTR("v"), PSTR("w"), PSTR("x"), PSTR("y"), PSTR("z"));
  234. }
  235. else
  236. {
  237. pantheios::log(pantheios::informational, PSTR("A"), PSTR("B"), PSTR("C"), PSTR("D"), PSTR("E"), PSTR("F"), PSTR("G"), PSTR("H"), PSTR("I"), PSTR("J"), PSTR("K"), PSTR("L"), PSTR("M"), PSTR("N"), PSTR("O"), PSTR("P"), PSTR("Q"), PSTR("R"), PSTR("S"), PSTR("T"), PSTR("U"), PSTR("V"), PSTR("W"), PSTR("X"), PSTR("Y"), PSTR("Z"));
  238. }
  239. }}
  240. // 3. Verification
  241. pantheios::be::test::Results results = pantheios::be::test::results();
  242. XTESTS_TEST_INTEGER_EQUAL(numEntries, results.size());
  243. { for(size_t i = 0; i < numEntries; ++i)
  244. {
  245. if(0 == (i % 2))
  246. {
  247. XTESTS_TEST_STRING_EQUAL(PSTR("abcdefghijklmnopqrstuvwxyz"), results[i].statement);
  248. }
  249. else
  250. {
  251. XTESTS_TEST_STRING_EQUAL(PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), results[i].statement);
  252. }
  253. }}
  254. }
  255. static void test_12()
  256. {}
  257. static void test_13()
  258. {}
  259. static void test_14()
  260. {}
  261. static void test_15()
  262. {}
  263. static void test_16()
  264. {}
  265. static void test_17()
  266. {}
  267. static void test_18()
  268. {}
  269. static void test_19()
  270. {}
  271. static void test_20()
  272. {}
  273. static void test_21()
  274. {
  275. // 1. Setup
  276. pantheios::be::test::reset();
  277. // 2. Create test data
  278. string_t msgEl1(256, '~');
  279. string_t msgEl2(4096, '#');
  280. pantheios::log(pantheios::informational, msgEl1, msgEl2);
  281. // 3. Verification
  282. pantheios::be::test::Results results = pantheios::be::test::results();
  283. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  284. XTESTS_TEST_STRING_EQUAL(msgEl1 + msgEl2, results[0].statement);
  285. XTESTS_TEST(pantheios::informational == results[0].severity);
  286. }
  287. static void test_22()
  288. {
  289. // 1. Setup
  290. pantheios::be::test::reset();
  291. // 2. Create test data
  292. string_t msgEl1(2560, '~');
  293. string_t msgEl2(40960, '#');
  294. pantheios::log(pantheios::informational, msgEl1, msgEl2);
  295. // 3. Verification
  296. pantheios::be::test::Results results = pantheios::be::test::results();
  297. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  298. XTESTS_TEST_STRING_EQUAL(msgEl1 + msgEl2, results[0].statement);
  299. XTESTS_TEST(pantheios::informational == results[0].severity);
  300. }
  301. static void test_23()
  302. {}
  303. static void test_24()
  304. {}
  305. static void test_25()
  306. {}
  307. static void test_26()
  308. {}
  309. static void test_27()
  310. {}
  311. static void test_28()
  312. {}
  313. static void test_29()
  314. {}
  315. /* ///////////////////////////// end of file //////////////////////////// */