Mercurial > malikania
view tests/libclient/line/main.cpp @ 53:fe7e3524e571
Tests: various style fixes
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 16 Dec 2016 13:07:44 +0100 |
parents | f30c84b4b9ed |
children | 858621081b95 |
line wrap: on
line source
/* * main.cpp -- test mlk::line * * Copyright (c) 2013-2016 Malikania Authors * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #define BOOST_TEST_MODULE "Line" #include <boost/test/unit_test.hpp> #include <malikania/line.hpp> namespace mlk { std::ostream& operator<<(std::ostream& out, const line& line) { out << "{"; out << line.x1() << ", " << line.y1() << ", "; out << line.x2() << ", " << line.y2(); out << "}"; return out; } } // !mlk BOOST_AUTO_TEST_CASE(none) { mlk::line line; BOOST_REQUIRE_EQUAL(0, line.x1()); BOOST_REQUIRE_EQUAL(0, line.y1()); BOOST_REQUIRE_EQUAL(0, line.x2()); BOOST_REQUIRE_EQUAL(0, line.y2()); } BOOST_AUTO_TEST_CASE(standard) { mlk::line line(10, 20, 30, 40); BOOST_REQUIRE_EQUAL(10, line.x1()); BOOST_REQUIRE_EQUAL(20, line.y1()); BOOST_REQUIRE_EQUAL(30, line.x2()); BOOST_REQUIRE_EQUAL(40, line.y2()); } BOOST_AUTO_TEST_CASE(operator_eq) { mlk::line line1, line2; BOOST_REQUIRE_EQUAL(line1, line2); } BOOST_AUTO_TEST_CASE(operator_eq1) { mlk::line line1(10, 20, 30, 40); mlk::line line2(10, 20, 30, 40); BOOST_REQUIRE_EQUAL(line1, line2); } BOOST_AUTO_TEST_CASE(operator_neq) { BOOST_REQUIRE_NE(mlk::line(10), mlk::line(20)); BOOST_REQUIRE_NE(mlk::line(10, 10), mlk::line(10, 20)); BOOST_REQUIRE_NE(mlk::line(10, 10, 10), mlk::line(10, 10, 20)); BOOST_REQUIRE_NE(mlk::line(10, 10, 10, 10), mlk::line(10, 10, 10, 20)); }