diff options
author | Benjamin Segovia <segovia.benjamin@gmail.com> | 2012-05-03 17:12:18 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-08-10 16:16:59 -0700 |
commit | 14430f2092f27a4fda9d8d80be90373388a06801 (patch) | |
tree | 5fa0ec1d8cf63d3c8c033d5e389130a0cbaf4851 /utests/utest.hpp | |
parent | ccd746d3af1a4778e5c145fb752ea5a739f70840 (diff) | |
download | beignet-14430f2092f27a4fda9d8d80be90373388a06801.tar.gz |
Finished the small test framework
Diffstat (limited to 'utests/utest.hpp')
-rw-r--r-- | utests/utest.hpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/utests/utest.hpp b/utests/utest.hpp index e444c721..338a4dca 100644 --- a/utests/utest.hpp +++ b/utests/utest.hpp @@ -27,8 +27,9 @@ #ifndef __UTEST_UTEST_HPP__ #define __UTEST_UTEST_HPP__ +#include "utest_exception.hpp" #include <vector> -#include <exception> +#include <iostream> /*! Quick and dirty unit test system with registration */ struct UTest @@ -51,9 +52,14 @@ struct UTest static void runAll(void); }; -/*! RegisterData a new unit test */ +/*! Register a new unit test */ #define UTEST_REGISTER(FN) static const UTest __##FN##__(FN, #FN); +/*! Turn a function into a unit test */ +#define MAKE_UTEST_FROM_FUNCTION(FN) \ + static void __ANON__##FN##__(void) { UTEST_EXPECT_SUCCESS(FN()); } \ + static const UTest __##FN##__(__ANON__##FN##__, #FN); + /*! No assert is expected */ #define UTEST_EXPECT_SUCCESS(EXPR) \ do { \ @@ -61,7 +67,7 @@ struct UTest EXPR; \ std::cout << " " << #EXPR << " [SUCCESS]" << std::endl; \ } \ - catch (gbe::Exception e) { \ + catch (Exception e) { \ std::cout << " " << #EXPR << " [FAILED]" << std::endl; \ std::cout << " " << e.what() << std::endl; \ } \ |