TestResult.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. #include "TestResult.h"
  9. #include "Failure.h"
  10. #include <stdio.h>
  11. TestResult::TestResult ()
  12. : failureCount (0)
  13. {
  14. }
  15. void TestResult::testsStarted ()
  16. {
  17. }
  18. void TestResult::addFailure (const Failure& failure)
  19. {
  20. if (failure.lineNumber < 0) // allow for no line number
  21. fprintf (stdout, "%s%s%s%s\n",
  22. "Failure: \"",
  23. failure.message.c_str (),
  24. "\" in ",
  25. failure.fileName.c_str ());
  26. else
  27. fprintf (stdout, "%s%s%ld%s%s%s\n",
  28. failure.fileName.c_str(), // Format matches Eclipse error flagging
  29. ":",
  30. failure.lineNumber,
  31. ": Failure: \"",
  32. failure.message.c_str(),
  33. "\" ");
  34. failureCount++;
  35. }
  36. void TestResult::testsEnded ()
  37. {
  38. if (failureCount > 0)
  39. fprintf (stdout, "There were %d failures\n", failureCount);
  40. else
  41. fprintf (stdout, "There were no test failures\n");
  42. }