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.

717 lines
15 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/component/test.component.inserters.w2m/test.component.inserters.w2m.cpp
  3. *
  4. * Purpose: Implementation file for the test.component.inserters.w2m project.
  5. *
  6. * Created: 19th October 2006
  7. * Updated: 6th August 2012
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2006-2012, 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.h>
  24. #include <stlsoft/string/simple_string.hpp>
  25. #include <pantheios/pantheios.hpp> // Pantheios C++ main header
  26. #include <pantheios/inserters/w2m.hpp> // for pantheios::w2m
  27. #include <pantheios/backends/bec.test.h>
  28. /* STLSoft Header Files */
  29. #include <stlsoft/util/limit_traits.h>
  30. #include <stlsoft/string/simple_string.hpp>
  31. /* Standard C++ Header Files */
  32. #include <exception>
  33. #include <string>
  34. /* Standard C Header Files */
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  38. /* /////////////////////////////////////////////////////////////////////////
  39. * Forward declarations
  40. */
  41. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  42. static void test_1_01();
  43. static void test_1_02();
  44. static void test_1_03();
  45. static void test_1_04();
  46. static void test_1_05();
  47. static void test_1_06();
  48. static void test_1_07();
  49. static void test_1_08();
  50. static void test_1_09();
  51. static void test_2_01();
  52. static void test_2_02();
  53. static void test_2_03();
  54. static void test_2_04();
  55. static void test_2_05();
  56. static void test_2_06();
  57. static void test_2_07();
  58. static void test_2_08();
  59. static void test_2_09();
  60. static void test_3_01();
  61. static void test_3_02();
  62. static void test_3_03();
  63. static void test_3_04();
  64. static void test_3_05();
  65. static void test_3_06();
  66. static void test_3_07();
  67. static void test_3_08();
  68. static void test_3_09();
  69. #endif /* !PANTHEIOS_USE_WIDE_STRINGS */
  70. /* /////////////////////////////////////////////////////////////////////////
  71. * Globals
  72. */
  73. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.component.inserters.w2m");
  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.w2m", verbosity))
  81. {
  82. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  83. XTESTS_RUN_CASE(test_1_01);
  84. XTESTS_RUN_CASE(test_1_02);
  85. XTESTS_RUN_CASE(test_1_03);
  86. XTESTS_RUN_CASE(test_1_04);
  87. XTESTS_RUN_CASE(test_1_05);
  88. XTESTS_RUN_CASE(test_1_06);
  89. XTESTS_RUN_CASE(test_1_07);
  90. XTESTS_RUN_CASE(test_1_08);
  91. XTESTS_RUN_CASE(test_1_09);
  92. XTESTS_RUN_CASE(test_2_01);
  93. XTESTS_RUN_CASE(test_2_02);
  94. XTESTS_RUN_CASE(test_2_03);
  95. XTESTS_RUN_CASE(test_2_04);
  96. XTESTS_RUN_CASE(test_2_05);
  97. XTESTS_RUN_CASE(test_2_06);
  98. XTESTS_RUN_CASE(test_2_07);
  99. XTESTS_RUN_CASE(test_2_08);
  100. XTESTS_RUN_CASE(test_2_09);
  101. XTESTS_RUN_CASE(test_3_01);
  102. XTESTS_RUN_CASE(test_3_02);
  103. XTESTS_RUN_CASE(test_3_03);
  104. XTESTS_RUN_CASE(test_3_04);
  105. XTESTS_RUN_CASE(test_3_05);
  106. XTESTS_RUN_CASE(test_3_06);
  107. XTESTS_RUN_CASE(test_3_07);
  108. XTESTS_RUN_CASE(test_3_08);
  109. XTESTS_RUN_CASE(test_3_09);
  110. #endif /* !PANTHEIOS_USE_WIDE_STRINGS */
  111. XTESTS_PRINT_RESULTS();
  112. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  113. }
  114. return retCode;
  115. }
  116. /* ////////////////////////////////////////////////////////////////////// */
  117. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  118. static void test_1_01()
  119. {
  120. // 1. Setup
  121. pantheios::be::test::reset();
  122. // 2. Create test data
  123. pantheios::log_NOTICE(pantheios::w2m(L""));
  124. // 3. Verification
  125. pantheios::be::test::Results results = pantheios::be::test::results();
  126. XTESTS_TEST(!results.empty());
  127. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  128. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  129. }
  130. static void test_1_02()
  131. {
  132. // 1. Setup
  133. pantheios::be::test::reset();
  134. // 2. Create test data
  135. pantheios::log_NOTICE(pantheios::w2m(L"a"));
  136. // 3. Verification
  137. pantheios::be::test::Results results = pantheios::be::test::results();
  138. XTESTS_TEST(!results.empty());
  139. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  140. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("a", results[0].statement);
  141. }
  142. static void test_1_03()
  143. {
  144. // 1. Setup
  145. pantheios::be::test::reset();
  146. // 2. Create test data
  147. pantheios::log_NOTICE("[", pantheios::w2m(L"abc"), "]");
  148. // 3. Verification
  149. pantheios::be::test::Results results = pantheios::be::test::results();
  150. XTESTS_TEST(!results.empty());
  151. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  152. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("[abc]", results[0].statement);
  153. }
  154. static void test_1_04()
  155. {
  156. // 1. Setup
  157. pantheios::be::test::reset();
  158. // 2. Create test data
  159. pantheios::log_NOTICE(pantheios::w2m(L""));
  160. // 3. Verification
  161. pantheios::be::test::Results results = pantheios::be::test::results();
  162. XTESTS_TEST(!results.empty());
  163. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  164. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  165. }
  166. static void test_1_05()
  167. {
  168. // 1. Setup
  169. pantheios::be::test::reset();
  170. // 2. Create test data
  171. pantheios::log_NOTICE(pantheios::w2m(L""));
  172. // 3. Verification
  173. pantheios::be::test::Results results = pantheios::be::test::results();
  174. XTESTS_TEST(!results.empty());
  175. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  176. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  177. }
  178. static void test_1_06()
  179. {
  180. // 1. Setup
  181. pantheios::be::test::reset();
  182. // 2. Create test data
  183. pantheios::log_NOTICE(pantheios::w2m(L""));
  184. // 3. Verification
  185. pantheios::be::test::Results results = pantheios::be::test::results();
  186. XTESTS_TEST(!results.empty());
  187. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  188. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  189. }
  190. static void test_1_07()
  191. {
  192. // 1. Setup
  193. pantheios::be::test::reset();
  194. // 2. Create test data
  195. pantheios::log_NOTICE(pantheios::w2m(L""));
  196. // 3. Verification
  197. pantheios::be::test::Results results = pantheios::be::test::results();
  198. XTESTS_TEST(!results.empty());
  199. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  200. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  201. }
  202. static void test_1_08()
  203. {
  204. // 1. Setup
  205. pantheios::be::test::reset();
  206. // 2. Create test data
  207. pantheios::log_NOTICE(pantheios::w2m(L""));
  208. // 3. Verification
  209. pantheios::be::test::Results results = pantheios::be::test::results();
  210. XTESTS_TEST(!results.empty());
  211. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  212. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  213. }
  214. static void test_1_09()
  215. {
  216. // 1. Setup
  217. pantheios::be::test::reset();
  218. // 2. Create test data
  219. pantheios::log_NOTICE(pantheios::w2m(L""));
  220. // 3. Verification
  221. pantheios::be::test::Results results = pantheios::be::test::results();
  222. XTESTS_TEST(!results.empty());
  223. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  224. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  225. }
  226. static void test_2_01()
  227. {
  228. // 1. Setup
  229. pantheios::be::test::reset();
  230. // 2. Create test data
  231. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  232. // 3. Verification
  233. pantheios::be::test::Results results = pantheios::be::test::results();
  234. XTESTS_TEST(!results.empty());
  235. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  236. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  237. }
  238. static void test_2_02()
  239. {
  240. // 1. Setup
  241. pantheios::be::test::reset();
  242. // 2. Create test data
  243. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"a")));
  244. // 3. Verification
  245. pantheios::be::test::Results results = pantheios::be::test::results();
  246. XTESTS_TEST(!results.empty());
  247. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  248. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("a", results[0].statement);
  249. }
  250. static void test_2_03()
  251. {
  252. // 1. Setup
  253. pantheios::be::test::reset();
  254. // 2. Create test data
  255. pantheios::log_NOTICE("[", pantheios::w2m(std::wstring(L"abc")), "]");
  256. // 3. Verification
  257. pantheios::be::test::Results results = pantheios::be::test::results();
  258. XTESTS_TEST(!results.empty());
  259. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  260. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("[abc]", results[0].statement);
  261. }
  262. static void test_2_04()
  263. {
  264. // 1. Setup
  265. pantheios::be::test::reset();
  266. // 2. Create test data
  267. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  268. // 3. Verification
  269. pantheios::be::test::Results results = pantheios::be::test::results();
  270. XTESTS_TEST(!results.empty());
  271. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  272. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  273. }
  274. static void test_2_05()
  275. {
  276. // 1. Setup
  277. pantheios::be::test::reset();
  278. // 2. Create test data
  279. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  280. // 3. Verification
  281. pantheios::be::test::Results results = pantheios::be::test::results();
  282. XTESTS_TEST(!results.empty());
  283. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  284. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  285. }
  286. static void test_2_06()
  287. {
  288. // 1. Setup
  289. pantheios::be::test::reset();
  290. // 2. Create test data
  291. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  292. // 3. Verification
  293. pantheios::be::test::Results results = pantheios::be::test::results();
  294. XTESTS_TEST(!results.empty());
  295. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  296. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  297. }
  298. static void test_2_07()
  299. {
  300. // 1. Setup
  301. pantheios::be::test::reset();
  302. // 2. Create test data
  303. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  304. // 3. Verification
  305. pantheios::be::test::Results results = pantheios::be::test::results();
  306. XTESTS_TEST(!results.empty());
  307. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  308. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  309. }
  310. static void test_2_08()
  311. {
  312. // 1. Setup
  313. pantheios::be::test::reset();
  314. // 2. Create test data
  315. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  316. // 3. Verification
  317. pantheios::be::test::Results results = pantheios::be::test::results();
  318. XTESTS_TEST(!results.empty());
  319. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  320. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  321. }
  322. static void test_2_09()
  323. {
  324. // 1. Setup
  325. pantheios::be::test::reset();
  326. // 2. Create test data
  327. pantheios::log_NOTICE(pantheios::w2m(std::wstring(L"")));
  328. // 3. Verification
  329. pantheios::be::test::Results results = pantheios::be::test::results();
  330. XTESTS_TEST(!results.empty());
  331. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  332. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  333. }
  334. static void test_3_01()
  335. {
  336. // 1. Setup
  337. pantheios::be::test::reset();
  338. // 2. Create test data
  339. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  340. // 3. Verification
  341. pantheios::be::test::Results results = pantheios::be::test::results();
  342. XTESTS_TEST(!results.empty());
  343. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  344. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  345. }
  346. static void test_3_02()
  347. {
  348. // 1. Setup
  349. pantheios::be::test::reset();
  350. // 2. Create test data
  351. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"a")));
  352. // 3. Verification
  353. pantheios::be::test::Results results = pantheios::be::test::results();
  354. XTESTS_TEST(!results.empty());
  355. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  356. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("a", results[0].statement);
  357. }
  358. static void test_3_03()
  359. {
  360. // 1. Setup
  361. pantheios::be::test::reset();
  362. // 2. Create test data
  363. pantheios::log_NOTICE("[", pantheios::w2m(stlsoft::simple_wstring(L"abc")), "]");
  364. // 3. Verification
  365. pantheios::be::test::Results results = pantheios::be::test::results();
  366. XTESTS_TEST(!results.empty());
  367. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  368. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("[abc]", results[0].statement);
  369. }
  370. static void test_3_04()
  371. {
  372. // 1. Setup
  373. pantheios::be::test::reset();
  374. // 2. Create test data
  375. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  376. // 3. Verification
  377. pantheios::be::test::Results results = pantheios::be::test::results();
  378. XTESTS_TEST(!results.empty());
  379. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  380. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  381. }
  382. static void test_3_05()
  383. {
  384. // 1. Setup
  385. pantheios::be::test::reset();
  386. // 2. Create test data
  387. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  388. // 3. Verification
  389. pantheios::be::test::Results results = pantheios::be::test::results();
  390. XTESTS_TEST(!results.empty());
  391. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  392. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  393. }
  394. static void test_3_06()
  395. {
  396. // 1. Setup
  397. pantheios::be::test::reset();
  398. // 2. Create test data
  399. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  400. // 3. Verification
  401. pantheios::be::test::Results results = pantheios::be::test::results();
  402. XTESTS_TEST(!results.empty());
  403. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  404. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  405. }
  406. static void test_3_07()
  407. {
  408. // 1. Setup
  409. pantheios::be::test::reset();
  410. // 2. Create test data
  411. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  412. // 3. Verification
  413. pantheios::be::test::Results results = pantheios::be::test::results();
  414. XTESTS_TEST(!results.empty());
  415. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  416. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  417. }
  418. static void test_3_08()
  419. {
  420. // 1. Setup
  421. pantheios::be::test::reset();
  422. // 2. Create test data
  423. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  424. // 3. Verification
  425. pantheios::be::test::Results results = pantheios::be::test::results();
  426. XTESTS_TEST(!results.empty());
  427. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  428. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  429. }
  430. static void test_3_09()
  431. {
  432. // 1. Setup
  433. pantheios::be::test::reset();
  434. // 2. Create test data
  435. pantheios::log_NOTICE(pantheios::w2m(stlsoft::simple_wstring(L"")));
  436. // 3. Verification
  437. pantheios::be::test::Results results = pantheios::be::test::results();
  438. XTESTS_TEST(!results.empty());
  439. XTESTS_TEST_INTEGER_EQUAL(1u, results.size());
  440. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  441. }
  442. #endif /* !PANTHEIOS_USE_WIDE_STRINGS */
  443. /* ///////////////////////////// end of file //////////////////////////// */