diff tests/libclient/js-sprite/main.cpp @ 44:f30c84b4b9ed

Tests: switch from GoogleTest to Boost.Unit, closes #588
author David Demelier <markand@malikania.fr>
date Wed, 30 Nov 2016 21:15:53 +0100
parents fabbe1759cec
children 96ba0c5cf893
line wrap: on
line diff
--- a/tests/libclient/js-sprite/main.cpp	Tue Nov 29 22:25:17 2016 +0100
+++ b/tests/libclient/js-sprite/main.cpp	Wed Nov 30 21:15:53 2016 +0100
@@ -19,7 +19,8 @@
 #include <chrono>
 #include <thread>
 
-#include <gtest/gtest.h>
+#define BOOST_TEST_MODULE "Javascript Sprite"
+#include <boost/test/unit_test.hpp>
 
 #include <malikania/js_client_resources_loader.hpp>
 #include <malikania/js_image.hpp>
@@ -31,14 +32,14 @@
 
 using namespace std::chrono_literals;
 
-class TestSprite : public testing::Test {
+class test_sprite {
 protected:
     directory_resources_locator m_locator;
     client_resources_loader m_loader;
     UniqueContext m_ctx;
 
 public:
-    TestSprite()
+    test_sprite()
         : m_locator(SOURCE_DIRECTORY "/resources")
         , m_loader(m_locator)
     {
@@ -51,7 +52,9 @@
     }
 };
 
-TEST_F(TestSprite, cell)
+BOOST_FIXTURE_TEST_SUITE(test_sprite_suite, test_sprite)
+
+BOOST_AUTO_TEST_CASE(cell)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -65,17 +68,17 @@
         }
 
         duk_get_global_string(m_ctx, "w");
-        ASSERT_EQ(32U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
         duk_get_global_string(m_ctx, "h");
-        ASSERT_EQ(32U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(32U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-TEST_F(TestSprite, columns)
+BOOST_AUTO_TEST_CASE(columns)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -88,14 +91,14 @@
         }
 
         duk_get_global_string(m_ctx, "n");
-        ASSERT_EQ(4U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-TEST_F(TestSprite, margins)
+BOOST_AUTO_TEST_CASE(margins)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -109,17 +112,17 @@
         }
 
         duk_get_global_string(m_ctx, "w");
-        ASSERT_EQ(4U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(4U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
         duk_get_global_string(m_ctx, "h");
-        ASSERT_EQ(6U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(6U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-TEST_F(TestSprite, rows)
+BOOST_AUTO_TEST_CASE(rows)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -132,14 +135,14 @@
         }
 
         duk_get_global_string(m_ctx, "n");
-        ASSERT_EQ(3U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-TEST_F(TestSprite, space)
+BOOST_AUTO_TEST_CASE(space)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -153,17 +156,17 @@
         }
 
         duk_get_global_string(m_ctx, "w");
-        ASSERT_EQ(2U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(2U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
         duk_get_global_string(m_ctx, "h");
-        ASSERT_EQ(3U, duk_to_uint(m_ctx, -1));
+        BOOST_REQUIRE_EQUAL(3U, duk_to_uint(m_ctx, -1));
         duk_pop(m_ctx);
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-TEST_F(TestSprite, basic)
+BOOST_AUTO_TEST_CASE(basic)
 {
     try {
         auto ret = duk_peval_string(m_ctx,
@@ -191,13 +194,8 @@
             std::this_thread::sleep_for(1s);
         }
     } catch (const std::exception &ex) {
-        FAIL() << ex.what();
+        BOOST_FAIL(ex.what());
     }
 }
 
-int main(int argc, char **argv)
-{
-    testing::InitGoogleTest(&argc, argv);
-
-    return RUN_ALL_TESTS();
-}
+BOOST_AUTO_TEST_SUITE_END()