diff tests/libclient/rectangle/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 fe7e3524e571
line wrap: on
line diff
--- a/tests/libclient/rectangle/main.cpp	Tue Nov 29 22:25:17 2016 +0100
+++ b/tests/libclient/rectangle/main.cpp	Wed Nov 30 21:15:53 2016 +0100
@@ -16,64 +16,72 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <gtest/gtest.h>
+#define BOOST_TEST_MODULE "Rectangle"
+#include <boost/test/unit_test.hpp>
 
 #include <malikania/rectangle.hpp>
 
-TEST(Basics, none)
+namespace mlk {
+
+std::ostream& operator<<(std::ostream& out, const rectangle& rectangle)
+{
+    out << "{";
+    out << rectangle.width() << ", " << rectangle.height() << ", ";
+    out << rectangle.x() << ", " << rectangle.y();
+    out << "}";
+
+    return out;
+}
+
+}
+
+BOOST_AUTO_TEST_CASE(none)
 {
     mlk::rectangle rectangle;
 
-    ASSERT_EQ(0, rectangle.x());
-    ASSERT_EQ(0, rectangle.y());
-    ASSERT_EQ(0U, rectangle.width());
-    ASSERT_EQ(0U, rectangle.height());
+    BOOST_REQUIRE_EQUAL(0, rectangle.x());
+    BOOST_REQUIRE_EQUAL(0, rectangle.y());
+    BOOST_REQUIRE_EQUAL(0U, rectangle.width());
+    BOOST_REQUIRE_EQUAL(0U, rectangle.height());
 }
 
-TEST(Basics, null)
+BOOST_AUTO_TEST_CASE(null)
 {
-    ASSERT_TRUE(mlk::rectangle().is_null());
-    ASSERT_FALSE(mlk::rectangle(0, 0, 10, 0).is_null());
-    ASSERT_FALSE(mlk::rectangle(0, 0, 0, 10).is_null());
-    ASSERT_FALSE(mlk::rectangle(0, 0, 10, 10).is_null());
+    BOOST_REQUIRE(mlk::rectangle().is_null());
+    BOOST_REQUIRE(!mlk::rectangle(0, 0, 10, 0).is_null());
+    BOOST_REQUIRE(!mlk::rectangle(0, 0, 0, 10).is_null());
+    BOOST_REQUIRE(!mlk::rectangle(0, 0, 10, 10).is_null());
 }
 
-TEST(Basics, standard)
+BOOST_AUTO_TEST_CASE(standard)
 {
     mlk::rectangle rectangle(10, 20, 30, 40);
 
-    ASSERT_EQ(10, rectangle.x());
-    ASSERT_EQ(20, rectangle.y());
-    ASSERT_EQ(30U, rectangle.width());
-    ASSERT_EQ(40U, rectangle.height());
+    BOOST_REQUIRE_EQUAL(10, rectangle.x());
+    BOOST_REQUIRE_EQUAL(20, rectangle.y());
+    BOOST_REQUIRE_EQUAL(30U, rectangle.width());
+    BOOST_REQUIRE_EQUAL(40U, rectangle.height());
 }
 
-TEST(Basics, operatorEq)
+BOOST_AUTO_TEST_CASE(operatorEq)
 {
     mlk::rectangle rectangle1, rectangle2;
 
-    ASSERT_EQ(rectangle1, rectangle2);
+    BOOST_REQUIRE_EQUAL(rectangle1, rectangle2);
 }
 
-TEST(Basics, operatorEq1)
+BOOST_AUTO_TEST_CASE(operatorEq1)
 {
     mlk::rectangle rectangle1(10, 20, 30, 40);
     mlk::rectangle rectangle2(10, 20, 30, 40);
 
-    ASSERT_EQ(rectangle1, rectangle2);
+    BOOST_REQUIRE_EQUAL(rectangle1, rectangle2);
 }
 
-TEST(Basics, operatorNeq)
+BOOST_AUTO_TEST_CASE(operatorNeq)
 {
-    ASSERT_NE(mlk::rectangle(10), mlk::rectangle(20));
-    ASSERT_NE(mlk::rectangle(10, 10), mlk::rectangle(10, 20));
-    ASSERT_NE(mlk::rectangle(10, 10, 10), mlk::rectangle(10, 10, 20));
-    ASSERT_NE(mlk::rectangle(10, 10, 10, 10), mlk::rectangle(10, 10, 10, 20));
+    BOOST_REQUIRE_NE(mlk::rectangle(10), mlk::rectangle(20));
+    BOOST_REQUIRE_NE(mlk::rectangle(10, 10), mlk::rectangle(10, 20));
+    BOOST_REQUIRE_NE(mlk::rectangle(10, 10, 10), mlk::rectangle(10, 10, 20));
+    BOOST_REQUIRE_NE(mlk::rectangle(10, 10, 10, 10), mlk::rectangle(10, 10, 10, 20));
 }
-
-int main(int argc, char **argv)
-{
-    testing::InitGoogleTest(&argc, argv);
-
-    return RUN_ALL_TESTS();
-}