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.

163 lines
4.2 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.fe.all/test.unit.fe.all.c
  3. *
  4. * Purpose: Implementation file for the test.unit.fe.all project.
  5. *
  6. * Created: 14th May 2008
  7. * Updated: 22nd March 2010
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2008-2010, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. #include <pantheios/frontends/fe.all.h>
  20. #include <pantheios/init_codes.h>
  21. #include <xtests/xtests.h>
  22. #include <stlsoft/stlsoft.h> /* for STLSOFT_NUM_ELEMENTS */
  23. #include <stdio.h> /* for fprintf() */
  24. #include <stdlib.h> /* for EXIT_SUCCESS, EXIT_FAILURE */
  25. /* /////////////////////////////////////////////////////////////////////////
  26. * Character encoding
  27. */
  28. #ifdef PANTHEIOS_USE_WIDE_STRINGS
  29. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_WIDE_STRING_EQUAL
  30. #else /* ? PANTHEIOS_USE_WIDE_STRINGS */
  31. # define XTESTS_TEST_STRING_EQUAL XTESTS_TEST_MULTIBYTE_STRING_EQUAL
  32. #endif /* PANTHEIOS_USE_WIDE_STRINGS */
  33. /* /////////////////////////////////////////////////////////////////////////
  34. * Globals
  35. */
  36. const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.fe.all");
  37. /* /////////////////////////////////////////////////////////////////////////
  38. * Statics and constants
  39. */
  40. static const int s_severityLevels[] =
  41. {
  42. PANTHEIOS_SEV_EMERGENCY
  43. , PANTHEIOS_SEV_ALERT
  44. , PANTHEIOS_SEV_CRITICAL
  45. , PANTHEIOS_SEV_ERROR
  46. , PANTHEIOS_SEV_WARNING
  47. , PANTHEIOS_SEV_NOTICE
  48. , PANTHEIOS_SEV_INFORMATIONAL
  49. , PANTHEIOS_SEV_DEBUG
  50. };
  51. static const int s_severityLevelResults[] =
  52. {
  53. 1
  54. , 1
  55. , 1
  56. , 1
  57. , 1
  58. , 1
  59. , 1
  60. , 1
  61. };
  62. /* ////////////////////////////////////////////////////////////////////// */
  63. int main(int argc, char** argv)
  64. {
  65. int retCode = EXIT_SUCCESS;
  66. int verbosity = 2;
  67. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  68. STLSOFT_STATIC_ASSERT(STLSOFT_NUM_ELEMENTS(s_severityLevels) == STLSOFT_NUM_ELEMENTS(s_severityLevelResults));
  69. if(XTESTS_START_RUNNER("test.unit.fe.all", verbosity))
  70. {
  71. /* Test-1 */
  72. if(XTESTS_CASE_BEGIN("Test-1", "Verify that the initialisation succeeds"))
  73. {
  74. void* token;
  75. int res;
  76. res = pantheios_fe_init(NULL, &token);
  77. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_INIT_RC_SUCCESS, res);
  78. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  79. {
  80. pantheios_fe_uninit(token);
  81. }
  82. XTESTS_CASE_END("Test-1");
  83. }
  84. /* Test-2 */
  85. if(XTESTS_CASE_BEGIN("Test-2", "Verify the process identity"))
  86. {
  87. void* token;
  88. int res;
  89. res = pantheios_fe_init(NULL, &token);
  90. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  91. {
  92. XTESTS_TEST_STRING_EQUAL(PANTHEIOS_FE_PROCESS_IDENTITY, pantheios_fe_getProcessIdentity(token));
  93. pantheios_fe_uninit(token);
  94. }
  95. XTESTS_CASE_END("Test-2");
  96. }
  97. /* Test-3 */
  98. if(XTESTS_CASE_BEGIN("Test-3", "Verify that all levels are acceptable"))
  99. {
  100. void* token;
  101. int res;
  102. res = pantheios_fe_init(NULL, &token);
  103. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  104. {
  105. { size_t i; for(i = 0; i != STLSOFT_NUM_ELEMENTS(s_severityLevels); ++i)
  106. {
  107. XTESTS_TEST_INTEGER_EQUAL(s_severityLevelResults[i], pantheios_fe_isSeverityLogged(token, s_severityLevels[i], 0));
  108. }}
  109. pantheios_fe_uninit(token);
  110. }
  111. pantheios_fe_uninit(token);
  112. XTESTS_CASE_END("Test-3");
  113. }
  114. XTESTS_PRINT_RESULTS();
  115. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  116. }
  117. return retCode;
  118. }
  119. /* ///////////////////////////// end of file //////////////////////////// */