From 7b30d997258e7b5cf87b723a83eb3d79164b43f7 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 22 Feb 2013 13:19:22 +0000 Subject: [PATCH] test: unit test for 2D boxes. --- test/Makefile.am | 2 +- test/testsuite.vcxproj | 1 + test/unit/box.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 test/unit/box.cpp diff --git a/test/Makefile.am b/test/Makefile.am index 539d5644..ce9611db 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -21,7 +21,7 @@ testsuite_SOURCES = testsuite.cpp \ unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \ unit/build.cpp unit/real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp \ unit/array.cpp unit/rotation.cpp unit/string.cpp unit/map.cpp \ - unit/color.cpp unit/atomic.cpp unit/interp.cpp + unit/color.cpp unit/atomic.cpp unit/interp.cpp unit/box.cpp testsuite_CPPFLAGS = $(AM_CPPFLAGS) testsuite_DEPENDENCIES = @LOL_DEPENDENCIES@ diff --git a/test/testsuite.vcxproj b/test/testsuite.vcxproj index 9951989d..31d5c116 100644 --- a/test/testsuite.vcxproj +++ b/test/testsuite.vcxproj @@ -37,6 +37,7 @@ + diff --git a/test/unit/box.cpp b/test/unit/box.cpp new file mode 100644 index 00000000..f59645d2 --- /dev/null +++ b/test/unit/box.cpp @@ -0,0 +1,39 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://www.wtfpl.net/ for more details. +// + +#if defined HAVE_CONFIG_H +# include "config.h" +#endif + +#include "core.h" +#include "lol/unit.h" + +namespace lol +{ + +LOLUNIT_FIXTURE(BoxTest) +{ + void SetUp() {} + + void TearDown() {} + + LOLUNIT_TEST(Box2DIsect) + { + Box2D b1(vec2(0.f, 0.f), vec2(10.f, 10.f)); + Box2D b2(vec2(5.f, 8.f), vec2(8.f, 12.f)); + Box2D b3(vec2(5.f, 11.f), vec2(8.f, 13.f)); + + LOLUNIT_ASSERT_EQUAL(true, BoxIsectBox(b1, b2)); + LOLUNIT_ASSERT_EQUAL(false, BoxIsectBox(b1, b3)); + } +}; + +} /* namespace lol */ +