Skip to content

Commit faef2b9

Browse files
author
Sebastiano Merlino
committed
Updating test library to the latest version
1 parent f188527 commit faef2b9

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/littletest.hpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
littletest::auto_test_runner((*__lt_autorun_it__)); \
5353
int __lt_result__ = littletest::auto_test_runner();
5454

55-
#define LT_TEST(__lt_name__) __lt_name__ ## _obj
56-
5755
#define LT_CREATE_RUNNER(__lt_suite_name__, __lt_runner_name__) \
5856
std::cout << "** Initializing Runner \"" << #__lt_runner_name__ << "\" **" << std::endl; \
5957
littletest::test_runner __lt_runner_name__
@@ -70,9 +68,9 @@
7068
#define LT_CHECKPOINT() __lt_tr__->set_checkpoint(__FILE__, __LINE__)
7169

7270
#define LT_BEGIN_TEST(__lt_suite_name__, __lt_test_name__) \
73-
struct __lt_test_name__ : public __lt_suite_name__, littletest::test<__lt_test_name__> \
71+
struct __lt_test_name__ ## _class: public __lt_suite_name__, littletest::test<__lt_test_name__ ## _class> \
7472
{ \
75-
__lt_test_name__() \
73+
__lt_test_name__ ## _class() \
7674
{ \
7775
__lt_name__ = #__lt_test_name__; \
7876
littletest::auto_test_vector.push_back(this); \
@@ -83,7 +81,7 @@
8381
#define LT_END_TEST(__lt_test_name__) \
8482
} \
8583
}; \
86-
__lt_test_name__ __lt_test_name__ ## _obj; \
84+
__lt_test_name__ ## _class __lt_test_name__; \
8785

8886
#define LT_BEGIN_AUTO_TEST(__lt_suite_name__, __lt_test_name__) LT_BEGIN_TEST(__lt_suite_name__, __lt_test_name__)
8987

@@ -348,7 +346,7 @@ class test_base;
348346

349347
std::vector<test_base*> auto_test_vector;
350348

351-
struct test_runner
349+
class test_runner
352350
{
353351
public:
354352
test_runner() :
@@ -377,6 +375,12 @@ struct test_runner
377375
return *this;
378376
}
379377

378+
template <class test_impl>
379+
test_runner& operator()(test_impl& t)
380+
{
381+
return run(&t);
382+
}
383+
380384
template <class test_impl>
381385
test_runner& operator()(test_impl* t)
382386
{
@@ -403,7 +407,7 @@ struct test_runner
403407
std::cout << (failures_counter + success_counter) << " checks" << std::endl;
404408
std::cout << "-> " << success_counter << " successes" << std::endl;
405409
std::cout << "-> " << failures_counter << " failures" << std::endl;
406-
std::cout << "Total run time: " << total_time << std::endl;
410+
std::cout << "Total run time: " << total_time << " ms"<< std::endl;
407411
std::cout << "Total time spent in tests: " << good_time_total << " ms" << std::endl;
408412
std::cout << "Average set up time: " << (total_set_up_time / test_counter) << " ms" << std::endl;
409413
std::cout << "Average tear down time: " << (total_tear_down_time / test_counter) << " ms" << std::endl;
@@ -553,7 +557,7 @@ class test : public test_base
553557

554558
tr->add_good_time(test_duration);
555559

556-
std::cout << "- Time spent during \"" << static_cast<test_impl* >(this)->__lt_name__ << "\": " << test_duration << std::endl;
560+
std::cout << "- Time spent during \"" << static_cast<test_impl* >(this)->__lt_name__ << "\": " << test_duration << " ms"<< std::endl;
557561

558562
try
559563
{
@@ -579,7 +583,7 @@ class test : public test_base
579583
test() { }
580584
test(const test<test_impl>& t) { }
581585

582-
friend struct test_runner;
586+
friend class test_runner;
583587
};
584588

585589
};

0 commit comments

Comments
 (0)