view tests/libcommon/point/main.cpp @ 186:16ff680a8a94

Common: move point, line and rectangle, closes #913 @30m
author David Demelier <markand@malikania.fr>
date Sat, 20 Oct 2018 21:12:20 +0200
parents
children
line wrap: on
line source

/*
 * main.cpp -- test mlk::client::point
 *
 * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr>
 *
 * 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 "Point"
#include <boost/test/unit_test.hpp>

#include <malikania/point.hpp>

namespace mlk {

auto operator<<(std::ostream& out, const point& point) -> std::ostream&
{
	out << "{" << point.x << ", " << point.y << "}";

	return out;
}

namespace {

BOOST_AUTO_TEST_CASE(none)
{
	point point;

	BOOST_TEST(point.x == 0);
	BOOST_TEST(point.y == 0);
}

BOOST_AUTO_TEST_CASE(standard)
{
	point point{10, 20};

	BOOST_TEST(point.x == 10);
	BOOST_TEST(point.y == 20);
}

BOOST_AUTO_TEST_CASE(operator_eq)
{
	point point1, point2;

	BOOST_TEST(point1 == point2);
}

BOOST_AUTO_TEST_CASE(operator_eq1)
{
	point point1{10, 20};
	point point2{10, 20};

	BOOST_TEST(point1 == point2);
}

BOOST_AUTO_TEST_CASE(operator_neq)
{
	BOOST_TEST((point{10} != point{20}));
	BOOST_TEST((point{10, 10} != point{10, 20}));
}

} // !namespace

} // !mlk::client