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.

199 lines
6.7 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: test/scratch/test.scratch.util.onbailout/test.scratch.util.onbailout.cpp
  3. *
  4. * Purpose: Implementation file for the test.scratch.util.onbailout project.
  5. *
  6. * Created: 21st June 2005
  7. * Updated: 6th August 2012
  8. *
  9. * Status: Wizard-generated
  10. *
  11. * License: (Licensed under the Synesis Software Open License)
  12. *
  13. * www: http://www.synesis.com.au/software
  14. *
  15. * This source code is placed into the public domain 2005
  16. * by Synesis Software Pty Ltd. There are no restrictions
  17. * whatsoever to your use of the software.
  18. *
  19. * This source code is provided by Synesis Software Pty Ltd "as is"
  20. * and any warranties, whether expressed or implied, including, but
  21. * not limited to, the implied warranties of merchantability and
  22. * fitness for a particular purpose are disclaimed. In no event
  23. * shall the Synesis Software Pty Ltd be liable for any direct,
  24. * indirect, incidental, special, exemplary, or consequential
  25. * damages (including, but not limited to, procurement of
  26. * substitute goods or services; loss of use, data, or profits; or
  27. * business interruption) however caused and on any theory of
  28. * liability, whether in contract, strict liability, or tort
  29. * (including negligence or otherwise) arising in any way out of
  30. * the use of this software, even if advised of the possibility of
  31. * such damage.
  32. *
  33. * Neither the name of Synesis Software Pty Ltd nor the names of
  34. * any subdivisions, employees or agents of Synesis Software Pty
  35. * Ltd, nor the names of any other contributors to this software
  36. * may be used to endorse or promote products derived from this
  37. * software without specific prior written permission.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /* This inclusion required for suppressing warnings during NoX (No eXception-support) configurations. */
  41. #include <pantheios/util/test/compiler_warnings_suppression.first_include.h>
  42. /* Pantheios Header Files */
  43. #include <pantheios/pantheios.h>
  44. #include <pantheios/init_codes.h>
  45. /* STLSoft Header Files */
  46. #include <stlsoft/stlsoft.h>
  47. /* Standard C++ Header Files */
  48. #include <exception>
  49. #include <iostream>
  50. #include <string>
  51. using std::cerr;
  52. using std::cin;
  53. using std::cout;
  54. using std::endl;
  55. /* Standard C Header Files */
  56. #include <stdio.h>
  57. #include <pantheios/util/test/compiler_warnings_suppression.last_include.h>
  58. PANTHEIOS_EXTERN_C PAN_CHAR_T const PANTHEIOS_FE_PROCESS_IDENTITY[] = PANTHEIOS_LITERAL_STRING("test.scratch.util.onbailout");
  59. static int main_(int /* argc */, char ** /*argv*/)
  60. {
  61. #if 0
  62. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, "abc");
  63. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, "abc", PANTHEIOS_FE_PROCESS_IDENTITY);
  64. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, "abc", PANTHEIOS_FE_PROCESS_IDENTITY, pantheios::getInitErrorString(PANTHEIOS_INIT_RC_CANNOT_CREATE_TSS_INDEX));
  65. // no longer valid pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, "abc", PANTHEIOS_FE_PROCESS_IDENTITY, (char const*)(pantheios::uint16_t)PANTHEIOS_INIT_RC_CANNOT_CREATE_TSS_INDEX);
  66. {
  67. std::string message(1200, 'm');
  68. std::string qualifier(1200, 'q');
  69. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  70. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  71. }
  72. {
  73. std::string message(2000, 'm');
  74. std::string qualifier(100, 'q');
  75. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  76. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  77. }
  78. {
  79. std::string message(100, 'm');
  80. std::string qualifier(2000, 'q');
  81. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  82. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  83. }
  84. {
  85. std::string message(2500, 'm');
  86. std::string qualifier(1200, 'q');
  87. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  88. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  89. }
  90. {
  91. std::string message(2500, 'm');
  92. std::string qualifier(100, 'q');
  93. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  94. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  95. }
  96. {
  97. std::string message(2500, 'm');
  98. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY);
  99. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, "");
  100. }
  101. #endif /* 0 */
  102. const size_t INCREMENT = 150;
  103. STLSOFT_STATIC_ASSERT(0 == (3000 % INCREMENT));
  104. { for(size_t i = 0; i != 3000; i += INCREMENT)
  105. {
  106. { for(size_t j = 0; j != 3000; j += INCREMENT)
  107. {
  108. if(0 == i)
  109. {
  110. std::string qualifier(j, 'q');
  111. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, NULL, PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  112. }
  113. else if(0 == j)
  114. {
  115. std::string message(i, 'm');
  116. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, "");
  117. }
  118. else
  119. {
  120. std::string message(i, 'm');
  121. std::string qualifier(j, 'q');
  122. pantheios::util::onBailOut(PANTHEIOS_SEV_DEBUG, message.c_str(), PANTHEIOS_FE_PROCESS_IDENTITY, qualifier.c_str());
  123. }
  124. }}
  125. }}
  126. return EXIT_SUCCESS;
  127. }
  128. int main(int argc, char *argv[])
  129. {
  130. #if 0
  131. for(;;) {}
  132. #endif /* 0 */
  133. #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
  134. try
  135. {
  136. #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
  137. return main_(argc, argv);
  138. #ifdef STLSOFT_CF_EXCEPTION_SUPPORT
  139. }
  140. catch(std::exception &x)
  141. {
  142. fprintf(stderr, "Unhandled error: %s\n", x.what());
  143. }
  144. catch(...)
  145. {
  146. pantheios::puts(pantheios::emergency, "Unhandled unknown error");
  147. }
  148. return EXIT_FAILURE;
  149. #endif /* STLSOFT_CF_EXCEPTION_SUPPORT */
  150. }