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.

384 lines
12 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/component/test.component.inserters.boolean/test.component.inserters.boolean.cpp
  3. *
  4. * Purpose: Implementation file for the test.component.inserters.boolean project.
  5. *
  6. * Created: 7th August 2008
  7. * Updated: 23rd March 2010
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2008-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> // Pantheios C++ main header
  24. #include <pantheios/inserters/boolean.hpp> // for pantheios::boolean
  25. #include <pantheios/backends/bec.test.h>
  26. /* STLSoft Header Files */
  27. #include <stlsoft/util/limit_traits.h>
  28. /* Standard C++ Header Files */
  29. #include <exception>
  30. #include <string>
  31. /* Standard C Header Files */
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  35. /* /////////////////////////////////////////////////////////////////////////
  36. * Forward declarations
  37. */
  38. static void test_1_01();
  39. static void test_1_02();
  40. static void test_1_03();
  41. static void test_1_04();
  42. static void test_1_05();
  43. static void test_1_06();
  44. static void test_1_07();
  45. static void test_1_08();
  46. static void test_1_09();
  47. static void test_1_10();
  48. /* /////////////////////////////////////////////////////////////////////////
  49. * Globals
  50. */
  51. PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.component.inserters.boolean");
  52. /* ////////////////////////////////////////////////////////////////////// */
  53. #define PSTR(x) PANTHEIOS_LITERAL_STRING(x)
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Character encoding
  56. */
  57. #ifdef PANTHEIOS_USE_WIDE_STRINGS
  58. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_WIDE_STRING_EQUAL
  59. #else /* ? PANTHEIOS_USE_WIDE_STRINGS */
  60. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_MULTIBYTE_STRING_EQUAL
  61. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  62. /* ////////////////////////////////////////////////////////////////////// */
  63. int main(int argc, char** argv)
  64. {
  65. int retCode = EXIT_SUCCESS;
  66. int verbosity = 2;
  67. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  68. if(XTESTS_START_RUNNER("test.component.inserters.integer", verbosity))
  69. {
  70. XTESTS_RUN_CASE(test_1_01);
  71. XTESTS_RUN_CASE(test_1_02);
  72. XTESTS_RUN_CASE(test_1_03);
  73. XTESTS_RUN_CASE(test_1_04);
  74. XTESTS_RUN_CASE(test_1_05);
  75. XTESTS_RUN_CASE(test_1_06);
  76. XTESTS_RUN_CASE(test_1_07);
  77. XTESTS_RUN_CASE(test_1_08);
  78. XTESTS_RUN_CASE(test_1_09);
  79. XTESTS_RUN_CASE(test_1_10);
  80. XTESTS_PRINT_RESULTS();
  81. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  82. }
  83. return retCode;
  84. }
  85. /* ////////////////////////////////////////////////////////////////////// */
  86. static void test_1_01()
  87. {
  88. // 1. Setup
  89. pantheios::be::test::reset();
  90. // 2. Create test data
  91. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  92. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  93. // 3. Verification
  94. pantheios::be::test::Results results = pantheios::be::test::results();
  95. XTESTS_TEST(!results.empty());
  96. XTESTS_TEST_INTEGER_EQUAL(2u, results.size());
  97. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[0].statement);
  98. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[1].statement);
  99. }
  100. static void test_1_02()
  101. {
  102. // 1. Setup
  103. pantheios::be::test::reset();
  104. // 2. Create test data
  105. pantheios::boolean::set_value_strings(NULL, NULL);
  106. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  107. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  108. // 3. Verification
  109. pantheios::be::test::Results results = pantheios::be::test::results();
  110. XTESTS_TEST(!results.empty());
  111. XTESTS_TEST_INTEGER_EQUAL(2u, results.size());
  112. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[0].statement);
  113. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[1].statement);
  114. }
  115. static void test_1_03()
  116. {
  117. // 1. Setup
  118. pantheios::be::test::reset();
  119. // 2. Create test data
  120. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  121. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  122. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  123. // 3. Verification
  124. pantheios::be::test::Results results = pantheios::be::test::results();
  125. XTESTS_TEST(!results.empty());
  126. XTESTS_TEST_INTEGER_EQUAL(2u, results.size());
  127. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[0].statement);
  128. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[1].statement);
  129. }
  130. static void test_1_04()
  131. {
  132. // 1. Setup
  133. pantheios::be::test::reset();
  134. // 2. Create test data
  135. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  136. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  137. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  138. pantheios::boolean::set_value_strings(NULL, NULL);
  139. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  140. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  141. // 3. Verification
  142. pantheios::be::test::Results results = pantheios::be::test::results();
  143. XTESTS_TEST(!results.empty());
  144. XTESTS_TEST_INTEGER_EQUAL(4u, results.size());
  145. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[0].statement);
  146. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[1].statement);
  147. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[2].statement);
  148. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[3].statement);
  149. }
  150. static void test_1_05()
  151. {
  152. // 1. Setup
  153. pantheios::be::test::reset();
  154. // 2. Create test data
  155. pantheios::boolean::set_value_strings(PSTR("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), PSTR("T"));
  156. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  157. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  158. pantheios::boolean::set_value_strings(NULL, NULL);
  159. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  160. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  161. // 3. Verification
  162. pantheios::be::test::Results results = pantheios::be::test::results();
  163. XTESTS_TEST(!results.empty());
  164. XTESTS_TEST_INTEGER_EQUAL(4u, results.size());
  165. XTESTS_TEST_STRING_EQUAL(PSTR("{ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff}"), results[0].statement);
  166. XTESTS_TEST_STRING_EQUAL(PSTR("{T}"), results[1].statement);
  167. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[2].statement);
  168. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[3].statement);
  169. }
  170. static void test_1_06()
  171. {
  172. // 1. Setup
  173. pantheios::be::test::reset();
  174. // 2. Create test data
  175. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  176. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  177. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  178. pantheios::boolean::set_value_strings(NULL, NULL);
  179. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  180. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  181. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  182. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  183. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  184. // 3. Verification
  185. pantheios::be::test::Results results = pantheios::be::test::results();
  186. XTESTS_TEST(!results.empty());
  187. XTESTS_TEST_INTEGER_EQUAL(6u, results.size());
  188. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[0].statement);
  189. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[1].statement);
  190. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[2].statement);
  191. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[3].statement);
  192. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[4].statement);
  193. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[5].statement);
  194. }
  195. static void test_1_07()
  196. {
  197. // 1. Setup
  198. pantheios::be::test::reset();
  199. // 2. Create test data
  200. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  201. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  202. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  203. pantheios::boolean::set_value_strings(NULL, NULL);
  204. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  205. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  206. pantheios::boolean::set_value_strings(PSTR("F"), PSTR("T"));
  207. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  208. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  209. // 3. Verification
  210. pantheios::be::test::Results results = pantheios::be::test::results();
  211. XTESTS_TEST(!results.empty());
  212. XTESTS_TEST_INTEGER_EQUAL(6u, results.size());
  213. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[0].statement);
  214. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[1].statement);
  215. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[2].statement);
  216. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[3].statement);
  217. XTESTS_TEST_STRING_EQUAL(PSTR("{F}"), results[4].statement);
  218. XTESTS_TEST_STRING_EQUAL(PSTR("{T}"), results[5].statement);
  219. }
  220. static void test_1_08()
  221. {
  222. // 1. Setup
  223. pantheios::be::test::reset();
  224. // 2. Create test data
  225. pantheios::boolean::set_value_strings(PSTR("FALSE"), PSTR("TRUE"));
  226. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  227. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  228. pantheios::boolean::set_value_strings(NULL, NULL);
  229. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  230. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  231. pantheios::boolean::set_value_strings(PSTR("F"), PSTR("T"));
  232. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  233. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  234. pantheios::boolean::set_value_strings(NULL, NULL);
  235. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(false), PSTR("}"));
  236. pantheios::log_NOTICE(PSTR("{"), pantheios::boolean(true), PSTR("}"));
  237. // 3. Verification
  238. pantheios::be::test::Results results = pantheios::be::test::results();
  239. XTESTS_TEST(!results.empty());
  240. XTESTS_TEST_INTEGER_EQUAL(8u, results.size());
  241. XTESTS_TEST_STRING_EQUAL(PSTR("{FALSE}"), results[0].statement);
  242. XTESTS_TEST_STRING_EQUAL(PSTR("{TRUE}"), results[1].statement);
  243. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[2].statement);
  244. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[3].statement);
  245. XTESTS_TEST_STRING_EQUAL(PSTR("{F}"), results[4].statement);
  246. XTESTS_TEST_STRING_EQUAL(PSTR("{T}"), results[5].statement);
  247. XTESTS_TEST_STRING_EQUAL(PSTR("{false}"), results[6].statement);
  248. XTESTS_TEST_STRING_EQUAL(PSTR("{true}"), results[7].statement);
  249. }
  250. static void test_1_09()
  251. {
  252. }
  253. static void test_1_10()
  254. {
  255. }
  256. /* ///////////////////////////// end of file //////////////////////////// */