comparison tests/js/main.cpp @ 488:7e273b7f4f92

Irccd: new coding style, closes #576
author David Demelier <markand@malikania.fr>
date Tue, 26 Sep 2017 17:18:47 +0200
parents 70b0c9e40131
children 16b9ebfd3f08
comparison
equal deleted inserted replaced
487:beb6c638b841 488:7e273b7f4f92
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 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 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19 #include <gtest/gtest.h> 19 #define BOOST_TEST_MODULE "Javascript"
20 #include <boost/test/unit_test.hpp>
20 21
21 #include <duktape.hpp> 22 #include <duktape.hpp>
22 #include <fs.hpp> 23 #include <fs.hpp>
23 24
24 namespace irccd { 25 namespace irccd {
25 26
26 class Test : public testing::Test { 27 class test {
27 protected: 28 protected:
28 UniqueContext m_ctx; 29 UniqueContext ctx_;
29 }; 30 };
30 31
31 /* 32 /*
32 * dukx_peval_file 33 * dukx_peval_file
33 * ------------------------------------------------------------------ 34 * ------------------------------------------------------------------
34 */ 35 */
35 36
36 TEST_F(Test, no_file) 37 BOOST_FIXTURE_TEST_SUITE(test_suite, test)
38
39 BOOST_AUTO_TEST_CASE(no_file)
37 { 40 {
38 ASSERT_THROW(dukx_peval_file(m_ctx, "nonexistent"), Exception); 41 BOOST_REQUIRE_THROW(dukx_peval_file(ctx_, "nonexistent"), Exception);
39 42
40 try { 43 try {
41 dukx_peval_file(m_ctx, "nonexistent"); 44 dukx_peval_file(ctx_, "nonexistent");
42 } catch (const Exception& ex) { 45 } catch (const Exception& ex) {
43 ASSERT_EQ("Error", ex.name); 46 BOOST_REQUIRE_EQUAL("Error", ex.name);
44 ASSERT_EQ("nonexistent", ex.fileName); 47 BOOST_REQUIRE_EQUAL("nonexistent", ex.fileName);
45 } 48 }
46 } 49 }
47 50
48 TEST_F(Test, syntax_error) 51 BOOST_AUTO_TEST_CASE(syntax_error)
49 { 52 {
50 ASSERT_THROW(dukx_peval_file(m_ctx, SOURCEDIR "/syntax-error.js"), Exception); 53 BOOST_REQUIRE_THROW(dukx_peval_file(ctx_, SOURCEDIR "/syntax-error.js"), Exception);
51 54
52 try { 55 try {
53 dukx_peval_file(m_ctx, SOURCEDIR "/syntax-error.js"); 56 dukx_peval_file(ctx_, SOURCEDIR "/syntax-error.js");
54 } catch (const Exception& ex) { 57 } catch (const Exception& ex) {
55 ASSERT_EQ("SyntaxError", ex.name); 58 BOOST_REQUIRE_EQUAL("SyntaxError", ex.name);
56 ASSERT_EQ("syntax-error.js", fs::baseName(ex.fileName)); 59 BOOST_REQUIRE_EQUAL("syntax-error.js", fs::baseName(ex.fileName));
57 ASSERT_EQ(6, ex.lineNumber); 60 BOOST_REQUIRE_EQUAL(6, ex.lineNumber);
58 ASSERT_EQ("empty expression not allowed (line 6)", ex.message); 61 BOOST_REQUIRE_EQUAL("empty expression not allowed (line 6)", ex.message);
59 } 62 }
60 } 63 }
61 64
65 BOOST_AUTO_TEST_SUITE_END()
66
62 } // !irccd 67 } // !irccd
63
64 int main(int argc, char **argv)
65 {
66 testing::InitGoogleTest(&argc, argv);
67
68 return RUN_ALL_TESTS();
69 }