Mercurial > malikania
diff examples/animation/main.cpp @ 80:a162f380f02e
CMake: create examples, closes #615
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 22 Jan 2017 09:59:14 +0100 |
parents | 78de82cc6bde |
children | 301599387b40 |
line wrap: on
line diff
--- a/examples/animation/main.cpp Sat Jan 21 14:13:52 2017 +0100 +++ b/examples/animation/main.cpp Sun Jan 22 09:59:14 2017 +0100 @@ -1,7 +1,7 @@ /* * main.cpp -- test animation * - * Copyright (c) 2013-2016 Malikania Authors + * Copyright (c) 2013-2017 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 @@ -20,65 +20,21 @@ #include <thread> #include <exception> -#define BOOST_TEST_MODULE "Animation" -#include <boost/test/unit_test.hpp> - #include <malikania/animation.hpp> #include <malikania/animator.hpp> #include <malikania/client_resources_loader.hpp> #include <malikania/resources_locator.hpp> #include <malikania/window.hpp> -namespace { - -mlk::window win(400, 400); - -} // !namespace - -class test_animation { -protected: - mlk::directory_resources_locator m_locator; - mlk::client_resources_loader m_loader; - -public: - test_animation() - : m_locator(SOURCE_DIRECTORY "/resources") - , m_loader(m_locator) - { - } -}; - -BOOST_FIXTURE_TEST_SUITE(test_animation_suite, test_animation) - -BOOST_AUTO_TEST_CASE(standard) -{ - try { - auto animation = m_loader.load_animation("animations/margins.json"); - - BOOST_REQUIRE_EQUAL(12U, animation.frames().size()); - BOOST_REQUIRE_EQUAL(500U, animation[0].delay()); - BOOST_REQUIRE_EQUAL(501U, animation[1].delay()); - BOOST_REQUIRE_EQUAL(502U, animation[2].delay()); - BOOST_REQUIRE_EQUAL(503U, animation[3].delay()); - BOOST_REQUIRE_EQUAL(504U, animation[4].delay()); - BOOST_REQUIRE_EQUAL(505U, animation[5].delay()); - BOOST_REQUIRE_EQUAL(506U, animation[6].delay()); - BOOST_REQUIRE_EQUAL(507U, animation[7].delay()); - BOOST_REQUIRE_EQUAL(508U, animation[8].delay()); - BOOST_REQUIRE_EQUAL(509U, animation[9].delay()); - BOOST_REQUIRE_EQUAL(510U, animation[10].delay()); - BOOST_REQUIRE_EQUAL(511U, animation[11].delay()); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } -} - -BOOST_AUTO_TEST_CASE(draw) +int main() { boost::timer::cpu_timer timer; try { - mlk::animation animation = m_loader.load_animation("animations/margins.json"); + mlk::window win(400, 400); + mlk::directory_resources_locator locator(SOURCE_DIRECTORY); + mlk::client_resources_loader loader(locator); + mlk::animation animation = loader.load_animation("animations/margins.json"); mlk::animator animator(animation); auto x = (400 / 2) - (animation.sprite().cell().width() / 2); @@ -90,9 +46,8 @@ animator.update(); win.present(); } - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); + } catch (const std::exception& ex) { + std::cerr << ex.what() << std::endl; + return 1; } } - -BOOST_AUTO_TEST_SUITE_END()