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.

69 lines
1.2 KiB

  1. #include "ExampleTestCase.h"
  2. void ExampleTestCase::example ()
  3. {
  4. assertDoublesEqual (1.0, 1.1, 0.05);
  5. assert (1 == 0);
  6. assert (1 == 1);
  7. }
  8. void ExampleTestCase::anotherExample ()
  9. {
  10. assert (1 == 2);
  11. }
  12. void ExampleTestCase::setUp ()
  13. {
  14. m_value1 = 2.0;
  15. m_value2 = 3.0;
  16. }
  17. void ExampleTestCase::testAdd ()
  18. {
  19. double result = m_value1 + m_value2;
  20. assert (result == 6.0);
  21. }
  22. void ExampleTestCase::testDivideByZero ()
  23. {
  24. int zero = 0;
  25. int result = 8 / zero;
  26. }
  27. void ExampleTestCase::testEquals ()
  28. {
  29. std::auto_ptr<long> l1 (new long (12));
  30. std::auto_ptr<long> l2 (new long (12));
  31. assertLongsEqual (12, 12);
  32. assertLongsEqual (12L, 12L);
  33. assertLongsEqual (*l1, *l2);
  34. assert (12L == 12L);
  35. assertLongsEqual (12, 13);
  36. assertDoublesEqual (12.0, 11.99, 0.5);
  37. }
  38. Test *ExampleTestCase::suite ()
  39. {
  40. TestSuite *testSuite = new TestSuite ("ExampleTestCase");
  41. testSuite->addTest (new TestCaller <ExampleTestCase> ("anotherExample", anotherExample));
  42. testSuite->addTest (new TestCaller <ExampleTestCase> ("testAdd", testAdd));
  43. testSuite->addTest (new TestCaller <ExampleTestCase> ("testDivideByZero", testDivideByZero));
  44. testSuite->addTest (new TestCaller <ExampleTestCase> ("testEquals", testEquals));
  45. return testSuite;
  46. }