testc.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. testc.c
  9. Abstract:
  10. This module implements the C library tests.
  11. Author:
  12. Evan Green 9-Jul-2013
  13. Environment:
  14. Test
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include "testc.h"
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. //
  24. // ---------------------------------------------------------------- Definitions
  25. //
  26. //
  27. // ------------------------------------------------------ Data Type Definitions
  28. //
  29. //
  30. // ----------------------------------------------- Internal Function Prototypes
  31. //
  32. //
  33. // -------------------------------------------------------------------- Globals
  34. //
  35. //
  36. // ------------------------------------------------------------------ Functions
  37. //
  38. INT
  39. main (
  40. INT ArgumentCount,
  41. CHAR **Arguments
  42. )
  43. /*++
  44. Routine Description:
  45. This routine is the entry point for the C librarytest program. It executes
  46. the tests.
  47. Arguments:
  48. ArgumentCount - Supplies the number of arguments specified on the command
  49. line.
  50. Arguments - Supplies an array of strings representing the command line
  51. arguments.
  52. Return Value:
  53. Returns the number of failures that occurred during the test.
  54. --*/
  55. {
  56. ULONG Failures;
  57. ULONG TotalFailures;
  58. TotalFailures = 0;
  59. Failures = TestRegularExpressions();
  60. if (Failures != 0) {
  61. printf("%d regular expression test failures.\n", Failures);
  62. TotalFailures += Failures;
  63. }
  64. Failures = TestQuickSort();
  65. if (Failures != 0) {
  66. printf("%d qsort failures.\n", Failures);
  67. TotalFailures += Failures;
  68. }
  69. Failures += TestBinarySearch();
  70. if (Failures != 0) {
  71. printf("%d binary search failures.\n", Failures);
  72. TotalFailures += Failures;
  73. }
  74. Failures = TestMath();
  75. if (Failures != 0) {
  76. printf("%d math failures.\n", Failures);
  77. TotalFailures += Failures;
  78. }
  79. Failures = TestMathFloat();
  80. if (Failures != 0) {
  81. printf("%d math float failures.\n", Failures);
  82. TotalFailures += Failures;
  83. }
  84. Failures = TestGetopt();
  85. if (Failures != 0) {
  86. printf("%d getopt failures.\n", Failures);
  87. TotalFailures += Failures;
  88. }
  89. if (TotalFailures != 0) {
  90. printf("*** %d C library test failures ***\n", TotalFailures);
  91. } else {
  92. printf("All C library tests passed.\n");
  93. }
  94. return TotalFailures;
  95. }
  96. //
  97. // --------------------------------------------------------- Internal Functions
  98. //
  99. void
  100. _assert (
  101. const char *Expression,
  102. const char *File,
  103. int Line
  104. )
  105. /*++
  106. Routine Description:
  107. This routine implements the underlying assert function that backs the
  108. assert macro.
  109. Arguments:
  110. File - Supplies a pointer to the null terminated string describing the file
  111. the assertion failure occurred in.
  112. Line - Supplies the line number the assertion failure occurred on.
  113. Expression - Supplies a pointer to the string representation of the
  114. source expression that failed.
  115. Return Value:
  116. This routine does not return.
  117. --*/
  118. {
  119. fprintf(stderr, "Assertion failure: %s: %d: %s\n", File, Line, Expression);
  120. abort();
  121. }