Permalink
Browse files

Update th to 604660bfda3d4e330a7452c898970aef27403fd1

  • Loading branch information...
1 parent b6a87c0 commit fe0ea8eefa66bc62582021dd50324b0db51504d1 @rescrv committed Aug 21, 2013
Showing with 24 additions and 22 deletions.
  1. +15 −13 th.cc
  2. +9 −9 th.h
View
@@ -38,33 +38,33 @@
// th
#include "th.h"
-static std::vector<th::base*>* _th_tests = NULL;
+static std::vector<th::test_base*>* _th_tests = NULL;
class escape_from_test_failure
{
public:
escape_from_test_failure() {}
};
-th :: base :: base(const char* group,
- const char* name,
- const char* file,
- size_t line)
+th :: test_base :: test_base(const char* group,
+ const char* name,
+ const char* file,
+ size_t line)
: m_group(group)
, m_name(name)
, m_file(file)
, m_line(line)
{
if (_th_tests == NULL)
{
- _th_tests = new std::vector<th::base*>();
+ _th_tests = new std::vector<th::test_base*>();
}
_th_tests->push_back(this);
}
void
-th :: base :: run(bool* failed)
+th :: test_base :: run(bool* failed)
{
std::cerr << "===== Test " << m_group << "::" << m_name << " @ " << m_file << ":" << m_line << std::endl;
@@ -80,15 +80,15 @@ th :: base :: run(bool* failed)
}
bool
-th :: base :: operator < (const base& rhs) const
+th :: test_base :: operator < (const test_base& rhs) const
{
return compare(rhs) < 0;
}
int
-th :: base :: compare(const base& rhs) const
+th :: test_base :: compare(const test_base& rhs) const
{
- const base& lhs(*this);
+ const test_base& lhs(*this);
int cmp;
// Compare file
@@ -176,7 +176,7 @@ th :: predicate :: fail()
}
static bool
-compare_base_ptrs(const th::base* lhs, const th::base* rhs)
+compare_test_base_ptrs(const th::test_base* lhs, const th::test_base* rhs)
{
return *lhs < *rhs;
}
@@ -189,8 +189,8 @@ th :: run_tests()
return 0;
}
- std::sort(_th_tests->begin(), _th_tests->end(), compare_base_ptrs);
- const std::vector<th::base*>& th_tests(*_th_tests);
+ std::sort(_th_tests->begin(), _th_tests->end(), compare_test_base_ptrs);
+ const std::vector<th::test_base*>& th_tests(*_th_tests);
int failures = 0;
for (size_t i = 0; i < th_tests.size(); ++i)
@@ -207,6 +207,8 @@ th :: run_tests()
return failures;
}
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=noreturn"
+
void
th :: fail()
{
View
@@ -48,28 +48,28 @@ run_tests();
void
fail();
-class base
+class test_base
{
public:
- base(const char* group,
+ test_base(const char* group,
const char* name,
const char* file,
size_t line);
- virtual ~base() throw () {}
+ virtual ~test_base() throw () {}
public:
void run(bool* failed);
public:
- bool operator < (const base& rhs) const;
+ bool operator < (const test_base& rhs) const;
private:
virtual void _run() = 0;
- int compare(const base& rhs) const;
+ int compare(const test_base& rhs) const;
private:
- base(const base&);
- base& operator = (const base&);
+ test_base(const test_base&);
+ test_base& operator = (const test_base&);
private:
const char* m_group;
@@ -119,11 +119,11 @@ class predicate
} // namespace th
#define TEST(GROUP, NAME) \
- class TH_CONCAT(GROUP, TH_CONCAT(_, TH_CONCAT(NAME, TH_CONCAT(_, __LINE__)))) : public th::base \
+ class TH_CONCAT(GROUP, TH_CONCAT(_, TH_CONCAT(NAME, TH_CONCAT(_, __LINE__)))) : public th::test_base \
{ \
public: \
TH_CONCAT(GROUP, TH_CONCAT(_, TH_CONCAT(NAME, TH_CONCAT(_, __LINE__))))() \
- : base(TH_STR(GROUP), TH_STR(NAME), __FILE__, __LINE__) {} \
+ : test_base(TH_STR(GROUP), TH_STR(NAME), __FILE__, __LINE__) {} \
protected: \
virtual void _run(); \
}; \

0 comments on commit fe0ea8e

Please sign in to comment.