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.

168 lines
4.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.fe.simple/test.unit.fe.simple.c
  3. *
  4. * Purpose: Implementation file for the test.unit.fe.simple 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.simple.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.simple");
  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. #ifdef NDEBUG
  60. , 0
  61. , 0
  62. #else /* ? NDEBUG */
  63. , 1
  64. , 1
  65. #endif /* NDEBUG */
  66. };
  67. /* ////////////////////////////////////////////////////////////////////// */
  68. int main(int argc, char** argv)
  69. {
  70. int retCode = EXIT_SUCCESS;
  71. int verbosity = 2;
  72. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  73. STLSOFT_STATIC_ASSERT(STLSOFT_NUM_ELEMENTS(s_severityLevels) == STLSOFT_NUM_ELEMENTS(s_severityLevelResults));
  74. if(XTESTS_START_RUNNER("test.unit.fe.simple", verbosity))
  75. {
  76. /* Test-1 */
  77. if(XTESTS_CASE_BEGIN("Test-1", "Verify that the initialisation succeeds"))
  78. {
  79. void* token;
  80. int res;
  81. res = pantheios_fe_init(NULL, &token);
  82. XTESTS_TEST_INTEGER_EQUAL(PANTHEIOS_INIT_RC_SUCCESS, res);
  83. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  84. {
  85. pantheios_fe_uninit(token);
  86. }
  87. XTESTS_CASE_END("Test-1");
  88. }
  89. /* Test-2 */
  90. if(XTESTS_CASE_BEGIN("Test-2", "Verify the process identity"))
  91. {
  92. void* token;
  93. int res;
  94. res = pantheios_fe_init(NULL, &token);
  95. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  96. {
  97. XTESTS_TEST_STRING_EQUAL(PANTHEIOS_FE_PROCESS_IDENTITY, pantheios_fe_getProcessIdentity(token));
  98. pantheios_fe_uninit(token);
  99. }
  100. XTESTS_CASE_END("Test-2");
  101. }
  102. /* Test-3 */
  103. if(XTESTS_CASE_BEGIN("Test-3", "Verify that simple levels are acceptable"))
  104. {
  105. void* token;
  106. int res;
  107. res = pantheios_fe_init(NULL, &token);
  108. if(PANTHEIOS_INIT_RC_SUCCESS == res)
  109. {
  110. { size_t i; for(i = 0; i != STLSOFT_NUM_ELEMENTS(s_severityLevels); ++i)
  111. {
  112. XTESTS_TEST_INTEGER_EQUAL(s_severityLevelResults[i], pantheios_fe_isSeverityLogged(token, s_severityLevels[i], 0));
  113. }}
  114. pantheios_fe_uninit(token);
  115. }
  116. pantheios_fe_uninit(token);
  117. XTESTS_CASE_END("Test-3");
  118. }
  119. XTESTS_PRINT_RESULTS();
  120. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  121. }
  122. return retCode;
  123. }
  124. /* ///////////////////////////// end of file //////////////////////////// */