comparison 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
comparison
equal deleted inserted replaced
43:fabbe1759cec 44:f30c84b4b9ed
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19 #include <gtest/gtest.h> 19 #define BOOST_TEST_MODULE "Rectangle"
20 #include <boost/test/unit_test.hpp>
20 21
21 #include <malikania/rectangle.hpp> 22 #include <malikania/rectangle.hpp>
22 23
23 TEST(Basics, none) 24 namespace mlk {
25
26 std::ostream& operator<<(std::ostream& out, const rectangle& rectangle)
27 {
28 out << "{";
29 out << rectangle.width() << ", " << rectangle.height() << ", ";
30 out << rectangle.x() << ", " << rectangle.y();
31 out << "}";
32
33 return out;
34 }
35
36 }
37
38 BOOST_AUTO_TEST_CASE(none)
24 { 39 {
25 mlk::rectangle rectangle; 40 mlk::rectangle rectangle;
26 41
27 ASSERT_EQ(0, rectangle.x()); 42 BOOST_REQUIRE_EQUAL(0, rectangle.x());
28 ASSERT_EQ(0, rectangle.y()); 43 BOOST_REQUIRE_EQUAL(0, rectangle.y());
29 ASSERT_EQ(0U, rectangle.width()); 44 BOOST_REQUIRE_EQUAL(0U, rectangle.width());
30 ASSERT_EQ(0U, rectangle.height()); 45 BOOST_REQUIRE_EQUAL(0U, rectangle.height());
31 } 46 }
32 47
33 TEST(Basics, null) 48 BOOST_AUTO_TEST_CASE(null)
34 { 49 {
35 ASSERT_TRUE(mlk::rectangle().is_null()); 50 BOOST_REQUIRE(mlk::rectangle().is_null());
36 ASSERT_FALSE(mlk::rectangle(0, 0, 10, 0).is_null()); 51 BOOST_REQUIRE(!mlk::rectangle(0, 0, 10, 0).is_null());
37 ASSERT_FALSE(mlk::rectangle(0, 0, 0, 10).is_null()); 52 BOOST_REQUIRE(!mlk::rectangle(0, 0, 0, 10).is_null());
38 ASSERT_FALSE(mlk::rectangle(0, 0, 10, 10).is_null()); 53 BOOST_REQUIRE(!mlk::rectangle(0, 0, 10, 10).is_null());
39 } 54 }
40 55
41 TEST(Basics, standard) 56 BOOST_AUTO_TEST_CASE(standard)
42 { 57 {
43 mlk::rectangle rectangle(10, 20, 30, 40); 58 mlk::rectangle rectangle(10, 20, 30, 40);
44 59
45 ASSERT_EQ(10, rectangle.x()); 60 BOOST_REQUIRE_EQUAL(10, rectangle.x());
46 ASSERT_EQ(20, rectangle.y()); 61 BOOST_REQUIRE_EQUAL(20, rectangle.y());
47 ASSERT_EQ(30U, rectangle.width()); 62 BOOST_REQUIRE_EQUAL(30U, rectangle.width());
48 ASSERT_EQ(40U, rectangle.height()); 63 BOOST_REQUIRE_EQUAL(40U, rectangle.height());
49 } 64 }
50 65
51 TEST(Basics, operatorEq) 66 BOOST_AUTO_TEST_CASE(operatorEq)
52 { 67 {
53 mlk::rectangle rectangle1, rectangle2; 68 mlk::rectangle rectangle1, rectangle2;
54 69
55 ASSERT_EQ(rectangle1, rectangle2); 70 BOOST_REQUIRE_EQUAL(rectangle1, rectangle2);
56 } 71 }
57 72
58 TEST(Basics, operatorEq1) 73 BOOST_AUTO_TEST_CASE(operatorEq1)
59 { 74 {
60 mlk::rectangle rectangle1(10, 20, 30, 40); 75 mlk::rectangle rectangle1(10, 20, 30, 40);
61 mlk::rectangle rectangle2(10, 20, 30, 40); 76 mlk::rectangle rectangle2(10, 20, 30, 40);
62 77
63 ASSERT_EQ(rectangle1, rectangle2); 78 BOOST_REQUIRE_EQUAL(rectangle1, rectangle2);
64 } 79 }
65 80
66 TEST(Basics, operatorNeq) 81 BOOST_AUTO_TEST_CASE(operatorNeq)
67 { 82 {
68 ASSERT_NE(mlk::rectangle(10), mlk::rectangle(20)); 83 BOOST_REQUIRE_NE(mlk::rectangle(10), mlk::rectangle(20));
69 ASSERT_NE(mlk::rectangle(10, 10), mlk::rectangle(10, 20)); 84 BOOST_REQUIRE_NE(mlk::rectangle(10, 10), mlk::rectangle(10, 20));
70 ASSERT_NE(mlk::rectangle(10, 10, 10), mlk::rectangle(10, 10, 20)); 85 BOOST_REQUIRE_NE(mlk::rectangle(10, 10, 10), mlk::rectangle(10, 10, 20));
71 ASSERT_NE(mlk::rectangle(10, 10, 10, 10), mlk::rectangle(10, 10, 10, 20)); 86 BOOST_REQUIRE_NE(mlk::rectangle(10, 10, 10, 10), mlk::rectangle(10, 10, 10, 20));
72 } 87 }
73
74 int main(int argc, char **argv)
75 {
76 testing::InitGoogleTest(&argc, argv);
77
78 return RUN_ALL_TESTS();
79 }