Failure.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. ///////////////////////////////////////////////////////////////////////////////
  9. //
  10. // FAILURE.H
  11. //
  12. // Failure is a class which holds information pertaining to a specific
  13. // test failure. The stream insertion operator is overloaded to allow easy
  14. // display.
  15. //
  16. ///////////////////////////////////////////////////////////////////////////////
  17. #pragma once
  18. #include <string>
  19. class Failure
  20. {
  21. public:
  22. Failure (const std::string& theTestName,
  23. const std::string& theFileName,
  24. long theLineNumber,
  25. const std::string& theCondition)
  26. : message (theCondition),
  27. testName (theTestName),
  28. fileName (theFileName),
  29. lineNumber (theLineNumber)
  30. {
  31. }
  32. Failure (const std::string& theTestName,
  33. const std::string& theFileName,
  34. const std::string& theCondition)
  35. : message (theCondition),
  36. testName (theTestName),
  37. fileName (theFileName),
  38. lineNumber (-1)
  39. {
  40. }
  41. Failure (const std::string& theTestName,
  42. const std::string& theFileName,
  43. long theLineNumber,
  44. const std::string& expected,
  45. const std::string& actual)
  46. : message("expected " + expected + " but was: " + actual),
  47. testName (theTestName),
  48. fileName (theFileName),
  49. lineNumber (theLineNumber)
  50. {
  51. }
  52. std::string message;
  53. std::string testName;
  54. std::string fileName;
  55. long lineNumber;
  56. };