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.

3041 lines
102 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.bec.file/test.unit.bec.file.cpp
  3. *
  4. * Purpose: Implementation file for the test.unit.be.file project.
  5. *
  6. * Created: 19th January 2008
  7. * Updated: 14th November 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. /* Pantheios Header Files */
  21. #include <pantheios/backends/bec.file.h>
  22. #include <pantheios/init_codes.h>
  23. #include <pantheios/util/system/threadid.h>
  24. /* STLSoft Header Files */
  25. #include <stlsoft/conversion/char_conversions.hpp>
  26. #include <stlsoft/conversion/integer_to_string.hpp>
  27. #include <platformstl/filesystem/file_lines.hpp>
  28. #include <platformstl/filesystem/filesystem_traits.hpp>
  29. /* xTests Header Files */
  30. #include <xtests/xtests.h>
  31. /* Standard C++ Header Files */
  32. #include <exception> // for std::exception
  33. #include <new> // for std::bad_alloc
  34. /* Standard C Header Files */
  35. #include <stdio.h> // for fprintf(), remove()
  36. #include <stdlib.h> // for exit codes
  37. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  38. /* /////////////////////////////////////////////////////////////////////////
  39. * Macros
  40. */
  41. #define PANTHEIOS_SEV_LEVELS_EQUAL(x, y) XTESTS_TEST_INTEGER_EQUAL(static_cast<int>(x), static_cast<int>(y))
  42. /* /////////////////////////////////////////////////////////////////////////
  43. * Typedefs
  44. */
  45. typedef platformstl::filesystem_traits<PAN_CHAR_T> fs_traits_t;
  46. typedef platformstl::basic_file_lines<char> lines_m_t;
  47. typedef platformstl::basic_file_lines<wchar_t> lines_w_t;
  48. typedef platformstl::basic_file_lines<PAN_CHAR_T> lines_t;
  49. typedef std::basic_string<char> string_m_t;
  50. typedef std::basic_string<wchar_t> string_w_t;
  51. typedef std::basic_string<PAN_CHAR_T> string_t;
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Character encoding
  54. */
  55. #ifdef PANTHEIOS_USE_WIDE_STRINGS
  56. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_WIDE_STRING_EQUAL
  57. # define P_TO_M_(x) static_cast<char const*>(stlsoft::w2m((x)))
  58. # define P_TO_W_(x) (x)
  59. # define gettidstr_() gettidstr_w_()
  60. #else /* ? PANTHEIOS_USE_WIDE_STRINGS */
  61. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_MULTIBYTE_STRING_EQUAL
  62. # define P_TO_M_(x) (x)
  63. # define P_TO_W_(x) static_cast<wchar_t const*>(stlsoft::m2w((x)))
  64. # define gettidstr_() gettidstr_m_()
  65. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  66. #ifdef PSTR
  67. # undef PSTR
  68. #endif
  69. #define PSTR PANTHEIOS_LITERAL_STRING
  70. /* /////////////////////////////////////////////////////////////////////////
  71. * Globals
  72. */
  73. PANTHEIOS_EXTERN_C const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.be.file");
  74. /* /////////////////////////////////////////////////////////////////////////
  75. * Forward declarations
  76. */
  77. namespace
  78. {
  79. static void test_1_00();
  80. static void test_1_01();
  81. static void test_1_02();
  82. static void test_1_03();
  83. static void test_1_04();
  84. static void test_1_05();
  85. static void test_1_06();
  86. static void test_1_07();
  87. static void test_1_08();
  88. static void test_1_09();
  89. static void test_1_0a();
  90. static void test_1_0b();
  91. static void test_1_0c();
  92. static void test_1_0d();
  93. static void test_1_0e();
  94. static void test_1_0f();
  95. static void test_2_00();
  96. static void test_2_01();
  97. static void test_2_02();
  98. static void test_2_03();
  99. static void test_2_04();
  100. static void test_2_05();
  101. static void test_2_06();
  102. static void test_2_07();
  103. static void test_2_08();
  104. static void test_2_09();
  105. static void test_2_0a();
  106. static void test_2_0b();
  107. static void test_2_0c();
  108. static void test_2_0d();
  109. static void test_2_0e();
  110. static void test_2_0f();
  111. static void test_3_00();
  112. static void test_3_01();
  113. static void test_3_02();
  114. static void test_3_03();
  115. static void test_3_04();
  116. static void test_3_05();
  117. static void test_3_06();
  118. static void test_3_07();
  119. static void test_3_08();
  120. static void test_3_09();
  121. static void test_3_0a();
  122. static void test_3_0b();
  123. static void test_3_0c();
  124. static void test_3_0d();
  125. static void test_3_0e();
  126. static void test_3_0f();
  127. static void test_4_00();
  128. static void test_4_01();
  129. } // anonymous namespace
  130. /* ////////////////////////////////////////////////////////////////////// */
  131. int main(int argc, char** argv)
  132. {
  133. int retCode = EXIT_SUCCESS;
  134. int verbosity = 2;
  135. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  136. if(XTESTS_START_RUNNER("test.unit.be.file", verbosity))
  137. {
  138. XTESTS_RUN_CASE(test_1_00);
  139. XTESTS_RUN_CASE(test_1_01);
  140. XTESTS_RUN_CASE(test_1_02);
  141. XTESTS_RUN_CASE(test_1_03);
  142. XTESTS_RUN_CASE(test_1_04);
  143. XTESTS_RUN_CASE(test_1_05);
  144. XTESTS_RUN_CASE(test_1_06);
  145. XTESTS_RUN_CASE(test_1_07);
  146. XTESTS_RUN_CASE(test_1_08);
  147. XTESTS_RUN_CASE(test_1_09);
  148. XTESTS_RUN_CASE(test_1_0a);
  149. XTESTS_RUN_CASE(test_1_0b);
  150. XTESTS_RUN_CASE(test_1_0c);
  151. XTESTS_RUN_CASE(test_1_0d);
  152. XTESTS_RUN_CASE(test_1_0e);
  153. XTESTS_RUN_CASE(test_1_0f);
  154. XTESTS_RUN_CASE(test_2_00);
  155. XTESTS_RUN_CASE(test_2_01);
  156. XTESTS_RUN_CASE(test_2_02);
  157. XTESTS_RUN_CASE(test_2_03);
  158. XTESTS_RUN_CASE(test_2_04);
  159. XTESTS_RUN_CASE(test_2_05);
  160. XTESTS_RUN_CASE(test_2_06);
  161. XTESTS_RUN_CASE(test_2_07);
  162. XTESTS_RUN_CASE(test_2_08);
  163. XTESTS_RUN_CASE(test_2_09);
  164. XTESTS_RUN_CASE(test_2_0a);
  165. XTESTS_RUN_CASE(test_2_0b);
  166. XTESTS_RUN_CASE(test_2_0c);
  167. XTESTS_RUN_CASE(test_2_0d);
  168. XTESTS_RUN_CASE(test_2_0e);
  169. XTESTS_RUN_CASE(test_2_0f);
  170. XTESTS_RUN_CASE(test_3_00);
  171. XTESTS_RUN_CASE(test_3_01);
  172. XTESTS_RUN_CASE(test_3_02);
  173. XTESTS_RUN_CASE(test_3_03);
  174. XTESTS_RUN_CASE(test_3_04);
  175. XTESTS_RUN_CASE(test_3_05);
  176. XTESTS_RUN_CASE(test_3_06);
  177. XTESTS_RUN_CASE(test_3_07);
  178. XTESTS_RUN_CASE(test_3_08);
  179. XTESTS_RUN_CASE(test_3_09);
  180. XTESTS_RUN_CASE(test_3_0a);
  181. XTESTS_RUN_CASE(test_3_0b);
  182. XTESTS_RUN_CASE(test_3_0c);
  183. XTESTS_RUN_CASE(test_3_0d);
  184. XTESTS_RUN_CASE(test_3_0e);
  185. XTESTS_RUN_CASE(test_3_0f);
  186. XTESTS_RUN_CASE(test_4_00);
  187. XTESTS_RUN_CASE(test_4_01);
  188. XTESTS_PRINT_RESULTS();
  189. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  190. }
  191. return retCode;
  192. }
  193. /* ////////////////////////////////////////////////////////////////////// */
  194. namespace
  195. {
  196. static string_m_t gettidstr_m_()
  197. {
  198. char num[21];
  199. size_t n;// = 0; STLSOFT_SUPPRESS_UNUSED(n); // Suppress Borland C/C++ warning (which is correct)
  200. char const* p = stlsoft::integer_to_string(&num[0], STLSOFT_NUM_ELEMENTS(num), pantheios::util::getCurrentThreadId(), n);
  201. return string_m_t(p, n);
  202. }
  203. static string_w_t gettidstr_w_()
  204. {
  205. wchar_t num[21];
  206. size_t n;// = 0; STLSOFT_SUPPRESS_UNUSED(n); // Suppress Borland C/C++ warning (which is correct)
  207. wchar_t const* p = stlsoft::integer_to_string(&num[0], STLSOFT_NUM_ELEMENTS(num), pantheios::util::getCurrentThreadId(), n);
  208. return string_w_t(p, n);
  209. }
  210. static PAN_CHAR_T const* strings[] =
  211. {
  212. PSTR("abc")
  213. , PSTR("ABC")
  214. , PSTR("abcdefghijklmnopqrstuvwxyz")
  215. , PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  216. , PSTR("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
  217. , PSTR("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
  218. , PSTR("00000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222223333333333333333333333333")
  219. };
  220. static void test_1_00()
  221. {
  222. pan_be_file_init_t init;
  223. pantheios_be_file_getDefaultAppInit(&init);
  224. init.flags |= 0
  225. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  226. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  227. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  228. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  229. | 0
  230. | PANTHEIOS_BE_FILE_F_TRUNCATE
  231. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  232. ;
  233. void* token;
  234. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  235. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  236. {
  237. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  238. }
  239. else
  240. {
  241. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  242. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_01.results");
  243. // create the output file
  244. pantheios_be_file_setFilePath(FILE_PATH);
  245. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  246. {
  247. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  248. }}
  249. pantheios_be_file_setFilePath(NULL);
  250. // close the output file
  251. lines_m_t lines(FILE_PATH);
  252. string_m_t const resultPrefix = "";
  253. fs_traits_t::unlink_file(FILE_PATH);
  254. // Start the tests
  255. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  256. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  257. {
  258. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  259. }}
  260. }
  261. }
  262. static void test_1_01()
  263. {
  264. pan_be_file_init_t init;
  265. pantheios_be_file_getDefaultAppInit(&init);
  266. init.flags |= 0
  267. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  268. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  269. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  270. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  271. | 0
  272. | PANTHEIOS_BE_FILE_F_TRUNCATE
  273. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  274. ;
  275. void* token;
  276. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  277. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  278. {
  279. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  280. }
  281. else
  282. {
  283. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  284. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_02.results");
  285. // create the output file
  286. pantheios_be_file_setFilePath(FILE_PATH);
  287. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  288. {
  289. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  290. }}
  291. pantheios_be_file_setFilePath(NULL);
  292. // close the output file
  293. lines_m_t lines(FILE_PATH);
  294. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "]: ";
  295. fs_traits_t::unlink_file(FILE_PATH);
  296. // Start the tests
  297. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  298. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  299. {
  300. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  301. }}
  302. }
  303. }
  304. static void test_1_02()
  305. {
  306. pan_be_file_init_t init;
  307. pantheios_be_file_getDefaultAppInit(&init);
  308. init.flags |= 0
  309. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  310. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  311. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  312. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  313. | 0
  314. | PANTHEIOS_BE_FILE_F_TRUNCATE
  315. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  316. ;
  317. void* token;
  318. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  319. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  320. {
  321. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  322. }
  323. else
  324. {
  325. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  326. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_01.results");
  327. // create the output file
  328. pantheios_be_file_setFilePath(FILE_PATH);
  329. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  330. {
  331. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  332. }}
  333. pantheios_be_file_setFilePath(NULL);
  334. // close the output file
  335. lines_m_t lines(FILE_PATH);
  336. string_m_t const resultPrefix = "[" + gettidstr_m_() + "]: ";
  337. fs_traits_t::unlink_file(FILE_PATH);
  338. // Start the tests
  339. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  340. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  341. {
  342. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  343. }}
  344. }
  345. }
  346. static void test_1_03()
  347. {
  348. pan_be_file_init_t init;
  349. pantheios_be_file_getDefaultAppInit(&init);
  350. init.flags |= 0
  351. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  352. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  353. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  354. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  355. | 0
  356. | PANTHEIOS_BE_FILE_F_TRUNCATE
  357. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  358. ;
  359. void* token;
  360. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  361. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  362. {
  363. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  364. }
  365. else
  366. {
  367. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  368. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_02.results");
  369. // create the output file
  370. pantheios_be_file_setFilePath(FILE_PATH);
  371. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  372. {
  373. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  374. }}
  375. pantheios_be_file_setFilePath(NULL);
  376. // close the output file
  377. lines_m_t lines(FILE_PATH);
  378. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "]: ";
  379. fs_traits_t::unlink_file(FILE_PATH);
  380. // Start the tests
  381. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  382. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  383. {
  384. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  385. }}
  386. }
  387. }
  388. static void test_1_04()
  389. {
  390. pan_be_file_init_t init;
  391. pantheios_be_file_getDefaultAppInit(&init);
  392. init.flags |= 0
  393. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  394. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  395. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  396. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  397. | 0
  398. | PANTHEIOS_BE_FILE_F_TRUNCATE
  399. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  400. ;
  401. void* token;
  402. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  403. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  404. {
  405. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  406. }
  407. else
  408. {
  409. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  410. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_02.results");
  411. // create the output file
  412. pantheios_be_file_setFilePath(FILE_PATH);
  413. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  414. {
  415. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  416. }}
  417. pantheios_be_file_setFilePath(NULL);
  418. // close the output file
  419. lines_m_t lines(FILE_PATH);
  420. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "]: ";
  421. fs_traits_t::unlink_file(FILE_PATH);
  422. // Start the tests
  423. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  424. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  425. {
  426. #if 0
  427. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  428. #endif /* 0 */
  429. }}
  430. }
  431. }
  432. static void test_1_05()
  433. {
  434. pan_be_file_init_t init;
  435. pantheios_be_file_getDefaultAppInit(&init);
  436. init.flags |= 0
  437. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  438. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  439. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  440. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  441. | 0
  442. | PANTHEIOS_BE_FILE_F_TRUNCATE
  443. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  444. ;
  445. void* token;
  446. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  447. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  448. {
  449. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  450. }
  451. else
  452. {
  453. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  454. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_03.results");
  455. // create the output file
  456. pantheios_be_file_setFilePath(FILE_PATH);
  457. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  458. {
  459. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  460. }}
  461. pantheios_be_file_setFilePath(NULL);
  462. // close the output file
  463. lines_m_t lines(FILE_PATH);
  464. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  465. fs_traits_t::unlink_file(FILE_PATH);
  466. // Start the tests
  467. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  468. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  469. {
  470. #if 0
  471. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  472. #endif /* 0 */
  473. }}
  474. }
  475. }
  476. static void test_1_06()
  477. {
  478. pan_be_file_init_t init;
  479. pantheios_be_file_getDefaultAppInit(&init);
  480. init.flags |= 0
  481. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  482. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  483. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  484. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  485. | 0
  486. | PANTHEIOS_BE_FILE_F_TRUNCATE
  487. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  488. ;
  489. void* token;
  490. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  491. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  492. {
  493. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  494. }
  495. else
  496. {
  497. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  498. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_03.results");
  499. // create the output file
  500. pantheios_be_file_setFilePath(FILE_PATH);
  501. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  502. {
  503. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  504. }}
  505. pantheios_be_file_setFilePath(NULL);
  506. // close the output file
  507. lines_m_t lines(FILE_PATH);
  508. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  509. fs_traits_t::unlink_file(FILE_PATH);
  510. // Start the tests
  511. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  512. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  513. {
  514. #if 0
  515. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  516. #endif /* 0 */
  517. }}
  518. }
  519. }
  520. static void test_1_07()
  521. {
  522. pan_be_file_init_t init;
  523. pantheios_be_file_getDefaultAppInit(&init);
  524. init.flags |= 0
  525. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  526. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  527. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  528. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  529. | 0
  530. | PANTHEIOS_BE_FILE_F_TRUNCATE
  531. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  532. ;
  533. void* token;
  534. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  535. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  536. {
  537. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  538. }
  539. else
  540. {
  541. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  542. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_03.results");
  543. // create the output file
  544. pantheios_be_file_setFilePath(FILE_PATH);
  545. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  546. {
  547. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  548. }}
  549. pantheios_be_file_setFilePath(NULL);
  550. // close the output file
  551. lines_m_t lines(FILE_PATH);
  552. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  553. fs_traits_t::unlink_file(FILE_PATH);
  554. // Start the tests
  555. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  556. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  557. {
  558. #if 0
  559. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  560. #endif /* 0 */
  561. }}
  562. }
  563. }
  564. static void test_1_08()
  565. {
  566. pan_be_file_init_t init;
  567. pantheios_be_file_getDefaultAppInit(&init);
  568. init.flags |= 0
  569. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  570. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  571. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  572. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  573. | 0
  574. | PANTHEIOS_BE_FILE_F_TRUNCATE
  575. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  576. ;
  577. void* token;
  578. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  579. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  580. {
  581. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  582. }
  583. else
  584. {
  585. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  586. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  587. // create the output file
  588. pantheios_be_file_setFilePath(FILE_PATH);
  589. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  590. {
  591. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  592. }}
  593. pantheios_be_file_setFilePath(NULL);
  594. // close the output file
  595. lines_m_t lines(FILE_PATH);
  596. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  597. fs_traits_t::unlink_file(FILE_PATH);
  598. // Start the tests
  599. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  600. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  601. {
  602. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  603. }}
  604. }
  605. }
  606. static void test_1_09()
  607. {
  608. pan_be_file_init_t init;
  609. pantheios_be_file_getDefaultAppInit(&init);
  610. init.flags |= 0
  611. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  612. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  613. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  614. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  615. | 0
  616. | PANTHEIOS_BE_FILE_F_TRUNCATE
  617. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  618. ;
  619. void* token;
  620. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  621. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  622. {
  623. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  624. }
  625. else
  626. {
  627. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  628. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_03.results");
  629. // create the output file
  630. pantheios_be_file_setFilePath(FILE_PATH);
  631. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  632. {
  633. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  634. }}
  635. pantheios_be_file_setFilePath(NULL);
  636. // close the output file
  637. lines_m_t lines(FILE_PATH);
  638. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  639. fs_traits_t::unlink_file(FILE_PATH);
  640. // Start the tests
  641. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  642. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  643. {
  644. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  645. }}
  646. }
  647. }
  648. static void test_1_0a()
  649. {
  650. pan_be_file_init_t init;
  651. pantheios_be_file_getDefaultAppInit(&init);
  652. init.flags |= 0
  653. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  654. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  655. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  656. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  657. | 0
  658. | PANTHEIOS_BE_FILE_F_TRUNCATE
  659. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  660. ;
  661. void* token;
  662. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  663. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  664. {
  665. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  666. }
  667. else
  668. {
  669. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  670. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  671. // create the output file
  672. pantheios_be_file_setFilePath(FILE_PATH);
  673. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  674. {
  675. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  676. }}
  677. pantheios_be_file_setFilePath(NULL);
  678. // close the output file
  679. lines_m_t lines(FILE_PATH);
  680. string_m_t const resultPrefix = "[" + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  681. fs_traits_t::unlink_file(FILE_PATH);
  682. // Start the tests
  683. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  684. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  685. {
  686. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  687. }}
  688. }
  689. }
  690. static void test_1_0b()
  691. {
  692. pan_be_file_init_t init;
  693. pantheios_be_file_getDefaultAppInit(&init);
  694. init.flags |= 0
  695. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  696. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  697. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  698. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  699. | 0
  700. | PANTHEIOS_BE_FILE_F_TRUNCATE
  701. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  702. ;
  703. void* token;
  704. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  705. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  706. {
  707. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  708. }
  709. else
  710. {
  711. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  712. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  713. // create the output file
  714. pantheios_be_file_setFilePath(FILE_PATH);
  715. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  716. {
  717. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  718. }}
  719. pantheios_be_file_setFilePath(NULL);
  720. // close the output file
  721. lines_m_t lines(FILE_PATH);
  722. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  723. fs_traits_t::unlink_file(FILE_PATH);
  724. // Start the tests
  725. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  726. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  727. {
  728. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  729. }}
  730. }
  731. }
  732. static void test_1_0c()
  733. {
  734. pan_be_file_init_t init;
  735. pantheios_be_file_getDefaultAppInit(&init);
  736. init.flags |= 0
  737. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  738. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  739. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  740. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  741. | 0
  742. | PANTHEIOS_BE_FILE_F_TRUNCATE
  743. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  744. ;
  745. void* token;
  746. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  747. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  748. {
  749. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  750. }
  751. else
  752. {
  753. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  754. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  755. // create the output file
  756. pantheios_be_file_setFilePath(FILE_PATH);
  757. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  758. {
  759. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  760. }}
  761. pantheios_be_file_setFilePath(NULL);
  762. // close the output file
  763. lines_m_t lines(FILE_PATH);
  764. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  765. fs_traits_t::unlink_file(FILE_PATH);
  766. // Start the tests
  767. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  768. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  769. {
  770. #if 0
  771. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  772. #endif /* 0 */
  773. }}
  774. }
  775. }
  776. static void test_1_0d()
  777. {
  778. pan_be_file_init_t init;
  779. pantheios_be_file_getDefaultAppInit(&init);
  780. init.flags |= 0
  781. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  782. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  783. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  784. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  785. | 0
  786. | PANTHEIOS_BE_FILE_F_TRUNCATE
  787. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  788. ;
  789. void* token;
  790. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  791. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  792. {
  793. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  794. }
  795. else
  796. {
  797. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  798. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  799. // create the output file
  800. pantheios_be_file_setFilePath(FILE_PATH);
  801. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  802. {
  803. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  804. }}
  805. pantheios_be_file_setFilePath(NULL);
  806. // close the output file
  807. lines_m_t lines(FILE_PATH);
  808. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  809. fs_traits_t::unlink_file(FILE_PATH);
  810. // Start the tests
  811. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  812. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  813. {
  814. #if 0
  815. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  816. #endif /* 0 */
  817. }}
  818. }
  819. }
  820. static void test_1_0e()
  821. {
  822. pan_be_file_init_t init;
  823. pantheios_be_file_getDefaultAppInit(&init);
  824. init.flags |= 0
  825. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  826. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  827. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  828. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  829. | 0
  830. | PANTHEIOS_BE_FILE_F_TRUNCATE
  831. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  832. ;
  833. void* token;
  834. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  835. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  836. {
  837. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  838. }
  839. else
  840. {
  841. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  842. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  843. // create the output file
  844. pantheios_be_file_setFilePath(FILE_PATH);
  845. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  846. {
  847. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  848. }}
  849. pantheios_be_file_setFilePath(NULL);
  850. // close the output file
  851. lines_m_t lines(FILE_PATH);
  852. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  853. fs_traits_t::unlink_file(FILE_PATH);
  854. // Start the tests
  855. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  856. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  857. {
  858. #if 0
  859. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  860. #endif /* 0 */
  861. }}
  862. }
  863. }
  864. static void test_1_0f()
  865. {
  866. pan_be_file_init_t init;
  867. pantheios_be_file_getDefaultAppInit(&init);
  868. init.flags |= 0
  869. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  870. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  871. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  872. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  873. | 0
  874. | PANTHEIOS_BE_FILE_F_TRUNCATE
  875. | PANTHEIOS_BE_FILE_F_WRITE_MULTIBYTE_CONTENTS
  876. ;
  877. void* token;
  878. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  879. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  880. {
  881. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  882. }
  883. else
  884. {
  885. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  886. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_1_04.results");
  887. // create the output file
  888. pantheios_be_file_setFilePath(FILE_PATH);
  889. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  890. {
  891. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  892. }}
  893. pantheios_be_file_setFilePath(NULL);
  894. // close the output file
  895. lines_m_t lines(FILE_PATH);
  896. string_m_t const resultPrefix = "[" + string_m_t(P_TO_M_(PANTHEIOS_FE_PROCESS_IDENTITY)) + "." + gettidstr_m_() + "; " + string_m_t(P_TO_M_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + "]: ";
  897. fs_traits_t::unlink_file(FILE_PATH);
  898. // Start the tests
  899. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  900. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  901. {
  902. #if 0
  903. XTESTS_TEST_MULTIBYTE_STRING_EQUAL((resultPrefix + P_TO_M_(strings[i])), lines[i]);
  904. #endif /* 0 */
  905. }}
  906. }
  907. }
  908. static void test_2_00()
  909. {
  910. pan_be_file_init_t init;
  911. pantheios_be_file_getDefaultAppInit(&init);
  912. init.flags |= 0
  913. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  914. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  915. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  916. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  917. | 0
  918. | PANTHEIOS_BE_FILE_F_TRUNCATE
  919. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  920. ;
  921. void* token;
  922. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  923. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  924. {
  925. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  926. }
  927. else
  928. {
  929. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  930. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_01.results");
  931. // create the output file
  932. pantheios_be_file_setFilePath(FILE_PATH);
  933. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  934. {
  935. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  936. }}
  937. pantheios_be_file_setFilePath(NULL);
  938. // close the output file
  939. lines_w_t lines(FILE_PATH);
  940. string_w_t const resultPrefix = L"";
  941. fs_traits_t::unlink_file(FILE_PATH);
  942. // Start the tests
  943. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  944. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  945. {
  946. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  947. }}
  948. }
  949. }
  950. static void test_2_01()
  951. {
  952. pan_be_file_init_t init;
  953. pantheios_be_file_getDefaultAppInit(&init);
  954. init.flags |= 0
  955. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  956. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  957. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  958. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  959. | 0
  960. | PANTHEIOS_BE_FILE_F_TRUNCATE
  961. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  962. ;
  963. void* token;
  964. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  965. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  966. {
  967. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  968. }
  969. else
  970. {
  971. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  972. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_02.results");
  973. // create the output file
  974. pantheios_be_file_setFilePath(FILE_PATH);
  975. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  976. {
  977. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  978. }}
  979. pantheios_be_file_setFilePath(NULL);
  980. // close the output file
  981. lines_w_t lines(FILE_PATH);
  982. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"]: ";
  983. fs_traits_t::unlink_file(FILE_PATH);
  984. // Start the tests
  985. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  986. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  987. {
  988. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  989. }}
  990. }
  991. }
  992. static void test_2_02()
  993. {
  994. pan_be_file_init_t init;
  995. pantheios_be_file_getDefaultAppInit(&init);
  996. init.flags |= 0
  997. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  998. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  999. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1000. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1001. | 0
  1002. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1003. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1004. ;
  1005. void* token;
  1006. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1007. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1008. {
  1009. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1010. }
  1011. else
  1012. {
  1013. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1014. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_01.results");
  1015. // create the output file
  1016. pantheios_be_file_setFilePath(FILE_PATH);
  1017. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1018. {
  1019. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1020. }}
  1021. pantheios_be_file_setFilePath(NULL);
  1022. // close the output file
  1023. lines_w_t lines(FILE_PATH);
  1024. string_w_t const resultPrefix = L"[" + gettidstr_w_() + L"]: ";
  1025. fs_traits_t::unlink_file(FILE_PATH);
  1026. // Start the tests
  1027. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1028. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1029. {
  1030. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1031. }}
  1032. }
  1033. }
  1034. static void test_2_03()
  1035. {
  1036. pan_be_file_init_t init;
  1037. pantheios_be_file_getDefaultAppInit(&init);
  1038. init.flags |= 0
  1039. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1040. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1041. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1042. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1043. | 0
  1044. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1045. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1046. ;
  1047. void* token;
  1048. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1049. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1050. {
  1051. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1052. }
  1053. else
  1054. {
  1055. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1056. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_02.results");
  1057. // create the output file
  1058. pantheios_be_file_setFilePath(FILE_PATH);
  1059. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1060. {
  1061. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1062. }}
  1063. pantheios_be_file_setFilePath(NULL);
  1064. // close the output file
  1065. lines_w_t lines(FILE_PATH);
  1066. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"]: ";
  1067. fs_traits_t::unlink_file(FILE_PATH);
  1068. // Start the tests
  1069. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1070. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1071. {
  1072. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1073. }}
  1074. }
  1075. }
  1076. static void test_2_04()
  1077. {
  1078. pan_be_file_init_t init;
  1079. pantheios_be_file_getDefaultAppInit(&init);
  1080. init.flags |= 0
  1081. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1082. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1083. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1084. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1085. | 0
  1086. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1087. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1088. ;
  1089. void* token;
  1090. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1091. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1092. {
  1093. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1094. }
  1095. else
  1096. {
  1097. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1098. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_02.results");
  1099. // create the output file
  1100. pantheios_be_file_setFilePath(FILE_PATH);
  1101. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1102. {
  1103. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1104. }}
  1105. pantheios_be_file_setFilePath(NULL);
  1106. // close the output file
  1107. lines_w_t lines(FILE_PATH);
  1108. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"]: ";
  1109. fs_traits_t::unlink_file(FILE_PATH);
  1110. // Start the tests
  1111. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1112. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1113. {
  1114. #if 0
  1115. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1116. #endif /* 0 */
  1117. }}
  1118. }
  1119. }
  1120. static void test_2_05()
  1121. {
  1122. pan_be_file_init_t init;
  1123. pantheios_be_file_getDefaultAppInit(&init);
  1124. init.flags |= 0
  1125. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1126. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1127. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1128. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1129. | 0
  1130. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1131. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1132. ;
  1133. void* token;
  1134. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1135. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1136. {
  1137. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1138. }
  1139. else
  1140. {
  1141. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1142. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_03.results");
  1143. // create the output file
  1144. pantheios_be_file_setFilePath(FILE_PATH);
  1145. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1146. {
  1147. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1148. }}
  1149. pantheios_be_file_setFilePath(NULL);
  1150. // close the output file
  1151. lines_w_t lines(FILE_PATH);
  1152. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1153. fs_traits_t::unlink_file(FILE_PATH);
  1154. // Start the tests
  1155. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1156. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1157. {
  1158. #if 0
  1159. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1160. #endif /* 0 */
  1161. }}
  1162. }
  1163. }
  1164. static void test_2_06()
  1165. {
  1166. pan_be_file_init_t init;
  1167. pantheios_be_file_getDefaultAppInit(&init);
  1168. init.flags |= 0
  1169. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1170. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1171. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1172. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1173. | 0
  1174. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1175. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1176. ;
  1177. void* token;
  1178. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1179. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1180. {
  1181. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1182. }
  1183. else
  1184. {
  1185. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1186. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_03.results");
  1187. // create the output file
  1188. pantheios_be_file_setFilePath(FILE_PATH);
  1189. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1190. {
  1191. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1192. }}
  1193. pantheios_be_file_setFilePath(NULL);
  1194. // close the output file
  1195. lines_w_t lines(FILE_PATH);
  1196. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1197. fs_traits_t::unlink_file(FILE_PATH);
  1198. // Start the tests
  1199. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1200. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1201. {
  1202. #if 0
  1203. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1204. #endif /* 0 */
  1205. }}
  1206. }
  1207. }
  1208. static void test_2_07()
  1209. {
  1210. pan_be_file_init_t init;
  1211. pantheios_be_file_getDefaultAppInit(&init);
  1212. init.flags |= 0
  1213. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1214. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1215. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1216. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1217. | 0
  1218. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1219. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1220. ;
  1221. void* token;
  1222. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1223. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1224. {
  1225. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1226. }
  1227. else
  1228. {
  1229. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1230. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_03.results");
  1231. // create the output file
  1232. pantheios_be_file_setFilePath(FILE_PATH);
  1233. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1234. {
  1235. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1236. }}
  1237. pantheios_be_file_setFilePath(NULL);
  1238. // close the output file
  1239. lines_w_t lines(FILE_PATH);
  1240. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1241. fs_traits_t::unlink_file(FILE_PATH);
  1242. // Start the tests
  1243. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1244. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1245. {
  1246. #if 0
  1247. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1248. #endif /* 0 */
  1249. }}
  1250. }
  1251. }
  1252. static void test_2_08()
  1253. {
  1254. pan_be_file_init_t init;
  1255. pantheios_be_file_getDefaultAppInit(&init);
  1256. init.flags |= 0
  1257. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1258. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1259. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1260. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1261. | 0
  1262. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1263. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1264. ;
  1265. void* token;
  1266. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1267. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1268. {
  1269. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1270. }
  1271. else
  1272. {
  1273. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1274. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1275. // create the output file
  1276. pantheios_be_file_setFilePath(FILE_PATH);
  1277. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1278. {
  1279. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1280. }}
  1281. pantheios_be_file_setFilePath(NULL);
  1282. // close the output file
  1283. lines_w_t lines(FILE_PATH);
  1284. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1285. fs_traits_t::unlink_file(FILE_PATH);
  1286. // Start the tests
  1287. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1288. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1289. {
  1290. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1291. }}
  1292. }
  1293. }
  1294. static void test_2_09()
  1295. {
  1296. pan_be_file_init_t init;
  1297. pantheios_be_file_getDefaultAppInit(&init);
  1298. init.flags |= 0
  1299. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1300. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1301. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1302. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1303. | 0
  1304. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1305. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1306. ;
  1307. void* token;
  1308. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1309. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1310. {
  1311. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1312. }
  1313. else
  1314. {
  1315. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1316. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_03.results");
  1317. // create the output file
  1318. pantheios_be_file_setFilePath(FILE_PATH);
  1319. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1320. {
  1321. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1322. }}
  1323. pantheios_be_file_setFilePath(NULL);
  1324. // close the output file
  1325. lines_w_t lines(FILE_PATH);
  1326. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1327. fs_traits_t::unlink_file(FILE_PATH);
  1328. // Start the tests
  1329. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1330. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1331. {
  1332. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1333. }}
  1334. }
  1335. }
  1336. static void test_2_0a()
  1337. {
  1338. pan_be_file_init_t init;
  1339. pantheios_be_file_getDefaultAppInit(&init);
  1340. init.flags |= 0
  1341. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1342. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1343. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1344. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1345. | 0
  1346. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1347. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1348. ;
  1349. void* token;
  1350. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1351. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1352. {
  1353. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1354. }
  1355. else
  1356. {
  1357. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1358. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1359. // create the output file
  1360. pantheios_be_file_setFilePath(FILE_PATH);
  1361. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1362. {
  1363. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1364. }}
  1365. pantheios_be_file_setFilePath(NULL);
  1366. // close the output file
  1367. lines_w_t lines(FILE_PATH);
  1368. string_w_t const resultPrefix = L"[" + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1369. fs_traits_t::unlink_file(FILE_PATH);
  1370. // Start the tests
  1371. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1372. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1373. {
  1374. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1375. }}
  1376. }
  1377. }
  1378. static void test_2_0b()
  1379. {
  1380. pan_be_file_init_t init;
  1381. pantheios_be_file_getDefaultAppInit(&init);
  1382. init.flags |= 0
  1383. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1384. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1385. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1386. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1387. | 0
  1388. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1389. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1390. ;
  1391. void* token;
  1392. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1393. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1394. {
  1395. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1396. }
  1397. else
  1398. {
  1399. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1400. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1401. // create the output file
  1402. pantheios_be_file_setFilePath(FILE_PATH);
  1403. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1404. {
  1405. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1406. }}
  1407. pantheios_be_file_setFilePath(NULL);
  1408. // close the output file
  1409. lines_w_t lines(FILE_PATH);
  1410. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1411. fs_traits_t::unlink_file(FILE_PATH);
  1412. // Start the tests
  1413. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1414. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1415. {
  1416. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1417. }}
  1418. }
  1419. }
  1420. static void test_2_0c()
  1421. {
  1422. pan_be_file_init_t init;
  1423. pantheios_be_file_getDefaultAppInit(&init);
  1424. init.flags |= 0
  1425. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1426. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1427. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1428. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1429. | 0
  1430. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1431. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1432. ;
  1433. void* token;
  1434. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1435. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1436. {
  1437. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1438. }
  1439. else
  1440. {
  1441. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1442. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1443. // create the output file
  1444. pantheios_be_file_setFilePath(FILE_PATH);
  1445. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1446. {
  1447. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1448. }}
  1449. pantheios_be_file_setFilePath(NULL);
  1450. // close the output file
  1451. lines_w_t lines(FILE_PATH);
  1452. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1453. fs_traits_t::unlink_file(FILE_PATH);
  1454. // Start the tests
  1455. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1456. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1457. {
  1458. #if 0
  1459. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1460. #endif /* 0 */
  1461. }}
  1462. }
  1463. }
  1464. static void test_2_0d()
  1465. {
  1466. pan_be_file_init_t init;
  1467. pantheios_be_file_getDefaultAppInit(&init);
  1468. init.flags |= 0
  1469. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1470. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1471. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1472. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1473. | 0
  1474. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1475. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1476. ;
  1477. void* token;
  1478. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1479. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1480. {
  1481. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1482. }
  1483. else
  1484. {
  1485. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1486. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1487. // create the output file
  1488. pantheios_be_file_setFilePath(FILE_PATH);
  1489. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1490. {
  1491. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1492. }}
  1493. pantheios_be_file_setFilePath(NULL);
  1494. // close the output file
  1495. lines_w_t lines(FILE_PATH);
  1496. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1497. fs_traits_t::unlink_file(FILE_PATH);
  1498. // Start the tests
  1499. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1500. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1501. {
  1502. #if 0
  1503. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1504. #endif /* 0 */
  1505. }}
  1506. }
  1507. }
  1508. static void test_2_0e()
  1509. {
  1510. pan_be_file_init_t init;
  1511. pantheios_be_file_getDefaultAppInit(&init);
  1512. init.flags |= 0
  1513. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1514. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1515. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1516. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1517. | 0
  1518. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1519. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1520. ;
  1521. void* token;
  1522. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1523. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1524. {
  1525. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1526. }
  1527. else
  1528. {
  1529. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1530. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1531. // create the output file
  1532. pantheios_be_file_setFilePath(FILE_PATH);
  1533. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1534. {
  1535. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1536. }}
  1537. pantheios_be_file_setFilePath(NULL);
  1538. // close the output file
  1539. lines_w_t lines(FILE_PATH);
  1540. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1541. fs_traits_t::unlink_file(FILE_PATH);
  1542. // Start the tests
  1543. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1544. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1545. {
  1546. #if 0
  1547. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1548. #endif /* 0 */
  1549. }}
  1550. }
  1551. }
  1552. static void test_2_0f()
  1553. {
  1554. pan_be_file_init_t init;
  1555. pantheios_be_file_getDefaultAppInit(&init);
  1556. init.flags |= 0
  1557. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1558. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1559. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1560. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1561. | 0
  1562. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1563. | PANTHEIOS_BE_FILE_F_WRITE_WIDE_CONTENTS
  1564. ;
  1565. void* token;
  1566. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1567. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1568. {
  1569. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1570. }
  1571. else
  1572. {
  1573. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1574. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_2_04.results");
  1575. // create the output file
  1576. pantheios_be_file_setFilePath(FILE_PATH);
  1577. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1578. {
  1579. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1580. }}
  1581. pantheios_be_file_setFilePath(NULL);
  1582. // close the output file
  1583. lines_w_t lines(FILE_PATH);
  1584. string_w_t const resultPrefix = L"[" + string_w_t(P_TO_W_(PANTHEIOS_FE_PROCESS_IDENTITY)) + L"." + gettidstr_w_() + L"; " + string_w_t(P_TO_W_(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY))) + L"]: ";
  1585. fs_traits_t::unlink_file(FILE_PATH);
  1586. // Start the tests
  1587. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1588. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1589. {
  1590. #if 0
  1591. XTESTS_TEST_WIDE_STRING_EQUAL((resultPrefix + P_TO_W_(strings[i])), lines[i]);
  1592. #endif /* 0 */
  1593. }}
  1594. }
  1595. }
  1596. static void test_3_00()
  1597. {
  1598. pan_be_file_init_t init;
  1599. pantheios_be_file_getDefaultAppInit(&init);
  1600. init.flags |= 0
  1601. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1602. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1603. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1604. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1605. | 0
  1606. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1607. ;
  1608. void* token;
  1609. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1610. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1611. {
  1612. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1613. }
  1614. else
  1615. {
  1616. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1617. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_01.results");
  1618. // create the output file
  1619. pantheios_be_file_setFilePath(FILE_PATH);
  1620. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1621. {
  1622. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1623. }}
  1624. pantheios_be_file_setFilePath(NULL);
  1625. // close the output file
  1626. lines_t lines(FILE_PATH);
  1627. string_t const resultPrefix = PSTR("");
  1628. fs_traits_t::unlink_file(FILE_PATH);
  1629. // Start the tests
  1630. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1631. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1632. {
  1633. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1634. }}
  1635. }
  1636. }
  1637. static void test_3_01()
  1638. {
  1639. pan_be_file_init_t init;
  1640. pantheios_be_file_getDefaultAppInit(&init);
  1641. init.flags |= 0
  1642. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1643. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1644. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1645. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1646. | 0
  1647. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1648. ;
  1649. void* token;
  1650. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1651. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1652. {
  1653. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1654. }
  1655. else
  1656. {
  1657. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1658. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_02.results");
  1659. // create the output file
  1660. pantheios_be_file_setFilePath(FILE_PATH);
  1661. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1662. {
  1663. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1664. }}
  1665. pantheios_be_file_setFilePath(NULL);
  1666. // close the output file
  1667. lines_t lines(FILE_PATH);
  1668. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR("]: ");
  1669. fs_traits_t::unlink_file(FILE_PATH);
  1670. // Start the tests
  1671. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1672. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1673. {
  1674. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1675. }}
  1676. }
  1677. }
  1678. static void test_3_02()
  1679. {
  1680. pan_be_file_init_t init;
  1681. pantheios_be_file_getDefaultAppInit(&init);
  1682. init.flags |= 0
  1683. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1684. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1685. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1686. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1687. | 0
  1688. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1689. ;
  1690. void* token;
  1691. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1692. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1693. {
  1694. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1695. }
  1696. else
  1697. {
  1698. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1699. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_01.results");
  1700. // create the output file
  1701. pantheios_be_file_setFilePath(FILE_PATH);
  1702. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1703. {
  1704. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1705. }}
  1706. pantheios_be_file_setFilePath(NULL);
  1707. // close the output file
  1708. lines_t lines(FILE_PATH);
  1709. string_t const resultPrefix = PSTR("[") + gettidstr_() + PSTR("]: ");
  1710. fs_traits_t::unlink_file(FILE_PATH);
  1711. // Start the tests
  1712. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1713. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1714. {
  1715. XTESTS_TEST_STRING_EQUAL(resultPrefix + strings[i], lines[i]);
  1716. }}
  1717. }
  1718. }
  1719. static void test_3_03()
  1720. {
  1721. pan_be_file_init_t init;
  1722. pantheios_be_file_getDefaultAppInit(&init);
  1723. init.flags |= 0
  1724. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1725. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1726. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1727. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1728. | 0
  1729. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1730. ;
  1731. void* token;
  1732. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1733. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1734. {
  1735. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1736. }
  1737. else
  1738. {
  1739. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1740. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_02.results");
  1741. // create the output file
  1742. pantheios_be_file_setFilePath(FILE_PATH);
  1743. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1744. {
  1745. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1746. }}
  1747. pantheios_be_file_setFilePath(NULL);
  1748. // close the output file
  1749. lines_t lines(FILE_PATH);
  1750. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("]: ");
  1751. fs_traits_t::unlink_file(FILE_PATH);
  1752. // Start the tests
  1753. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1754. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1755. {
  1756. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1757. }}
  1758. }
  1759. }
  1760. static void test_3_04()
  1761. {
  1762. pan_be_file_init_t init;
  1763. pantheios_be_file_getDefaultAppInit(&init);
  1764. init.flags |= 0
  1765. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1766. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1767. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1768. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1769. | 0
  1770. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1771. ;
  1772. void* token;
  1773. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1774. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1775. {
  1776. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1777. }
  1778. else
  1779. {
  1780. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1781. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_02.results");
  1782. // create the output file
  1783. pantheios_be_file_setFilePath(FILE_PATH);
  1784. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1785. {
  1786. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1787. }}
  1788. pantheios_be_file_setFilePath(NULL);
  1789. // close the output file
  1790. lines_t lines(FILE_PATH);
  1791. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("]: ");
  1792. fs_traits_t::unlink_file(FILE_PATH);
  1793. // Start the tests
  1794. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1795. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1796. {
  1797. #if 0
  1798. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1799. #endif /* 0 */
  1800. }}
  1801. }
  1802. }
  1803. static void test_3_05()
  1804. {
  1805. pan_be_file_init_t init;
  1806. pantheios_be_file_getDefaultAppInit(&init);
  1807. init.flags |= 0
  1808. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1809. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1810. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1811. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1812. | 0
  1813. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1814. ;
  1815. void* token;
  1816. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1817. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1818. {
  1819. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1820. }
  1821. else
  1822. {
  1823. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1824. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_03.results");
  1825. // create the output file
  1826. pantheios_be_file_setFilePath(FILE_PATH);
  1827. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1828. {
  1829. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1830. }}
  1831. pantheios_be_file_setFilePath(NULL);
  1832. // close the output file
  1833. lines_t lines(FILE_PATH);
  1834. string_t const resultPrefix = PSTR("[") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  1835. fs_traits_t::unlink_file(FILE_PATH);
  1836. // Start the tests
  1837. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1838. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1839. {
  1840. #if 0
  1841. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1842. #endif /* 0 */
  1843. }}
  1844. }
  1845. }
  1846. static void test_3_06()
  1847. {
  1848. pan_be_file_init_t init;
  1849. pantheios_be_file_getDefaultAppInit(&init);
  1850. init.flags |= 0
  1851. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1852. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1853. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1854. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1855. | 0
  1856. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1857. ;
  1858. void* token;
  1859. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1860. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1861. {
  1862. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1863. }
  1864. else
  1865. {
  1866. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1867. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_03.results");
  1868. // create the output file
  1869. pantheios_be_file_setFilePath(FILE_PATH);
  1870. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1871. {
  1872. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1873. }}
  1874. pantheios_be_file_setFilePath(NULL);
  1875. // close the output file
  1876. lines_t lines(FILE_PATH);
  1877. string_t const resultPrefix = PSTR("[") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  1878. fs_traits_t::unlink_file(FILE_PATH);
  1879. // Start the tests
  1880. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1881. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1882. {
  1883. #if 0
  1884. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1885. #endif /* 0 */
  1886. }}
  1887. }
  1888. }
  1889. static void test_3_07()
  1890. {
  1891. pan_be_file_init_t init;
  1892. pantheios_be_file_getDefaultAppInit(&init);
  1893. init.flags |= 0
  1894. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1895. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1896. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1897. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1898. | 0
  1899. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1900. ;
  1901. void* token;
  1902. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1903. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1904. {
  1905. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1906. }
  1907. else
  1908. {
  1909. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1910. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_03.results");
  1911. // create the output file
  1912. pantheios_be_file_setFilePath(FILE_PATH);
  1913. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1914. {
  1915. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1916. }}
  1917. pantheios_be_file_setFilePath(NULL);
  1918. // close the output file
  1919. lines_t lines(FILE_PATH);
  1920. string_t const resultPrefix = PSTR("[") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  1921. fs_traits_t::unlink_file(FILE_PATH);
  1922. // Start the tests
  1923. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1924. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1925. {
  1926. #if 0
  1927. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1928. #endif /* 0 */
  1929. }}
  1930. }
  1931. }
  1932. static void test_3_08()
  1933. {
  1934. pan_be_file_init_t init;
  1935. pantheios_be_file_getDefaultAppInit(&init);
  1936. init.flags |= 0
  1937. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1938. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1939. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1940. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1941. | 0
  1942. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1943. ;
  1944. void* token;
  1945. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1946. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1947. {
  1948. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1949. }
  1950. else
  1951. {
  1952. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1953. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_04.results");
  1954. // create the output file
  1955. pantheios_be_file_setFilePath(FILE_PATH);
  1956. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1957. {
  1958. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  1959. }}
  1960. pantheios_be_file_setFilePath(NULL);
  1961. // close the output file
  1962. lines_t lines(FILE_PATH);
  1963. string_t const resultPrefix = PSTR("[") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  1964. fs_traits_t::unlink_file(FILE_PATH);
  1965. // Start the tests
  1966. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  1967. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1968. {
  1969. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  1970. }}
  1971. }
  1972. }
  1973. static void test_3_09()
  1974. {
  1975. pan_be_file_init_t init;
  1976. pantheios_be_file_getDefaultAppInit(&init);
  1977. init.flags |= 0
  1978. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  1979. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  1980. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  1981. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  1982. | 0
  1983. | PANTHEIOS_BE_FILE_F_TRUNCATE
  1984. ;
  1985. void* token;
  1986. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  1987. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  1988. {
  1989. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  1990. }
  1991. else
  1992. {
  1993. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  1994. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_03.results");
  1995. // create the output file
  1996. pantheios_be_file_setFilePath(FILE_PATH);
  1997. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  1998. {
  1999. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2000. }}
  2001. pantheios_be_file_setFilePath(NULL);
  2002. // close the output file
  2003. lines_t lines(FILE_PATH);
  2004. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2005. fs_traits_t::unlink_file(FILE_PATH);
  2006. // Start the tests
  2007. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2008. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2009. {
  2010. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2011. }}
  2012. }
  2013. }
  2014. static void test_3_0a()
  2015. {
  2016. pan_be_file_init_t init;
  2017. pantheios_be_file_getDefaultAppInit(&init);
  2018. init.flags |= 0
  2019. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2020. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2021. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2022. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2023. | 0
  2024. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2025. ;
  2026. void* token;
  2027. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2028. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2029. {
  2030. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2031. }
  2032. else
  2033. {
  2034. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2035. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0a.results");
  2036. // create the output file
  2037. pantheios_be_file_setFilePath(FILE_PATH);
  2038. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2039. {
  2040. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2041. }}
  2042. pantheios_be_file_setFilePath(NULL);
  2043. // close the output file
  2044. lines_t lines(FILE_PATH);
  2045. string_t const resultPrefix = PSTR("[") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2046. fs_traits_t::unlink_file(FILE_PATH);
  2047. // Start the tests
  2048. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2049. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2050. {
  2051. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2052. }}
  2053. }
  2054. }
  2055. static void test_3_0b()
  2056. {
  2057. pan_be_file_init_t init;
  2058. pantheios_be_file_getDefaultAppInit(&init);
  2059. init.flags |= 0
  2060. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2061. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2062. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2063. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2064. | 0
  2065. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2066. ;
  2067. void* token;
  2068. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2069. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2070. {
  2071. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2072. }
  2073. else
  2074. {
  2075. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2076. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0b.results");
  2077. // create the output file
  2078. pantheios_be_file_setFilePath(FILE_PATH);
  2079. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2080. {
  2081. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2082. }}
  2083. pantheios_be_file_setFilePath(NULL);
  2084. // close the output file
  2085. lines_t lines(FILE_PATH);
  2086. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2087. fs_traits_t::unlink_file(FILE_PATH);
  2088. // Start the tests
  2089. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2090. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2091. {
  2092. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2093. }}
  2094. }
  2095. }
  2096. static void test_3_0c()
  2097. {
  2098. pan_be_file_init_t init;
  2099. pantheios_be_file_getDefaultAppInit(&init);
  2100. init.flags |= 0
  2101. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2102. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2103. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2104. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2105. | 0
  2106. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2107. ;
  2108. void* token;
  2109. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2110. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2111. {
  2112. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2113. }
  2114. else
  2115. {
  2116. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2117. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0c.results");
  2118. // create the output file
  2119. pantheios_be_file_setFilePath(FILE_PATH);
  2120. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2121. {
  2122. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2123. }}
  2124. pantheios_be_file_setFilePath(NULL);
  2125. // close the output file
  2126. lines_t lines(FILE_PATH);
  2127. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2128. fs_traits_t::unlink_file(FILE_PATH);
  2129. // Start the tests
  2130. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2131. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2132. {
  2133. #if 0
  2134. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2135. #endif /* 0 */
  2136. }}
  2137. }
  2138. }
  2139. static void test_3_0d()
  2140. {
  2141. pan_be_file_init_t init;
  2142. pantheios_be_file_getDefaultAppInit(&init);
  2143. init.flags |= 0
  2144. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2145. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2146. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2147. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2148. | 0
  2149. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2150. ;
  2151. void* token;
  2152. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2153. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2154. {
  2155. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2156. }
  2157. else
  2158. {
  2159. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2160. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0d.results");
  2161. // create the output file
  2162. pantheios_be_file_setFilePath(FILE_PATH);
  2163. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2164. {
  2165. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2166. }}
  2167. pantheios_be_file_setFilePath(NULL);
  2168. // close the output file
  2169. lines_t lines(FILE_PATH);
  2170. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2171. fs_traits_t::unlink_file(FILE_PATH);
  2172. // Start the tests
  2173. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2174. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2175. {
  2176. #if 0
  2177. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2178. #endif /* 0 */
  2179. }}
  2180. }
  2181. }
  2182. static void test_3_0e()
  2183. {
  2184. pan_be_file_init_t init;
  2185. pantheios_be_file_getDefaultAppInit(&init);
  2186. init.flags |= 0
  2187. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2188. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2189. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2190. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2191. | 0
  2192. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2193. ;
  2194. void* token;
  2195. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2196. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2197. {
  2198. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2199. }
  2200. else
  2201. {
  2202. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2203. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0e.results");
  2204. // create the output file
  2205. pantheios_be_file_setFilePath(FILE_PATH);
  2206. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2207. {
  2208. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2209. }}
  2210. pantheios_be_file_setFilePath(NULL);
  2211. // close the output file
  2212. lines_t lines(FILE_PATH);
  2213. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2214. fs_traits_t::unlink_file(FILE_PATH);
  2215. // Start the tests
  2216. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2217. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2218. {
  2219. #if 0
  2220. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2221. #endif /* 0 */
  2222. }}
  2223. }
  2224. }
  2225. static void test_3_0f()
  2226. {
  2227. pan_be_file_init_t init;
  2228. pantheios_be_file_getDefaultAppInit(&init);
  2229. init.flags |= 0
  2230. // | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2231. // | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2232. // | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2233. // | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2234. | 0
  2235. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2236. ;
  2237. void* token;
  2238. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2239. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2240. {
  2241. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2242. }
  2243. else
  2244. {
  2245. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2246. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_3_0f.results");
  2247. // create the output file
  2248. pantheios_be_file_setFilePath(FILE_PATH);
  2249. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2250. {
  2251. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, strings[i], stlsoft::c_str_len(strings[i]));
  2252. }}
  2253. pantheios_be_file_setFilePath(NULL);
  2254. // close the output file
  2255. lines_t lines(FILE_PATH);
  2256. string_t const resultPrefix = PSTR("[") + string_t(PANTHEIOS_FE_PROCESS_IDENTITY) + PSTR(".") + gettidstr_() + PSTR("; ") + string_t(pantheios::getSeverityString(PANTHEIOS_SEV_EMERGENCY)) + PSTR("]: ");
  2257. fs_traits_t::unlink_file(FILE_PATH);
  2258. // Start the tests
  2259. XTESTS_REQUIRE(XTESTS_TEST_INTEGER_EQUAL(STLSOFT_NUM_ELEMENTS(strings), lines.size()));
  2260. { for(size_t i = 0; i != STLSOFT_NUM_ELEMENTS(strings); ++i)
  2261. {
  2262. #if 0
  2263. XTESTS_TEST_STRING_EQUAL((resultPrefix + strings[i]), lines[i]);
  2264. #endif /* 0 */
  2265. }}
  2266. }
  2267. }
  2268. static void test_4_00()
  2269. {
  2270. pan_be_file_init_t init;
  2271. pantheios_be_file_getDefaultAppInit(&init);
  2272. init.flags |= 0
  2273. | 0
  2274. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2275. | PANTHEIOS_BE_FILE_F_DELETE_IF_EMPTY
  2276. ;
  2277. void* token;
  2278. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2279. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2280. {
  2281. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2282. }
  2283. else
  2284. {
  2285. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2286. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_4_00.results");
  2287. { // (i) Writing something (none-0 length)
  2288. pantheios_be_file_setFilePath(FILE_PATH);
  2289. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2290. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("abc"), 3u);
  2291. pantheios_be_file_setFilePath(NULL);
  2292. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2293. }
  2294. { // (i) Writing something (0 length)
  2295. pantheios_be_file_setFilePath(FILE_PATH);
  2296. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2297. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("abc"), 0u);
  2298. pantheios_be_file_setFilePath(NULL);
  2299. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2300. }
  2301. { // (i) Writing nothing
  2302. pantheios_be_file_setFilePath(FILE_PATH);
  2303. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2304. pantheios_be_file_setFilePath(NULL);
  2305. XTESTS_TEST_BOOLEAN_FALSE(fs_traits_t::file_exists(FILE_PATH));
  2306. }
  2307. // ... do it anyway ...
  2308. fs_traits_t::unlink_file(FILE_PATH);
  2309. }
  2310. }
  2311. static void test_4_01()
  2312. {
  2313. pan_be_file_init_t init;
  2314. pantheios_be_file_getDefaultAppInit(&init);
  2315. init.flags |= 0
  2316. | PANTHEIOS_BE_INIT_F_NO_PROCESS_ID
  2317. | PANTHEIOS_BE_INIT_F_NO_THREAD_ID
  2318. | PANTHEIOS_BE_INIT_F_NO_DATETIME
  2319. | PANTHEIOS_BE_INIT_F_NO_SEVERITY
  2320. | 0
  2321. | PANTHEIOS_BE_FILE_F_TRUNCATE
  2322. | PANTHEIOS_BE_FILE_F_DELETE_IF_EMPTY
  2323. ;
  2324. void* token;
  2325. int res = pantheios_be_file_init(PANTHEIOS_FE_PROCESS_IDENTITY, PANTHEIOS_BEID_ALL, &init, NULL, &token);
  2326. if(PANTHEIOS_INIT_RC_SUCCESS != res)
  2327. {
  2328. XTESTS_FAIL_WITH_QUALIFIER("failed to initialise bec.file", pantheios::getInitErrorString(res));
  2329. }
  2330. else
  2331. {
  2332. stlsoft::scoped_handle<void*> uninit_(token, pantheios_be_file_uninit);
  2333. static const PAN_CHAR_T FILE_PATH[] = PANTHEIOS_LITERAL_STRING("test_4_00.results");
  2334. { // (i) Writing something (none-0 length)
  2335. pantheios_be_file_setFilePath(FILE_PATH);
  2336. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2337. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("abc"), 3u);
  2338. pantheios_be_file_setFilePath(NULL);
  2339. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2340. }
  2341. { // (i) Writing something (0 length)
  2342. pantheios_be_file_setFilePath(FILE_PATH);
  2343. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2344. pantheios_be_file_logEntry(NULL, token, PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("abc"), 0u);
  2345. pantheios_be_file_setFilePath(NULL);
  2346. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2347. }
  2348. { // (i) Writing nothing
  2349. pantheios_be_file_setFilePath(FILE_PATH);
  2350. XTESTS_TEST_BOOLEAN_TRUE(fs_traits_t::file_exists(FILE_PATH));
  2351. pantheios_be_file_setFilePath(NULL);
  2352. XTESTS_TEST_BOOLEAN_FALSE(fs_traits_t::file_exists(FILE_PATH));
  2353. }
  2354. // ... do it anyway ...
  2355. fs_traits_t::unlink_file(FILE_PATH);
  2356. }
  2357. }
  2358. } // anonymous namespace
  2359. /* ///////////////////////////// end of file //////////////////////////// */