Source code of Windows XP (NT5)
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.

84 lines
1.9 KiB

  1. #include <pch.h>
  2. #pragma hdrstop
  3. //---[ prototypes ]------------------------------------------------------------
  4. void TestAssert();
  5. void TestSideAssert();
  6. void TestAssertSz();
  7. void TestSideAssertSz();
  8. //+---------------------------------------------------------------------------
  9. //
  10. // Function: main
  11. //
  12. // Purpose: Entrypoint for the unit test. Calls all of the sub-tests
  13. //
  14. // Arguments:
  15. // (none)
  16. //
  17. // Returns:
  18. //
  19. // Author: jeffspr 3 Sep 1997
  20. //
  21. // Notes:
  22. //
  23. void _cdecl main()
  24. {
  25. printf("\n\nUnit test for (netcfg)\\common\\debug ");
  26. #ifdef _DBG
  27. printf("[debug build]\n\n");
  28. #else
  29. printf("[release build]\n\n");
  30. #endif
  31. TestAssert();
  32. TestAssertSz();
  33. TestSideAssert();
  34. TestSideAssertSz();
  35. }
  36. void TestAssert()
  37. {
  38. Assert(TRUE); // This should succeed
  39. Assert(FALSE); // This should fail
  40. }
  41. void TestAssertSz()
  42. {
  43. AssertSz(TRUE, "This should not have asserted");
  44. AssertSz(FALSE, "This assert is expected on debug builds");
  45. }
  46. void TestSideAssert()
  47. {
  48. BOOL fTest = FALSE;
  49. printf("Pre-call value of fTest : %d\n", fTest);
  50. SideAssert(fTest = TRUE); // This should not fire
  51. printf("Post-call-#1 value of fTest: %d (should be TRUE)\n", fTest);
  52. SideAssert(fTest = FALSE); // This should assert on Debug
  53. printf("Post-call-#2 value of fTest: %d (should be FALSE, Asserted in DEBUG builds)\n", fTest);
  54. }
  55. void TestSideAssertSz()
  56. {
  57. BOOL fTest = FALSE;
  58. printf("Pre-call value of fTest : %d\n", fTest);
  59. SideAssertSz(fTest = TRUE, "This assert should not have fired"); // This should not fire
  60. printf("Post-call-#1 value of fTest: %d (should be TRUE)\n", fTest);
  61. SideAssertSz(fTest = FALSE, "This assert should have fired in DEBUG mode only"); // This should assert on Debug
  62. printf("Post-call-#2 value of fTest: %d (should be FALSE, Asserted in DEBUG builds)\n", fTest);
  63. }