diff --git a/configure.ac b/configure.ac index 992ad93..43c79ca 100644 --- a/configure.ac +++ b/configure.ac @@ -5,8 +5,8 @@ AM_INIT_AUTOMAKE([1.11.1 foreign no-dist-gzip dist-xz]) AM_SILENT_RULES([yes]) AC_LANG([C++]) -AC_PROG_CXX([g++47 g++]) -CXXFLAGS="$CXXFLAGS -std=gnu++0x -Wall -Wextra" +AC_PROG_CXX +CXXFLAGS="$CXXFLAGS -std=c++11 -Wall -Wextra" AC_PROG_CXXCPP AC_PROG_RANLIB AC_PROG_INSTALL diff --git a/tests/Makefile.am b/tests/Makefile.am index a2a783e..fa6c611 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,14 +10,17 @@ test_SOURCES = \ AM_CPPFLAGS = \ -include config.h \ -I$(top_srcdir)/src \ - -pthread + -pthread \ + $(WX_CPPFLAGS) AM_CXXFLAGS = \ - $(FFMPEG_CFLAGS) + $(FFMPEG_CFLAGS) \ + $(WX_CXXFLAGS_ONLY) LDADD = \ ../src/libspek.a \ - $(FFMPEG_LIBS) + $(FFMPEG_LIBS) \ + $(WX_LIBS) AM_LDFLAGS = \ -pthread diff --git a/tests/test-utils.cc b/tests/test-utils.cc index 343ca81..9f29987 100644 --- a/tests/test-utils.cc +++ b/tests/test-utils.cc @@ -20,28 +20,28 @@ #include "test.h" +static void test_vercmp() +{ + test("1.2.3 == 1.2.3", 0, spek_vercmp("1.2.3", "1.2.3")); + test("1.2.3 > 1.2.2", 1, spek_vercmp("1.2.3", "1.2.2")); + test("1.2.2 < 1.2.3", -1, spek_vercmp("1.2.2", "1.2.3")); + test("1.2.3 > 1", 1, spek_vercmp("1.2.3", "1")); + test("1.2.3 > 1.", 1, spek_vercmp("1.2.3", "1.")); + test("1.2.3 > 1.2", 1, spek_vercmp("1.2.3", "1.2")); + test("1.2.3 > 1.2.", 1, spek_vercmp("1.2.3", "1.2.")); + test("1.15.3 > 1.2", 1, spek_vercmp("1.15.3", "1.2")); + test("2 > 1.2.2", 1, spek_vercmp("2", "1.2.2")); + test("1.2.3 > ''", 1, spek_vercmp("1.2.3", "")); + test("'' == ''", 0, spek_vercmp("", "")); + test("123 == 123", 0, spek_vercmp("123", "123")); + test("0.2.3 < 1", -1, spek_vercmp("0.2.3", "1")); + test("0.9.8 < 0.10.1", -1, spek_vercmp("0.9.8", "0.10.1")); + test("1.200 < 2.20", -1, spek_vercmp("1.200", "2.20")); + test("1.0.0 < 2.0.0", -1, spek_vercmp("1.0.0", "2.0.0")); + test("1.0.0 < 1.0.1", -1, spek_vercmp("1.0.0", "1.0.1")); +} + void test_utils() { test_vercmp(); } - -static void test_vercmp() -{ - test(0 == spek_vercmp("1.2.3", "1.2.3"), "1.2.3 == 1.2.3"); - test(1 == spek_vercmp("1.2.3", "1.2.2"), "1.2.3 > 1.2.2"); - test(-1 == spek_vercmp("1.2.2", "1.2.3"), "1.2.2 < 1.2.3"); - test(1 == spek_vercmp("1.2.3", "1"), "1.2.3 > 1"); - test(1 == spek_vercmp("1.2.3", "1."), "1.2.3 > 1."); - test(1 == spek_vercmp("1.2.3", "1.2"), "1.2.3 > 1.2"); - test(1 == spek_vercmp("1.2.3", "1.2."), "1.2.3 > 1.2."); - test(1 == spek_vercmp("1.15.3", "1.2"), "1.15.3 > 1.2"); - test(1 == spek_vercmp("2", "1.2.2"), "2 > 1.2.2"); - test(1 == spek_vercmp("1.2.3", ""), "1.2.3 > ''"); - test(0 == spek_vercmp("", ""), "'' == ''"); - test(0 == spek_vercmp("123", "123"), "123 == 123"); - test(-1 == spek_vercmp("0.2.3", "1"), "0.2.3 < 1"); - test(-1 == spek_vercmp("0.9.8", "0.10.1"), "0.9.8 < 0.10.1"); - test(-1 == spek_vercmp("1.200", "2.20"), "1.200 < 2.20"); - test(-1 == spek_vercmp("1.0.0", "2.0.0"), "1.0.0 < 2.0.0"); - test(-1 == spek_vercmp("1.0.0", "1.0.1"), "1.0.0 < 1.0.1"); -} diff --git a/tests/test.cc b/tests/test.cc index 43a7de0..4396d07 100644 --- a/tests/test.cc +++ b/tests/test.cc @@ -27,7 +27,9 @@ int main() { test_utils(); - std::cerr << g_passes << " / " << g_total << " test passed" << std::endl; + std::cerr << "-------------" << std::endl; + std::cerr << g_passes << "/" << g_total << " tests passed" << std::endl; + std::cerr << "-------------" << std::endl; if (g_passes < g_total) { return -1; } else { @@ -35,12 +37,12 @@ int main() } } -void test(bool condition, const std::string& message) +void test(const std::string& message, bool condition) { g_total++; - if (!condition) { - std::cerr << "FAIL: " << message << std::endl; - } else { + if (condition) { g_passes++; + } else { + std::cerr << "FAIL: " << message << std::endl; } } diff --git a/tests/test.h b/tests/test.h index 31eb085..fa31ac9 100644 --- a/tests/test.h +++ b/tests/test.h @@ -21,7 +21,12 @@ #include -void test(bool condition, const std::string& message); +void test(const std::string& message, bool condition); + +template void test(const std::string& message, const T& expected, const T& actual) +{ + test(message, expected == actual); +} void test_utils();