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.

173 lines
6.1 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/unit/test.unit.levels.dynamic_initialisation/test.unit.levels.dynamic_initialisation.cpp
  3. *
  4. * Purpose: Implementation file for the test.unit.levels.dynamic_initialisation project.
  5. *
  6. * Created: 20th October 2007
  7. * Updated: 6th August 2012
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * Copyright (c) 2007-2012, Synesis Software Pty Ltd.
  14. * All rights reserved.
  15. *
  16. * www: http://www.synesis.com.au/software
  17. *
  18. * ////////////////////////////////////////////////////////////////////// */
  19. #include <pantheios/util/test/compiler_warnings_suppression.first_include.h>
  20. class DynamicInit
  21. {
  22. public:
  23. DynamicInit();
  24. public:
  25. const int debug;
  26. const int informational;
  27. const int notice;
  28. const int warning;
  29. const int error;
  30. const int critical;
  31. const int alert;
  32. const int emergency;
  33. private:
  34. DynamicInit(DynamicInit const&);
  35. DynamicInit& operator =(DynamicInit const&);
  36. } levels;
  37. #define PANTHEIOS_NO_INCLUDE_COMSTL_STRING_ACCESS
  38. #define PANTHEIOS_NO_INCLUDE_UNIXSTL_STRING_ACCESS
  39. #define PANTHEIOS_NO_INCLUDE_WINSTL_STRING_ACCESS
  40. /* Pantheios Header Files */
  41. #include <pantheios/pantheios.h>
  42. /* xTests Header Files */
  43. #include <xtests/xtests.h>
  44. /* Standard C++ Header Files */
  45. #include <exception> // for std::exception
  46. #include <new> // for std::bad_alloc
  47. /* Standard C Header Files */
  48. #include <stdlib.h> // for exit codes
  49. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  50. /* /////////////////////////////////////////////////////////////////////////
  51. * Macros
  52. */
  53. #define PANTHEIOS_SEV_LEVELS_EQUAL(x, y) XTESTS_TEST_INTEGER_EQUAL(static_cast<int>(x), static_cast<int>(y))
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Globals
  56. */
  57. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.unit.levels.dynamic_initialisation");
  58. /* ////////////////////////////////////////////////////////////////////// */
  59. const int debug = ::pantheios::debug;
  60. const int informational = ::pantheios::informational;
  61. const int notice = ::pantheios::notice;
  62. const int warning = ::pantheios::warning;
  63. const int error = ::pantheios::error;
  64. const int critical = ::pantheios::critical;
  65. const int alert = ::pantheios::alert;
  66. const int emergency = ::pantheios::emergency;
  67. DynamicInit::DynamicInit()
  68. : debug (::pantheios::debug)
  69. , informational (::pantheios::informational)
  70. , notice (::pantheios::notice)
  71. , warning (::pantheios::warning)
  72. , error (::pantheios::error)
  73. , critical (::pantheios::critical)
  74. , alert (::pantheios::alert)
  75. , emergency (::pantheios::emergency)
  76. {}
  77. /* ////////////////////////////////////////////////////////////////////// */
  78. int main(int argc, char** argv)
  79. {
  80. int retCode = EXIT_SUCCESS;
  81. int verbosity = 2;
  82. XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);
  83. if(XTESTS_START_RUNNER("test.unit.levels.dynamic_initialisation", verbosity))
  84. {
  85. /* Case 1 - verifying Pantheios levels instances */
  86. if(!XTESTS_CASE_BEGIN("case-1", "verifying Pantheios levels instances"))
  87. {
  88. retCode = EXIT_FAILURE;
  89. }
  90. else
  91. {
  92. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, ::pantheios::emergency);
  93. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, ::pantheios::alert);
  94. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, ::pantheios::critical);
  95. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, ::pantheios::error);
  96. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, ::pantheios::warning);
  97. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, ::pantheios::notice);
  98. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, ::pantheios::informational);
  99. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, ::pantheios::debug);
  100. XTESTS_CASE_END("");
  101. }
  102. /* Case 2 - verifying non-local constants */
  103. if(!XTESTS_CASE_BEGIN("case-2", "verifying non-local constants"))
  104. {
  105. retCode = EXIT_FAILURE;
  106. }
  107. else
  108. {
  109. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, ::emergency);
  110. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, ::alert);
  111. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, ::critical);
  112. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, ::error);
  113. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, ::warning);
  114. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, ::notice);
  115. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, ::informational);
  116. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, ::debug);
  117. XTESTS_CASE_END("");
  118. }
  119. /* Case 3 - verifying dynamic initialisation levels instances */
  120. if(!XTESTS_CASE_BEGIN("case-3", "verifying dynamic initialisation levels instances"))
  121. {
  122. retCode = EXIT_FAILURE;
  123. }
  124. else
  125. {
  126. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_EMERGENCY, levels.emergency);
  127. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ALERT, levels.alert);
  128. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_CRITICAL, levels.critical);
  129. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_ERROR, levels.error);
  130. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_WARNING, levels.warning);
  131. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_NOTICE, levels.notice);
  132. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_INFORMATIONAL, levels.informational);
  133. PANTHEIOS_SEV_LEVELS_EQUAL(PANTHEIOS_SEV_DEBUG, levels.debug);
  134. XTESTS_CASE_END("");
  135. }
  136. XTESTS_PRINT_RESULTS();
  137. XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
  138. }
  139. return retCode;
  140. }
  141. /* ///////////////////////////// end of file //////////////////////////// */