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.

436 lines
10 KiB

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