diff --git a/tests/core/Sconscript b/tests/core/Sconscript index bc61935f..28e1d99a 100644 --- a/tests/core/Sconscript +++ b/tests/core/Sconscript @@ -11,10 +11,10 @@ def CoreTest(name, source): return run -res = [ CoreTest("version", "version.c") ] +res = [ CoreTest("version", "version.c") ] +res += [ CoreTest("string", "string.cpp") ] Return("res") -#test( "string", ) #test( "file" ) #test( "database" ) #test( "index" ) diff --git a/tests/core/string.cpp b/tests/core/string.cpp index 7b17a723..52eac07a 100644 --- a/tests/core/string.cpp +++ b/tests/core/string.cpp @@ -3,7 +3,7 @@ * Test the string formatting functions. */ #include -#include +#include "test.h" void test_utos() { @@ -70,10 +70,9 @@ void test_lowercase() } -int main(int argc, char **argv) -{ - test :: run("Unsigned to String Test", test_utos); - test :: run("Seconds to String Test", test_sec2str); - test :: run("Seconds to String (Detailed) Test", test_sec2str_detailed); - test :: run("String Lowercase Test", test_lowercase); -} +DECLARE_UNIT_TESTS( + UNIT_TEST("Unsigned to String", test_utos), + UNIT_TEST("Seconds to String", test_sec2str), + UNIT_TEST("Seconds to String (Detailed)", test_sec2str_detailed), + UNIT_TEST("String Lowercase", test_lowercase), +); diff --git a/tests/core/test.h b/tests/core/test.h new file mode 100644 index 00000000..c505337c --- /dev/null +++ b/tests/core/test.h @@ -0,0 +1,25 @@ +/* + * Copyright 2015 (c) Anna Schumaker. + */ + +#ifndef TESTS_CORE_TESTS_H +#define TESTS_CORE_TESTS_H + +extern "C" { +#include +} + +#include + + +#undef tostring + +template +static inline char *tostring(T s) +{ + std::stringstream ss; + ss << s; + return strdup(ss.str().c_str()); +} + +#endif /* TESTS_CORE_TESTS_H */