Mercurial > irccd
comparison tests/src/system-jsapi/main.cpp @ 581:a51b5dd5b761
Tests: put everything in src/
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 04 Dec 2017 14:12:13 +0100 |
parents | tests/system-jsapi/main.cpp@84ea13c850f4 |
children | 35832b7f4f9d |
comparison
equal
deleted
inserted
replaced
580:2e16c3623531 | 581:a51b5dd5b761 |
---|---|
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/irccd.hpp> | |
23 #include <irccd/system.hpp> | |
24 | |
25 #include <irccd/js/file_jsapi.hpp> | |
26 #include <irccd/js/system_jsapi.hpp> | |
27 | |
28 #include <js_test.hpp> | |
29 | |
30 namespace irccd { | |
31 | |
32 using fixture = js_test<file_jsapi, system_jsapi>; | |
33 | |
34 BOOST_FIXTURE_TEST_SUITE(system_jsapi_suite, fixture) | |
35 | |
36 BOOST_AUTO_TEST_CASE(home) | |
37 { | |
38 duk_peval_string_noresult(plugin_->context(), "result = Irccd.System.home();"); | |
39 | |
40 BOOST_TEST(duk_get_global_string(plugin_->context(),"result")); | |
41 BOOST_TEST(duk_get_string(plugin_->context(), -1) == sys::home()); | |
42 } | |
43 | |
44 #if defined(HAVE_POPEN) | |
45 | |
46 BOOST_AUTO_TEST_CASE(popen) | |
47 { | |
48 auto ret = duk_peval_string(plugin_->context(), | |
49 "f = Irccd.System.popen(\"" IRCCD_EXECUTABLE " --version\", \"r\");" | |
50 "r = f.readline();" | |
51 ); | |
52 | |
53 if (ret != 0) | |
54 throw dukx_stack(plugin_->context(), -1); | |
55 | |
56 BOOST_TEST(duk_get_global_string(plugin_->context(), "r")); | |
57 BOOST_TEST(duk_get_string(plugin_->context(), -1) == IRCCD_VERSION); | |
58 } | |
59 | |
60 #endif | |
61 | |
62 BOOST_AUTO_TEST_SUITE_END() | |
63 | |
64 } // !irccd |