Mercurial > irccd
comparison tests/src/libirccd-js/jsapi-elapsedtimer/main.cpp @ 611:9fbd1700435b
Tests: reoganize hierarchy
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 15 Dec 2017 15:37:58 +0100 |
parents | tests/src/elapsedtimer-jsapi/main.cpp@9d4da384f5d6 |
children | 27587ff92a64 |
comparison
equal
deleted
inserted
replaced
610:22b3cd6f991f | 611:9fbd1700435b |
---|---|
1 /* | |
2 * main.cpp -- test Irccd.ElapsedTimer API | |
3 * | |
4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
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 | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #define BOOST_TEST_MODULE "ElapsedTimer Javascript API" | |
20 #include <boost/test/unit_test.hpp> | |
21 | |
22 #include <thread> | |
23 | |
24 #include <irccd/js/elapsed_timer_jsapi.hpp> | |
25 | |
26 #include <irccd/test/js_test.hpp> | |
27 | |
28 using namespace std::chrono_literals; | |
29 | |
30 namespace irccd { | |
31 | |
32 BOOST_FIXTURE_TEST_SUITE(elapsed_timer_jsapi_suite, js_test<elapsed_timer_jsapi>) | |
33 | |
34 BOOST_AUTO_TEST_CASE(standard) | |
35 { | |
36 if (duk_peval_string(plugin_->context(), "timer = new Irccd.ElapsedTimer();") != 0) | |
37 throw dukx_stack(plugin_->context(), -1); | |
38 | |
39 std::this_thread::sleep_for(300ms); | |
40 | |
41 if (duk_peval_string(plugin_->context(), "result = timer.elapsed();") != 0) | |
42 throw dukx_stack(plugin_->context(), -1); | |
43 | |
44 BOOST_REQUIRE(duk_get_global_string(plugin_->context(), "result")); | |
45 BOOST_REQUIRE_GE(duk_get_int(plugin_->context(), -1), 250); | |
46 BOOST_REQUIRE_LE(duk_get_int(plugin_->context(), -1), 350); | |
47 } | |
48 | |
49 } // !irccd | |
50 | |
51 BOOST_AUTO_TEST_SUITE_END() |