comparison tests/src/libirccd-js/js-api-directory/main.cpp @ 773:8c44bbcbbab9

Misc: style, cleanup and update
author David Demelier <markand@malikania.fr>
date Fri, 26 Oct 2018 13:01:00 +0200
parents 35c1517d705d
children bfc51f8a00f3
comparison
equal deleted inserted replaced
772:f5ccf65ae929 773:8c44bbcbbab9
28 28
29 namespace { 29 namespace {
30 30
31 class directory_js_fixture : public js_fixture { 31 class directory_js_fixture : public js_fixture {
32 public: 32 public:
33 directory_js_fixture() 33 directory_js_fixture()
34 { 34 {
35 duk::push(plugin_->get_context(), CMAKE_SOURCE_DIR); 35 duk::push(plugin_->get_context(), CMAKE_SOURCE_DIR);
36 duk_put_global_string(plugin_->get_context(), "CMAKE_SOURCE_DIR"); 36 duk_put_global_string(plugin_->get_context(), "CMAKE_SOURCE_DIR");
37 } 37 }
38 }; 38 };
39 39
40 BOOST_FIXTURE_TEST_SUITE(directory_js_api_suite, directory_js_fixture) 40 BOOST_FIXTURE_TEST_SUITE(directory_js_api_suite, directory_js_fixture)
41 41
42 BOOST_AUTO_TEST_CASE(constructor) 42 BOOST_AUTO_TEST_CASE(constructor)
43 { 43 {
44 const std::string script( 44 const std::string script(
45 "d = new Irccd.Directory(CMAKE_SOURCE_DIR + \"/tests/root\");" 45 "d = new Irccd.Directory(CMAKE_SOURCE_DIR + \"/tests/root\");"
46 "p = d.path;" 46 "p = d.path;"
47 "l = d.entries.length;" 47 "l = d.entries.length;"
48 ); 48 );
49 49
50 if (duk_peval_string(plugin_->get_context(), script.c_str()) != 0) 50 if (duk_peval_string(plugin_->get_context(), script.c_str()) != 0)
51 throw duk::get_stack(plugin_->get_context(), -1); 51 throw duk::get_stack(plugin_->get_context(), -1);
52 52
53 duk_get_global_string(plugin_->get_context(), "l"); 53 duk_get_global_string(plugin_->get_context(), "l");
54 BOOST_TEST(duk_get_int(plugin_->get_context(), -1) == 3); 54 BOOST_TEST(duk_get_int(plugin_->get_context(), -1) == 3);
55 } 55 }
56 56
57 BOOST_AUTO_TEST_SUITE_END() 57 BOOST_AUTO_TEST_SUITE_END()
58 58
59 } // !namespace 59 } // !namespace