Fresco/Fresco-Test/syunit-c++/include Breakpoint.hh,1.2,1.3 ResultsMap.hh,1.3,1.4 TestCase.hh,1.3,1.4 TestCaseWrapper.hh,1.3,1.4 TestCmd.hh,1.3,1.4
Nathaniel Smith <[email protected]> Tue, 20 May 2003 04:06:30 -0500
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include
In directory purcel:/tmp/cvs-serv3366/include
Modified Files:
Breakpoint.hh ResultsMap.hh TestCase.hh TestCaseWrapper.hh
TestCmd.hh
Log Message:
Old formatting changes that I forgot to check in.
Index: Breakpoint.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include/Breakpoint.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Breakpoint.hh 19 Feb 2003 20:40:16 -0000 1.2
+++ Breakpoint.hh 20 May 2003 09:06:26 -0000 1.3
@@ -3,9 +3,14 @@
extern "C"
{
- void SyUnit_fail_breakpoint();
- void SyUnit_error_breakpoint();
- void SyUnit_problem_breakpoint(); // called by the other two
+ void
+ SyUnit_fail_breakpoint();
+
+ void
+ SyUnit_error_breakpoint();
+
+ void
+ SyUnit_problem_breakpoint(); // called by the other two
}
#endif /* header guard */
Index: ResultsMap.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include/ResultsMap.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ResultsMap.hh 19 Feb 2003 22:27:36 -0000 1.3
+++ ResultsMap.hh 20 May 2003 09:06:26 -0000 1.4
@@ -9,62 +9,62 @@
namespace SyUnit
{
-class ResultsMapTest;
+ class ResultsMapTest;
-// This class is YAGNI compliant.
-// It maybe be a little short on the error checking, though; it won't
-// notice if you try and assign twice to the same key, for example.
-// (This is because the only accessor is [], and we want to allow
-// rewriting via [] to allow things like appending to a partial
-// message.) Of course, the expected semantics for blah[i] = "foo" is
-// to overwrite blah[i], not add a new additional i field, anyway.
-// Worse, it won't do any validation of the key fields, for improper
-// characters like "@" or ":".
-class ResultsMap {
-public:
- ResultsMap() :
- my_keys(),
- my_map()
- {};
+ // This class is YAGNI compliant.
+ // It maybe be a little short on the error checking, though; it won't
+ // notice if you try and assign twice to the same key, for example.
+ // (This is because the only accessor is [], and we want to allow
+ // rewriting via [] to allow things like appending to a partial
+ // message.) Of course, the expected semantics for blah[i] = "foo" is
+ // to overwrite blah[i], not add a new additional i field, anyway.
+ // Worse, it won't do any validation of the key fields, for improper
+ // characters like "@" or ":".
+ class ResultsMap {
+ public:
+ ResultsMap() :
+ my_keys(),
+ my_map()
+ {};
- ResultsMap(const ResultsMap& other) :
- my_keys(other.my_keys),
- my_map(other.my_map)
- {}
+ ResultsMap(const ResultsMap& other) :
+ my_keys(other.my_keys),
+ my_map(other.my_map)
+ {}
- void
- clear();
+ void
+ clear();
- bool
- operator == (const ResultsMap& other) const;
+ bool
+ operator == (const ResultsMap& other) const;
- bool
- operator != (const ResultsMap& other) const
- { return ! (*this == other); }
+ bool
+ operator != (const ResultsMap& other) const
+ { return ! (*this == other); }
- ResultsMap &
- operator = (const ResultsMap& other);
-
- std::string &
- operator [] (const std::string & key);
-
- // We don't use a ResultsMap& because if we use a reference, we have
- // to make it const (or we won't be able to print nonce objects).
- // But we can't make it const, because operator[] is non-const, and
- // we can't print without using operator[]...
- friend std::ostream &
- operator << (std::ostream &, ResultsMap);
-
-private:
- //. A list to let us print in the same order things were added.
- std::list<std::string> my_keys;
- std::map<std::string, std::string> my_map;
-
- static const std::string continuation_indent;
- static const std::string blank_line_quote;
-
- friend class ResultsMapTest;
-};
+ ResultsMap &
+ operator = (const ResultsMap& other);
+
+ std::string &
+ operator [] (const std::string & key);
+
+ // We don't use a ResultsMap& because if we use a reference, we have
+ // to make it const (or we won't be able to print nonce objects).
+ // But we can't make it const, because operator[] is non-const, and
+ // we can't print without using operator[]...
+ friend std::ostream &
+ operator << (std::ostream &, ResultsMap);
+
+ private:
+ //. A list to let us print in the same order things were added.
+ std::list<std::string> my_keys;
+ std::map<std::string, std::string> my_map;
+
+ static const std::string continuation_indent;
+ static const std::string blank_line_quote;
+
+ friend class ResultsMapTest;
+ };
}
Index: TestCase.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include/TestCase.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- TestCase.hh 19 Feb 2003 22:27:36 -0000 1.3
+++ TestCase.hh 20 May 2003 09:06:26 -0000 1.4
@@ -8,85 +8,85 @@
namespace SyUnit
{
-// A few cheap exception classes
-class TestExit {};
-class TestFailure : public TestExit {};
-class TestError : public TestExit {};
-
-class TestCase
-{
-public:
- TestCase() {}
- virtual ~TestCase() {}
-
- virtual void
- set_up() {}
-
- virtual void
- tear_down() {}
-
- ResultsMap result;
-
- protected:
- void
- fail(const std::string msg = "fail() called");
+ // A few cheap exception classes
+ class TestExit {};
+ class TestFailure : public TestExit {};
+ class TestError : public TestExit {};
- void
- error(const std::string msg = "error() called");
-
- void
- assert_true(bool cond,
- const std::string msg = "assert_true failed");
-
- void
- assert_false(bool cond,
+ class TestCase
+ {
+ public:
+ TestCase() {}
+ virtual ~TestCase() {}
+
+ virtual void
+ set_up() {}
+
+ virtual void
+ tear_down() {}
+
+ ResultsMap result;
+
+ protected:
+ void
+ fail(const std::string msg = "fail() called");
+
+ void
+ error(const std::string msg = "error() called");
+
+ void
+ assert_true(bool cond,
+ const std::string msg = "assert_true failed");
+
+ void
+ assert_false(bool cond,
const std::string msg = "assert_false failed");
-
- template <typename S, typename T>
- void
- assert_equals(S s,
- T t,
- const std::string msg = "assert_equals failed")
- { if (! (s == t) ) fail(msg); }
-
- void
- assert_equals_delta(double x, double y, double epsilon,
- const std::string msg =
- "assert_equals_delta failed");
-
- // Specializations to raise an error if assert_equals is used with
- // floating point numbers.
- template <typename S>
- void
- assert_equals(S, float, const std::string = "")
- { error("Called assert_equals with a float argument."); }
-
- template <typename T>
- void
- assert_equals(float, T, const std::string = "")
- { error("Called assert_equals with a float argument."); }
-
-
- void
- assert_equals(float, float, const std::string = "");
-
- template <typename S>
- void
- assert_equals(S, double, const std::string = "")
- { error("Called assert_equals with a double argument."); }
-
- template <typename T>
- void
- assert_equals(double, T, const std::string = "")
+
+ template <typename S, typename T>
+ void
+ assert_equals(S s,
+ T t,
+ const std::string msg = "assert_equals failed")
+ { if (! (s == t) ) fail(msg); }
+
+ void
+ assert_equals_delta(double x, double y, double epsilon,
+ const std::string msg =
+ "assert_equals_delta failed");
+
+ // Specializations to raise an error if assert_equals is used with
+ // floating point numbers.
+ template <typename S>
+ void
+ assert_equals(S, float, const std::string = "")
+ { error("Called assert_equals with a float argument."); }
+
+ template <typename T>
+ void
+ assert_equals(float, T, const std::string = "")
+ { error("Called assert_equals with a float argument."); }
+
+
+ void
+ assert_equals(float, float, const std::string = "");
+
+ template <typename S>
+ void
+ assert_equals(S, double, const std::string = "")
+ { error("Called assert_equals with a double argument."); }
+
+ template <typename T>
+ void
+ assert_equals(double, T, const std::string = "")
{ error("Called assert_equals with a double argument."); }
-
- void
- assert_equals(double, double, const std::string = "");
-
-};
-
-class InterfaceTestCase : public TestCase {};
-
+
+ void
+ assert_equals(double, double, const std::string = "");
+
+ };
+
+ class InterfaceTestCase : public TestCase {};
+
}
#endif /* header guard */
Index: TestCaseWrapper.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include/TestCaseWrapper.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- TestCaseWrapper.hh 19 Feb 2003 22:27:36 -0000 1.3
+++ TestCaseWrapper.hh 20 May 2003 09:06:26 -0000 1.4
@@ -9,140 +9,140 @@
namespace SyUnit
{
-
-class ResultsMap;
-
-// Pure virtual interface class, so the templatized version can
-// inherit from it.
-class TestCaseWrapper
-{
-public:
- virtual ResultsMap run() = 0;
- virtual const std::string name() const = 0;
- virtual const std::string description() const = 0;
-};
-
-template <typename TC>
-class TestCaseWrapperImpl
- : public SyUnit::TestCaseWrapper
-{
-public:
- typedef void (TC::* method_type)();
-
- TestCaseWrapperImpl(const char* name,
- method_type method,
- const char* description = 0
- ) :
- my_name(name),
- my_description(description),
- my_method(method)
- {}
-
- virtual ResultsMap
- run();
-
- virtual const std::string
- name() const { return my_name; }
-
- virtual const std::string
- description() const { return my_description; }
-private:
- std::string my_name;
- std::string my_description;
- method_type my_method;
-};
-
-class TestExit;
-
-template <typename TC> ResultsMap
-TestCaseWrapperImpl<TC>::run()
-{
- TC test;
-
- test.result["Test"] = my_name;
- if (my_description != "") test.result["Description"] = my_description;
- test.result["Result"] = "PASS";
-
- try
- {
- test.set_up();
- }
- catch (std::exception& e)
+ class ResultsMap;
+
+ // Pure virtual interface class, so the templatized version can
+ // inherit from it.
+ class TestCaseWrapper
{
- SyUnit_error_breakpoint();
- test.result["Result"] = "ERROR";
- test.result["Cause"] = "set_up() threw a std::exception: ";
- test.result["Exception"] = e.what();
- return test.result;
- }
- catch (...)
+ public:
+ virtual ResultsMap run() = 0;
+ virtual const std::string name() const = 0;
+ virtual const std::string description() const = 0;
+ };
+
+ template <typename TC>
+ class TestCaseWrapperImpl
+ : public SyUnit::TestCaseWrapper
{
- SyUnit_error_breakpoint();
- test.result["Result"] = "ERROR";
- test.result["Cause"] = "set_up() threw an unknown exception";
- return test.result;
- }
+ public:
+ typedef void (TC::* method_type)();
+
+ TestCaseWrapperImpl(const char* name,
+ method_type method,
+ const char* description = 0
+ ) :
+ my_name(name),
+ my_description(description),
+ my_method(method)
+ {}
+
+ virtual ResultsMap
+ run();
- try
- {
- (test.*my_method)();
- }
- catch (TestExit& e) {} // maybe should do some verifying that fields
- // match exception thrown...
- catch (std::exception& e)
- {
- SyUnit_error_breakpoint();
- test.result["Result"] = "ERROR";
- test.result["Cause"] = "test method threw a std::exception";
- test.result["Exception"] += e.what();
- }
- catch (...)
- {
- SyUnit_error_breakpoint();
- test.result["Result"] = "ERROR";
- test.result["Cause"] = "test method threw an unknown exception";
- }
- // Always call tear_down()
+ virtual const std::string
+ name() const { return my_name; }
+
+ virtual const std::string
+ description() const { return my_description; }
+
+ private:
+ std::string my_name;
+ std::string my_description;
+ method_type my_method;
+ };
- try
- {
- test.tear_down();
- }
- catch (std::exception& e)
+ class TestExit;
+
+ template <typename TC> ResultsMap
+ TestCaseWrapperImpl<TC>::run()
{
- SyUnit_error_breakpoint();
- std::string msg = "tear_down() threw a std::exception: ";
- msg += e.what();
- if (test.result["Result"] == "ERROR")
- {
- test.result["Details"] += msg;
- test.result["Details"] += "\n";
- }
- else
- {
- test.result["Result"] = "ERROR";
- test.result["Cause"] = msg;
- }
+ TC test;
+
+ test.result["Test"] = my_name;
+ if (my_description != "") test.result["Description"] = my_description;
+ test.result["Result"] = "PASS";
+
+ try
+ {
+ test.set_up();
+ }
+ catch (std::exception& e)
+ {
+ SyUnit_error_breakpoint();
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = "set_up() threw a std::exception: ";
+ test.result["Exception"] = e.what();
+ return test.result;
+ }
+ catch (...)
+ {
+ SyUnit_error_breakpoint();
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = "set_up() threw an unknown exception";
+ return test.result;
+ }
+
+ try
+ {
+ (test.*my_method)();
+ }
+ catch (TestExit& e) {} // maybe should do some verifying that fields
+ // match exception thrown...
+ catch (std::exception& e)
+ {
+ SyUnit_error_breakpoint();
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = "test method threw a std::exception";
+ test.result["Exception"] += e.what();
+ }
+ catch (...)
+ {
+ SyUnit_error_breakpoint();
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = "test method threw an unknown exception";
+ }
+ // Always call tear_down()
+
+ try
+ {
+ test.tear_down();
+ }
+ catch (std::exception& e)
+ {
+ SyUnit_error_breakpoint();
+ std::string msg = "tear_down() threw a std::exception: ";
+ msg += e.what();
+ if (test.result["Result"] == "ERROR")
+ {
+ test.result["Details"] += msg;
+ test.result["Details"] += "\n";
+ }
+ else
+ {
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = msg;
+ }
+ }
+ catch (...)
+ {
+ SyUnit_error_breakpoint();
+ std::string msg = "tear_down() threw an unknown exception";
+ if (test.result["Result"] == "ERROR")
+ {
+ test.result["Details"] += msg;
+ test.result["Details"] += "\n";
+ }
+ else
+ {
+ test.result["Result"] = "ERROR";
+ test.result["Cause"] = msg;
+ }
+ }
+ return test.result;
}
- catch (...)
- {
- SyUnit_error_breakpoint();
- std::string msg = "tear_down() threw an unknown exception";
- if (test.result["Result"] == "ERROR")
- {
- test.result["Details"] += msg;
- test.result["Details"] += "\n";
- }
- else
- {
- test.result["Result"] = "ERROR";
- test.result["Cause"] = msg;
- }
- }
- return test.result;
-}
-
+
}
#endif /* header guard */
Index: TestCmd.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-Test/syunit-c++/include/TestCmd.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- TestCmd.hh 19 Feb 2003 22:27:36 -0000 1.3
+++ TestCmd.hh 20 May 2003 09:06:26 -0000 1.4
@@ -8,30 +8,30 @@
namespace SyUnit
{
-
-class TestCmd
-{
-public:
- TestCmd(char argc, char** argv);
- ~TestCmd();
-
- // This takes ownership of the passed in TestCaseWrapper
- void
- add(TestCaseWrapper* test);
+
+ class TestCmd
+ {
+ public:
+ TestCmd(char argc, char** argv);
+ ~TestCmd();
+
+ // This takes ownership of the passed in TestCaseWrapper
+ void
+ add(TestCaseWrapper* test);
+
+ int
+ run();
+
+ void
+ usage();
- int
- run();
-
- void
- usage();
+ private:
+ std::map<const std::string, TestCaseWrapper*> my_tests;
+ enum { INVALID, LIST, RUN } my_action;
+ std::string my_test_name;
+ std::string my_exec_name;
+ };
-private:
- std::map<const std::string, TestCaseWrapper*> my_tests;
- enum { INVALID, LIST, RUN } my_action;
- std::string my_test_name;
- std::string my_exec_name;
-};
-
}
#endif /* header guard */