Mercurial > irccd
comparison tests/src/libirccd-js/jsapi-system/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/system-jsapi/main.cpp@9d4da384f5d6 |
children | 27587ff92a64 |
comparison
equal
deleted
inserted
replaced
610:22b3cd6f991f | 611:9fbd1700435b |
---|---|
1 /* | |
2 * main.cpp -- test Irccd.System 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 "System Javascript API" | |
20 #include <boost/test/unit_test.hpp> | |
21 | |
22 #include <irccd/system.hpp> | |
23 | |
24 #include <irccd/daemon/irccd.hpp> | |
25 | |
26 #include <irccd/js/file_jsapi.hpp> | |
27 #include <irccd/js/system_jsapi.hpp> | |
28 | |
29 #include <irccd/test/js_test.hpp> | |
30 | |
31 namespace irccd { | |
32 | |
33 using fixture = js_test<file_jsapi, system_jsapi>; | |
34 | |
35 BOOST_FIXTURE_TEST_SUITE(system_jsapi_suite, fixture) | |
36 | |
37 BOOST_AUTO_TEST_CASE(home) | |
38 { | |
39 duk_peval_string_noresult(plugin_->context(), "result = Irccd.System.home();"); | |
40 | |
41 BOOST_TEST(duk_get_global_string(plugin_->context(),"result")); | |
42 BOOST_TEST(duk_get_string(plugin_->context(), -1) == sys::home()); | |
43 } | |
44 | |
45 #if defined(HAVE_POPEN) | |
46 | |
47 BOOST_AUTO_TEST_CASE(popen) | |
48 { | |
49 auto ret = duk_peval_string(plugin_->context(), | |
50 "f = Irccd.System.popen(\"" IRCCD_EXECUTABLE " --version\", \"r\");" | |
51 "r = f.readline();" | |
52 ); | |
53 | |
54 if (ret != 0) | |
55 throw dukx_stack(plugin_->context(), -1); | |
56 | |
57 BOOST_TEST(duk_get_global_string(plugin_->context(), "r")); | |
58 BOOST_TEST(duk_get_string(plugin_->context(), -1) == IRCCD_VERSION); | |
59 } | |
60 | |
61 #endif | |
62 | |
63 BOOST_AUTO_TEST_SUITE_END() | |
64 | |
65 } // !irccd |