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.

94 lines
2.0KB

  1. // ---
  2. //
  3. // $Id: source.cpp,v 1.4 2005/06/08 09:25:09 nilu Exp $
  4. //
  5. // CppTest - A C++ Unit Testing Framework
  6. // Copyright (c) 2003 Niklas Lundell
  7. //
  8. // ---
  9. //
  10. // This library is free software; you can redistribute it and/or
  11. // modify it under the terms of the GNU Lesser General Public
  12. // License as published by the Free Software Foundation; either
  13. // version 2 of the License, or (at your option) any later version.
  14. //
  15. // This library is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. // Lesser General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU Lesser General Public
  21. // License along with this library; if not, write to the
  22. // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. // Boston, MA 02111-1307, USA.
  24. //
  25. // ---
  26. #include "cpptest-source.h"
  27. using namespace std;
  28. namespace Test
  29. {
  30. /// Constructs an invalid source object, which filename and message are
  31. /// empty strings and the line equals zero.
  32. ///
  33. Source::Source()
  34. : _line(0)
  35. {}
  36. /// Constructs a source object.
  37. ///
  38. /// \param file Name of the file containing the failing function.
  39. /// \param line Line where the function starts.
  40. /// \param msg Expression (or message) that caused the failure.
  41. ///
  42. Source::Source(const char* file, unsigned int line, const char* msg)
  43. : _line(line),
  44. _file(file ? file : ""),
  45. _msg(msg ? msg : "")
  46. {}
  47. /// \return Name of the file containing the failing function.
  48. ///
  49. const string&
  50. Source::file() const
  51. {
  52. return _file;
  53. }
  54. /// \return Line where the function starts.
  55. ///
  56. unsigned int
  57. Source::line() const
  58. {
  59. return _line;
  60. }
  61. /// \return Descriptive message.
  62. ///
  63. const string&
  64. Source::message() const
  65. {
  66. return _msg;
  67. }
  68. /// \return Name of the suite, which the test belongs to.
  69. ///
  70. const string&
  71. Source::suite() const
  72. {
  73. return _suite;
  74. }
  75. /// \return Name of failing test.
  76. ///
  77. const string&
  78. Source::test() const
  79. {
  80. return _test;
  81. }
  82. } // namespace Test