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.

565 lines
12 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/component/test.component.inserters.args/test.component.inserters.args.cpp
  3. *
  4. * Purpose: Implementation file for the test.component.inserters.args 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.hpp> // Pantheios C++ main header
  24. #include <pantheios/inserters/args.hpp> // for pantheios::args
  25. #include <pantheios/backends/bec.test.h>
  26. /* Standard C++ Header Files */
  27. #include <exception>
  28. /* Standard C Header Files */
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  32. /* /////////////////////////////////////////////////////////////////////////
  33. * Forward declarations
  34. */
  35. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  36. static void test_1_01();
  37. static void test_1_02();
  38. static void test_1_03();
  39. static void test_1_04();
  40. static void test_1_05();
  41. static void test_1_06();
  42. static void test_1_07();
  43. static void test_1_08();
  44. static void test_1_09();
  45. static void test_1_11();
  46. static void test_1_12();
  47. static void test_1_13();
  48. static void test_1_14();
  49. static void test_1_15();
  50. static void test_1_16();
  51. static void test_1_17();
  52. static void test_1_18();
  53. static void test_1_19();
  54. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Globals
  57. */
  58. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.component.inserters.args");
  59. /* ////////////////////////////////////////////////////////////////////// */
  60. int main(int argc, char** argv)
  61. {
  62. int retCode = EXIT_SUCCESS;
  63. int verbosity = 2;
  64. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  65. if(XTESTS_START_RUNNER("test.component.inserters.args", verbosity))
  66. {
  67. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  68. XTESTS_RUN_CASE(test_1_01);
  69. XTESTS_RUN_CASE(test_1_02);
  70. XTESTS_RUN_CASE(test_1_03);
  71. XTESTS_RUN_CASE(test_1_04);
  72. XTESTS_RUN_CASE(test_1_05);
  73. XTESTS_RUN_CASE(test_1_06);
  74. XTESTS_RUN_CASE(test_1_07);
  75. XTESTS_RUN_CASE(test_1_08);
  76. XTESTS_RUN_CASE(test_1_09);
  77. XTESTS_RUN_CASE(test_1_11);
  78. XTESTS_RUN_CASE(test_1_12);
  79. XTESTS_RUN_CASE(test_1_13);
  80. XTESTS_RUN_CASE(test_1_14);
  81. XTESTS_RUN_CASE(test_1_15);
  82. XTESTS_RUN_CASE(test_1_16);
  83. XTESTS_RUN_CASE(test_1_17);
  84. XTESTS_RUN_CASE(test_1_18);
  85. XTESTS_RUN_CASE(test_1_19);
  86. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  87. XTESTS_PRINT_RESULTS();
  88. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  89. }
  90. return retCode;
  91. }
  92. /* ////////////////////////////////////////////////////////////////////// */
  93. #ifndef PANTHEIOS_USE_WIDE_STRINGS
  94. static void test_1_01()
  95. {
  96. // 1. Setup
  97. pantheios::be::test::reset();
  98. // 2. Create test data
  99. pantheios::log_NOTICE(pantheios::args(0, static_cast<char**>(NULL)));
  100. // 3. Verification
  101. pantheios::be::test::Results results = pantheios::be::test::results();
  102. XTESTS_TEST(!results.empty());
  103. XTESTS_TEST(1 == results.size());
  104. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  105. }
  106. static void test_1_02()
  107. {
  108. // 1. Setup
  109. pantheios::be::test::reset();
  110. // 2. Create test data
  111. char const* argv[] =
  112. {
  113. "abc"
  114. };
  115. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv));
  116. // 3. Verification
  117. pantheios::be::test::Results results = pantheios::be::test::results();
  118. XTESTS_TEST(!results.empty());
  119. XTESTS_TEST(1 == results.size());
  120. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc", results[0].statement);
  121. }
  122. static void test_1_03()
  123. {
  124. // 1. Setup
  125. pantheios::be::test::reset();
  126. // 2. Create test data
  127. char const* argv[] =
  128. {
  129. "abc"
  130. , "def"
  131. };
  132. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv));
  133. // 3. Verification
  134. pantheios::be::test::Results results = pantheios::be::test::results();
  135. XTESTS_TEST(!results.empty());
  136. XTESTS_TEST(1 == results.size());
  137. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc, def", results[0].statement);
  138. }
  139. static void test_1_04()
  140. {
  141. // 1. Setup
  142. pantheios::be::test::reset();
  143. // 2. Create test data
  144. char const* argv[] =
  145. {
  146. "abc"
  147. , "def"
  148. , "ghi"
  149. , "jkl"
  150. };
  151. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv));
  152. // 3. Verification
  153. pantheios::be::test::Results results = pantheios::be::test::results();
  154. XTESTS_TEST(!results.empty());
  155. XTESTS_TEST(1 == results.size());
  156. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc, def, ghi, jkl", results[0].statement);
  157. }
  158. static void test_1_05()
  159. {
  160. // 1. Setup
  161. pantheios::be::test::reset();
  162. // 2. Create test data
  163. char const* argv[] =
  164. {
  165. "abc"
  166. , "def"
  167. , "ghi"
  168. , "jkl"
  169. };
  170. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::alwaysQuoteArgs));
  171. // 3. Verification
  172. pantheios::be::test::Results results = pantheios::be::test::results();
  173. XTESTS_TEST(!results.empty());
  174. XTESTS_TEST(1 == results.size());
  175. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("\"abc\", \"def\", \"ghi\", \"jkl\"", results[0].statement);
  176. }
  177. static void test_1_06()
  178. {
  179. // 1. Setup
  180. pantheios::be::test::reset();
  181. // 2. Create test data
  182. char const* argv[] =
  183. {
  184. "abc"
  185. , "def ghi"
  186. , "jkl"
  187. };
  188. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::neverQuoteArgs));
  189. // 3. Verification
  190. pantheios::be::test::Results results = pantheios::be::test::results();
  191. XTESTS_TEST(!results.empty());
  192. XTESTS_TEST(1 == results.size());
  193. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc, def ghi, jkl", results[0].statement);
  194. }
  195. static void test_1_07()
  196. {
  197. // 1. Setup
  198. pantheios::be::test::reset();
  199. // 2. Create test data
  200. char const* argv[] =
  201. {
  202. "abc"
  203. , "def ghi"
  204. , "jkl"
  205. };
  206. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::quoteArgsWithSpaces));
  207. // 3. Verification
  208. pantheios::be::test::Results results = pantheios::be::test::results();
  209. XTESTS_TEST(!results.empty());
  210. XTESTS_TEST(1 == results.size());
  211. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc, \"def ghi\", jkl", results[0].statement);
  212. }
  213. static void test_1_08()
  214. {
  215. // 1. Setup
  216. pantheios::be::test::reset();
  217. // 2. Create test data
  218. char const* argv[] =
  219. {
  220. "abc"
  221. , "def ghi"
  222. , "jkl"
  223. };
  224. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::alwaysQuoteArgs));
  225. // 3. Verification
  226. pantheios::be::test::Results results = pantheios::be::test::results();
  227. XTESTS_TEST(!results.empty());
  228. XTESTS_TEST(1 == results.size());
  229. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("\"abc\", \"def ghi\", \"jkl\"", results[0].statement);
  230. }
  231. static void test_1_09()
  232. {
  233. }
  234. static void test_1_11()
  235. {
  236. // 1. Setup
  237. pantheios::be::test::reset();
  238. // 2. Create test data
  239. pantheios::log_NOTICE(pantheios::args(0, static_cast<char**>(NULL), pantheios::args::quoteArgsWithSpaces, "|"));
  240. // 3. Verification
  241. pantheios::be::test::Results results = pantheios::be::test::results();
  242. XTESTS_TEST(!results.empty());
  243. XTESTS_TEST(1 == results.size());
  244. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("", results[0].statement);
  245. }
  246. static void test_1_12()
  247. {
  248. // 1. Setup
  249. pantheios::be::test::reset();
  250. // 2. Create test data
  251. char const* argv[] =
  252. {
  253. "abc"
  254. };
  255. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::quoteArgsWithSpaces, "|"));
  256. // 3. Verification
  257. pantheios::be::test::Results results = pantheios::be::test::results();
  258. XTESTS_TEST(!results.empty());
  259. XTESTS_TEST(1 == results.size());
  260. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc", results[0].statement);
  261. }
  262. static void test_1_13()
  263. {
  264. // 1. Setup
  265. pantheios::be::test::reset();
  266. // 2. Create test data
  267. char const* argv[] =
  268. {
  269. "abc"
  270. , "def"
  271. };
  272. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::quoteArgsWithSpaces, "|"));
  273. // 3. Verification
  274. pantheios::be::test::Results results = pantheios::be::test::results();
  275. XTESTS_TEST(!results.empty());
  276. XTESTS_TEST(1 == results.size());
  277. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc|def", results[0].statement);
  278. }
  279. static void test_1_14()
  280. {
  281. // 1. Setup
  282. pantheios::be::test::reset();
  283. // 2. Create test data
  284. char const* argv[] =
  285. {
  286. "abc"
  287. , "def"
  288. , "ghi"
  289. , "jkl"
  290. };
  291. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::quoteArgsWithSpaces, "|"));
  292. // 3. Verification
  293. pantheios::be::test::Results results = pantheios::be::test::results();
  294. XTESTS_TEST(!results.empty());
  295. XTESTS_TEST(1 == results.size());
  296. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc|def|ghi|jkl", results[0].statement);
  297. }
  298. static void test_1_15()
  299. {
  300. // 1. Setup
  301. pantheios::be::test::reset();
  302. // 2. Create test data
  303. char const* argv[] =
  304. {
  305. "abc"
  306. , "def"
  307. , "ghi"
  308. , "jkl"
  309. };
  310. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::alwaysQuoteArgs, "|"));
  311. // 3. Verification
  312. pantheios::be::test::Results results = pantheios::be::test::results();
  313. XTESTS_TEST(!results.empty());
  314. XTESTS_TEST(1 == results.size());
  315. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("\"abc\"|\"def\"|\"ghi\"|\"jkl\"", results[0].statement);
  316. }
  317. static void test_1_16()
  318. {
  319. // 1. Setup
  320. pantheios::be::test::reset();
  321. // 2. Create test data
  322. char const* argv[] =
  323. {
  324. "abc"
  325. , "def ghi"
  326. , "jkl"
  327. };
  328. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::neverQuoteArgs, "|"));
  329. // 3. Verification
  330. pantheios::be::test::Results results = pantheios::be::test::results();
  331. XTESTS_TEST(!results.empty());
  332. XTESTS_TEST(1 == results.size());
  333. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc|def ghi|jkl", results[0].statement);
  334. }
  335. static void test_1_17()
  336. {
  337. // 1. Setup
  338. pantheios::be::test::reset();
  339. // 2. Create test data
  340. char const* argv[] =
  341. {
  342. "abc"
  343. , "def ghi"
  344. , "jkl"
  345. };
  346. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::quoteArgsWithSpaces, "|"));
  347. // 3. Verification
  348. pantheios::be::test::Results results = pantheios::be::test::results();
  349. XTESTS_TEST(!results.empty());
  350. XTESTS_TEST(1 == results.size());
  351. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("abc|\"def ghi\"|jkl", results[0].statement);
  352. }
  353. static void test_1_18()
  354. {
  355. // 1. Setup
  356. pantheios::be::test::reset();
  357. // 2. Create test data
  358. char const* argv[] =
  359. {
  360. "abc"
  361. , "def ghi"
  362. , "jkl"
  363. };
  364. pantheios::log_NOTICE(pantheios::args(STLSOFT_NUM_ELEMENTS(argv), argv, pantheios::args::alwaysQuoteArgs, "|"));
  365. // 3. Verification
  366. pantheios::be::test::Results results = pantheios::be::test::results();
  367. XTESTS_TEST(!results.empty());
  368. XTESTS_TEST(1 == results.size());
  369. XTESTS_TEST_MULTIBYTE_STRING_EQUAL("\"abc\"|\"def ghi\"|\"jkl\"", results[0].statement);
  370. }
  371. static void test_1_19()
  372. {
  373. }
  374. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  375. /* ///////////////////////////// end of file //////////////////////////// */