# HG changeset patch # User David Demelier # Date 1540065512 -7200 # Node ID eaa7f85bfc227e2974a60ea23b6c7a0f14667790 # Parent 16ff680a8a94a896b77344d6658a293bd1489ae7 Tests: use BOOST_TEST, closes #917 @1h diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libclient/color/main.cpp --- a/tests/libclient/color/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libclient/color/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -36,50 +36,50 @@ { color c; - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(white) { color c{255, 255, 255, 255}; - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(red) { color c{255, 0, 0, 255}; - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(green) { color c{0, 255, 0, 255}; - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(blue) { color c{0, 0, 255, 255}; - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_SUITE_END() @@ -95,50 +95,50 @@ { const auto c = color::from_hex(0xff000000); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(white) { const auto c = color::from_hex(0xffffffff); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(red) { const auto c = color::from_hex(0xffff0000); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(green) { const auto c = color::from_hex(0xff00ff00); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(blue) { const auto c = color::from_hex(0xff0000ff); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_SUITE_END() @@ -156,50 +156,50 @@ { const auto c = color::from_name("black"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(white) { const auto c = color::from_name("white"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(red) { const auto c = color::from_name("red"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(green) { const auto c = color::from_name("green"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(128, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 128); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(blue) { const auto c = color::from_name("blue"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(wrong) @@ -222,50 +222,50 @@ { const auto c = color::from_name("#000000"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(white) { const auto c = color::from_name("#ffffff"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(red) { const auto c = color::from_name("#ff0000"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(green) { const auto c = color::from_name("#00ff00"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(blue) { const auto c = color::from_name("#0000ff"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(wrong) @@ -288,60 +288,60 @@ { const auto c = color::from_name("#000"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(white) { const auto c = color::from_name("#fff"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(red) { const auto c = color::from_name("#f00"); - BOOST_REQUIRE_EQUAL(255, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 255); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(green) { const auto c = color::from_name("#0f0"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(255, c.green); - BOOST_REQUIRE_EQUAL(0, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 255); + BOOST_TEST(c.blue == 0); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(blue) { const auto c = color::from_name("#00f"); - BOOST_REQUIRE_EQUAL(0, c.red); - BOOST_REQUIRE_EQUAL(0, c.green); - BOOST_REQUIRE_EQUAL(255, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 0); + BOOST_TEST(c.green == 0); + BOOST_TEST(c.blue == 255); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(combination) { const auto c = color::from_name("#123"); - BOOST_REQUIRE_EQUAL(17, c.red); - BOOST_REQUIRE_EQUAL(34, c.green); - BOOST_REQUIRE_EQUAL(51, c.blue); - BOOST_REQUIRE_EQUAL(255, c.alpha); + BOOST_TEST(c.red == 17); + BOOST_TEST(c.green == 34); + BOOST_TEST(c.blue == 51); + BOOST_TEST(c.alpha == 255); } BOOST_AUTO_TEST_CASE(wrong) diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libclient/js-color/main.cpp --- a/tests/libclient/js-color/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libclient/js-color/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -37,7 +37,7 @@ dukx_load_color(ctx_); } - int component(const char *name) + auto component(const char* name) -> int { duk_get_global_string(ctx_, name); auto value = duk_require_int(ctx_, -1); @@ -58,197 +58,158 @@ BOOST_AUTO_TEST_CASE(constructor_default) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color();" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color();" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(0, component("r")); - BOOST_REQUIRE_EQUAL(0, component("g")); - BOOST_REQUIRE_EQUAL(0, component("b")); - BOOST_REQUIRE_EQUAL(255, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 0); + BOOST_TEST(component("g") == 0); + BOOST_TEST(component("b") == 0); + BOOST_TEST(component("a") == 255); } BOOST_AUTO_TEST_CASE(constructor_string) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color('white');" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color('white');" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(255, component("r")); - BOOST_REQUIRE_EQUAL(255, component("g")); - BOOST_REQUIRE_EQUAL(255, component("b")); - BOOST_REQUIRE_EQUAL(255, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 255); + BOOST_TEST(component("g") == 255); + BOOST_TEST(component("b") == 255); + BOOST_TEST(component("a") == 255); } BOOST_AUTO_TEST_CASE(constructor_string_rgb) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color('#0000ff');" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color('#0000ff');" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(0, component("r")); - BOOST_REQUIRE_EQUAL(0, component("g")); - BOOST_REQUIRE_EQUAL(255, component("b")); - BOOST_REQUIRE_EQUAL(255, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 0); + BOOST_TEST(component("g") == 0); + BOOST_TEST(component("b") == 255); + BOOST_TEST(component("a") == 255); } BOOST_AUTO_TEST_CASE(constructor_3_args) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color(10, 20, 30);" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color(10, 20, 30);" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(10, component("r")); - BOOST_REQUIRE_EQUAL(20, component("g")); - BOOST_REQUIRE_EQUAL(30, component("b")); - BOOST_REQUIRE_EQUAL(255, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 10); + BOOST_TEST(component("g") == 20); + BOOST_TEST(component("b") == 30); + BOOST_TEST(component("a") == 255); } BOOST_AUTO_TEST_CASE(constructor_4_args) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color(10, 20, 30, 40);" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color(10, 20, 30, 40);" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(10, component("r")); - BOOST_REQUIRE_EQUAL(20, component("g")); - BOOST_REQUIRE_EQUAL(30, component("b")); - BOOST_REQUIRE_EQUAL(40, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 10); + BOOST_TEST(component("g") == 20); + BOOST_TEST(component("b") == 30); + BOOST_TEST(component("a") == 40); } BOOST_AUTO_TEST_CASE(constructor_object_no_alpha) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color({ red: 10, green: 20, blue: 30 });" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color({ red: 10, green: 20, blue: 30 });" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(10, component("r")); - BOOST_REQUIRE_EQUAL(20, component("g")); - BOOST_REQUIRE_EQUAL(30, component("b")); - BOOST_REQUIRE_EQUAL(255, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 10); + BOOST_TEST(component("g") == 20); + BOOST_TEST(component("b") == 30); + BOOST_TEST(component("a") == 255); } BOOST_AUTO_TEST_CASE(constructor_object_alpha) { - try { - auto ret = duk_peval_string(ctx_, - "c = Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 40 });" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 40 });" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(10, component("r")); - BOOST_REQUIRE_EQUAL(20, component("g")); - BOOST_REQUIRE_EQUAL(30, component("b")); - BOOST_REQUIRE_EQUAL(40, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 10); + BOOST_TEST(component("g") == 20); + BOOST_TEST(component("b") == 30); + BOOST_TEST(component("a") == 40); } BOOST_AUTO_TEST_CASE(constructor_new) { /* - * Just one test, function parse the same way, only 'this' or a new object is returned. + * Just one test, function parse the same way, only 'this' or a new + * object is returned. */ - try { - auto ret = duk_peval_string(ctx_, - "c = new Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 40 });" - "r = c.red;" - "g = c.green;" - "b = c.blue;" - "a = c.alpha;" - ); + const auto ret = duk_peval_string(ctx_, + "c = new Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 40 });" + "r = c.red;" + "g = c.green;" + "b = c.blue;" + "a = c.alpha;" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - BOOST_REQUIRE_EQUAL(10, component("r")); - BOOST_REQUIRE_EQUAL(20, component("g")); - BOOST_REQUIRE_EQUAL(30, component("b")); - BOOST_REQUIRE_EQUAL(40, component("a")); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + BOOST_TEST(component("r") == 10); + BOOST_TEST(component("g") == 20); + BOOST_TEST(component("b") == 30); + BOOST_TEST(component("a") == 40); } BOOST_AUTO_TEST_SUITE_END() @@ -262,245 +223,200 @@ BOOST_AUTO_TEST_CASE(constructor_arg_1) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color(null);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color(null);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "TypeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_arg_2) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color(10, null, 30);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color(10, null, 30);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "TypeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_range_1) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color(-1, 20, 30);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color(-1, 20, 30);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_range_2) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color(10, 20, 256);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color(10, 20, 256);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_range_3) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color(10, 20, 30, 800);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color(10, 20, 30, 800);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_object_range_red) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color({ red: -1, green: 20, blue: 30 });" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color({ red: -1, green: 20, blue: 30 });" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_object_range_alpha) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 800 });" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color({ red: 10, green: 20, blue: 30, alpha: 800 });" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_string) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color('does not exist');" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color('does not exist');" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "Error"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(constructor_string_rgb) { - try { - auto ret = duk_peval_string(ctx_, - "try {" - " Malikania.Color('#ghijkl');" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " Malikania.Color('#ghijkl');" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "Error"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_SUITE_END() @@ -509,120 +425,106 @@ * Require. * ------------------------------------------------------------------ * - * TypeTraits::require expect to have a valid color, it raises an error for any invalid component. Only alpha - * can be ommitted but if it is present and incorrect, an exception is also raised. + * TypeTraits::require expect to have a valid color, it raises an error + * for any invalid component. Only alpha can be ommitted but if it is present + * and incorrect, an exception is also raised. */ BOOST_AUTO_TEST_SUITE(require) BOOST_AUTO_TEST_CASE(success) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - auto color = dukx_require_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + const auto color = dukx_require_color(ctx, 0); - duk_push_uint(ctx, color.red); - duk_put_global_string(ctx, "r"); - duk_push_uint(ctx, color.green); - duk_put_global_string(ctx, "g"); - duk_push_uint(ctx, color.blue); - duk_put_global_string(ctx, "b"); - duk_push_uint(ctx, color.alpha); - duk_put_global_string(ctx, "a"); + duk_push_uint(ctx, color.red); + duk_put_global_string(ctx, "r"); + duk_push_uint(ctx, color.green); + duk_put_global_string(ctx, "g"); + duk_push_uint(ctx, color.blue); + duk_put_global_string(ctx, "b"); + duk_push_uint(ctx, color.alpha); + duk_put_global_string(ctx, "a"); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); - - auto ret = duk_peval_string(ctx_, "draw('#ff0000');"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + const auto ret = duk_peval_string(ctx_, "draw('#ff0000');"); + + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "r"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "g"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "b"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "a"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "r"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "g"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "b"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "a"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(fail) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - dukx_require_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + dukx_require_color(ctx, 0); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - auto ret = duk_peval_string(ctx_, - "try {" - " draw('#ghijkl');" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " draw('#ghijkl');" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "Error"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(fail_alpha) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - dukx_require_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + dukx_require_color(ctx, 0); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - auto ret = duk_peval_string(ctx_, - "try {" - " draw({ red: 10, green: 20, blue: 30, alpha: 800 });" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(ctx_, + "try {" + " draw({ red: 10, green: 20, blue: 30, alpha: 800 });" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "correct"); - BOOST_REQUIRE(duk_to_boolean(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "name"); + BOOST_TEST(duk_to_string(ctx_, -1) == "RangeError"); + duk_pop(ctx_); + duk_get_global_string(ctx_, "correct"); + BOOST_TEST(duk_to_boolean(ctx_, -1)); + duk_pop(ctx_); } BOOST_AUTO_TEST_SUITE_END() @@ -638,170 +540,150 @@ BOOST_AUTO_TEST_CASE(normal) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - auto color = dukx_get_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + const auto color = dukx_get_color(ctx, 0); - duk_push_uint(ctx, color.red); - duk_put_global_string(ctx, "r"); - duk_push_uint(ctx, color.green); - duk_put_global_string(ctx, "g"); - duk_push_uint(ctx, color.blue); - duk_put_global_string(ctx, "b"); - duk_push_uint(ctx, color.alpha); - duk_put_global_string(ctx, "a"); + duk_push_uint(ctx, color.red); + duk_put_global_string(ctx, "r"); + duk_push_uint(ctx, color.green); + duk_put_global_string(ctx, "g"); + duk_push_uint(ctx, color.blue); + duk_put_global_string(ctx, "b"); + duk_push_uint(ctx, color.alpha); + duk_put_global_string(ctx, "a"); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); - - auto ret = duk_peval_string(ctx_, "draw('#ff0000');"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + const auto ret = duk_peval_string(ctx_, "draw('#ff0000');"); + + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "r"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "g"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "b"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "a"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "r"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "g"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "b"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "a"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(adjust_rgb) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - auto color = dukx_get_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + const auto color = dukx_get_color(ctx, 0); - duk_push_uint(ctx, color.red); - duk_put_global_string(ctx, "r"); - duk_push_uint(ctx, color.green); - duk_put_global_string(ctx, "g"); - duk_push_uint(ctx, color.blue); - duk_put_global_string(ctx, "b"); - duk_push_uint(ctx, color.alpha); - duk_put_global_string(ctx, "a"); + duk_push_uint(ctx, color.red); + duk_put_global_string(ctx, "r"); + duk_push_uint(ctx, color.green); + duk_put_global_string(ctx, "g"); + duk_push_uint(ctx, color.blue); + duk_put_global_string(ctx, "b"); + duk_push_uint(ctx, color.alpha); + duk_put_global_string(ctx, "a"); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); - - auto ret = duk_peval_string(ctx_, "draw('#ghijkl');"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + const auto ret = duk_peval_string(ctx_, "draw('#ghijkl');"); + + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "r"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "g"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "b"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "a"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "r"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "g"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "b"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "a"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(adjust_all) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - auto color = dukx_get_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + const auto color = dukx_get_color(ctx, 0); - duk_push_uint(ctx, color.red); - duk_put_global_string(ctx, "r"); - duk_push_uint(ctx, color.green); - duk_put_global_string(ctx, "g"); - duk_push_uint(ctx, color.blue); - duk_put_global_string(ctx, "b"); - duk_push_uint(ctx, color.alpha); - duk_put_global_string(ctx, "a"); + duk_push_uint(ctx, color.red); + duk_put_global_string(ctx, "r"); + duk_push_uint(ctx, color.green); + duk_put_global_string(ctx, "g"); + duk_push_uint(ctx, color.blue); + duk_put_global_string(ctx, "b"); + duk_push_uint(ctx, color.alpha); + duk_put_global_string(ctx, "a"); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); - - auto ret = duk_peval_string(ctx_, "draw({ red: -1, green: 256, blue: 100, alpha: 800 });"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + const auto ret = duk_peval_string(ctx_, "draw({ red: -1, green: 256, blue: 100, alpha: 800 });"); + + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "r"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "g"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "b"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "a"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "r"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "g"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "b"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 100U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "a"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); } BOOST_AUTO_TEST_CASE(something_else) { - try { - duk_push_c_function(ctx_, [] (auto ctx) { - auto color = dukx_get_color(ctx, 0); + duk_push_c_function(ctx_, [] (auto ctx) { + const auto color = dukx_get_color(ctx, 0); - duk_push_uint(ctx, color.red); - duk_put_global_string(ctx, "r"); - duk_push_uint(ctx, color.green); - duk_put_global_string(ctx, "g"); - duk_push_uint(ctx, color.blue); - duk_put_global_string(ctx, "b"); - duk_push_uint(ctx, color.alpha); - duk_put_global_string(ctx, "a"); + duk_push_uint(ctx, color.red); + duk_put_global_string(ctx, "r"); + duk_push_uint(ctx, color.green); + duk_put_global_string(ctx, "g"); + duk_push_uint(ctx, color.blue); + duk_put_global_string(ctx, "b"); + duk_push_uint(ctx, color.alpha); + duk_put_global_string(ctx, "a"); - return 0; - }, 1); - duk_put_global_string(ctx_, "draw"); - - auto ret = duk_peval_string(ctx_, "draw(null);"); + return 0; + }, 1); + duk_put_global_string(ctx_, "draw"); - if (ret != 0) { - throw dukx_get_exception(ctx_, -1); - } + const auto ret = duk_peval_string(ctx_, "draw(null);"); + + if (ret != 0) + throw dukx_get_exception(ctx_, -1); - duk_get_global_string(ctx_, "r"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "g"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "b"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - duk_get_global_string(ctx_, "a"); - BOOST_REQUIRE_EQUAL(255U, duk_to_uint(ctx_, -1)); - duk_pop(ctx_); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(ctx_, "r"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "g"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "b"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 0U); + duk_pop(ctx_); + duk_get_global_string(ctx_, "a"); + BOOST_TEST(duk_to_uint(ctx_, -1) == 255U); + duk_pop(ctx_); } BOOST_AUTO_TEST_SUITE_END() diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/js-elapsed-timer/CMakeLists.txt --- a/tests/libcommon/js-elapsed-timer/CMakeLists.txt Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/js-elapsed-timer/CMakeLists.txt Sat Oct 20 21:58:32 2018 +0200 @@ -21,4 +21,3 @@ LIBRARIES libmlk-common-js SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) - diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/js-line/main.cpp --- a/tests/libcommon/js-line/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/js-line/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -49,126 +49,110 @@ BOOST_AUTO_TEST_CASE(constructor_default) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Line();" - "x1 = r.x1;" - "y1 = r.y1;" - "x2 = r.x2;" - "y2 = r.y2;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Line();" + "x1 = r.x1;" + "y1 = r.y1;" + "x2 = r.x2;" + "y2 = r.y2;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_4_args) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Line(10, 20, 30, 40);" - "x1 = r.x1;" - "y1 = r.y1;" - "x2 = r.x2;" - "y2 = r.y2;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Line(10, 20, 30, 40);" + "x1 = r.x1;" + "y1 = r.y1;" + "x2 = r.x2;" + "y2 = r.y2;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(30, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(40, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 30); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 40); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_object) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Line({ x1: 10, y1: 20, x2: 30, y2: 40 });" - "x1 = r.x1;" - "y1 = r.y1;" - "x2 = r.x2;" - "y2 = r.y2;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Line({ x1: 10, y1: 20, x2: 30, y2: 40 });" + "x1 = r.x1;" + "y1 = r.y1;" + "x2 = r.x2;" + "y2 = r.y2;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(30, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(40, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 30); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 40); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_new) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = new Malikania.Line({ x1: 10, y1: 20, x2: 30, y2: 40 });" - "x1 = r.x1;" - "y1 = r.y1;" - "x2 = r.x2;" - "y2 = r.y2;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = new Malikania.Line({ x1: 10, y1: 20, x2: 30, y2: 40 });" + "x1 = r.x1;" + "y1 = r.y1;" + "x2 = r.x2;" + "y2 = r.y2;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(30, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(40, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 30); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 40); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -182,28 +166,24 @@ BOOST_AUTO_TEST_CASE(arg_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Line(null);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Line(null);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "TypeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -217,76 +197,68 @@ BOOST_AUTO_TEST_CASE(success) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto line = dukx_require_line(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto line = dukx_require_line(ctx, 0); - duk_push_int(ctx, line.x1); - duk_put_global_string(ctx, "x1"); - duk_push_int(ctx, line.y1); - duk_put_global_string(ctx, "y1"); - duk_push_int(ctx, line.x2); - duk_put_global_string(ctx, "x2"); - duk_push_int(ctx, line.y2); - duk_put_global_string(ctx, "y2"); + duk_push_int(ctx, line.x1); + duk_put_global_string(ctx, "x1"); + duk_push_int(ctx, line.y1); + duk_put_global_string(ctx, "y1"); + duk_push_int(ctx, line.x2); + duk_put_global_string(ctx, "x2"); + duk_push_int(ctx, line.y2); + duk_put_global_string(ctx, "y2"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); - - const auto ret = duk_peval_string(m_ctx, "build({ x1: 50, y1: 80, x2: 100, y2: 200 });"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, "build({ x1: 50, y1: 80, x2: 100, y2: 200 });"); + + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(50, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(80, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(100, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(200, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 50); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 80); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 100); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 200); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(fail) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - dukx_require_line(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + dukx_require_line(ctx, 0); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, - "try {" - " build({});" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " build({});" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "Error"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -300,43 +272,39 @@ BOOST_AUTO_TEST_CASE(adjust_all) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto line = dukx_get_line(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto line = dukx_get_line(ctx, 0); - duk_push_int(ctx, line.x1); - duk_put_global_string(ctx, "x1"); - duk_push_int(ctx, line.y1); - duk_put_global_string(ctx, "y1"); - duk_push_int(ctx, line.x2); - duk_put_global_string(ctx, "x2"); - duk_push_int(ctx, line.y2); - duk_put_global_string(ctx, "y2"); + duk_push_int(ctx, line.x1); + duk_put_global_string(ctx, "x1"); + duk_push_int(ctx, line.y1); + duk_put_global_string(ctx, "y1"); + duk_push_int(ctx, line.x2); + duk_put_global_string(ctx, "x2"); + duk_push_int(ctx, line.y2); + duk_put_global_string(ctx, "y2"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); - - const auto ret = duk_peval_string(m_ctx, "build({});"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, "build({});"); + + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x1"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y1"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "x2"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y2"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y1"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "x2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y2"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/js-point/main.cpp --- a/tests/libcommon/js-point/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/js-point/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -49,94 +49,78 @@ BOOST_AUTO_TEST_CASE(constructor_default) { - try { - const auto ret = duk_peval_string(m_ctx, - "p = Malikania.Point();" - "x = p.x;" - "y = p.y;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "p = Malikania.Point();" + "x = p.x;" + "y = p.y;" + ); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_2_args) { - try { - const auto ret = duk_peval_string(m_ctx, - "p = Malikania.Point(-10, -20);" - "x = p.x;" - "y = p.y;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "p = Malikania.Point(-10, -20);" + "x = p.x;" + "y = p.y;" + ); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(-10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(-20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == -10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == -20); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_object) { - try { - const auto ret = duk_peval_string(m_ctx, - "p = Malikania.Point({ x: 100, y: 200 });" - "x = p.x;" - "y = p.y;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "p = Malikania.Point({ x: 100, y: 200 });" + "x = p.x;" + "y = p.y;" + ); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(100, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(200, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 100); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 200); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_new) { - try { - const auto ret = duk_peval_string(m_ctx, - "p = new Malikania.Point({ x: 100, y: 200 });" - "x = p.x;" - "y = p.y;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "p = new Malikania.Point({ x: 100, y: 200 });" + "x = p.x;" + "y = p.y;" + ); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(100, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(200, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 100); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 200); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -150,28 +134,24 @@ BOOST_AUTO_TEST_CASE(constructor_arg_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Point(null);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Point(null);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "TypeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -185,67 +165,58 @@ BOOST_AUTO_TEST_CASE(success) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto point = dukx_require_point(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto point = dukx_require_point(ctx, 0); - duk_push_int(ctx, point.x); - duk_put_global_string(ctx, "x"); - duk_push_int(ctx, point.y); - duk_put_global_string(ctx, "y"); + duk_push_int(ctx, point.x); + duk_put_global_string(ctx, "x"); + duk_push_int(ctx, point.y); + duk_put_global_string(ctx, "y"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, "build({ x: 100, y: 200 });"); + const auto ret = duk_peval_string(m_ctx, "build({ x: 100, y: 200 });"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(100, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(200, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 100); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 200); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(fail) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - dukx_require_point(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + dukx_require_point(ctx, 0); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - auto ret = duk_peval_string(m_ctx, - "try {" - " build({});" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " build({});" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) { - throw dukx_get_exception(m_ctx, -1); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "Error"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -259,33 +230,29 @@ BOOST_AUTO_TEST_CASE(adjust_all) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto point = dukx_get_point(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto point = dukx_get_point(ctx, 0); - duk_push_int(ctx, point.x); - duk_put_global_string(ctx, "x"); - duk_push_int(ctx, point.y); - duk_put_global_string(ctx, "y"); + duk_push_int(ctx, point.x); + duk_put_global_string(ctx, "x"); + duk_push_int(ctx, point.y); + duk_put_global_string(ctx, "y"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, "build({});"); + const auto ret = duk_peval_string(m_ctx, "build({});"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/js-rectangle/main.cpp --- a/tests/libcommon/js-rectangle/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/js-rectangle/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -49,126 +49,110 @@ BOOST_AUTO_TEST_CASE(constructor_default) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Rectangle();" - "x = r.x;" - "y = r.y;" - "w = r.width;" - "h = r.height;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Rectangle();" + "x = r.x;" + "y = r.y;" + "w = r.width;" + "h = r.height;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_4_args) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Rectangle(10, 20, 30, 40);" - "x = r.x;" - "y = r.y;" - "w = r.width;" - "h = r.height;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Rectangle(10, 20, 30, 40);" + "x = r.x;" + "y = r.y;" + "w = r.width;" + "h = r.height;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(30U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(40U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 30U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 40U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_object) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = Malikania.Rectangle({ x: 10, y: 20, width: 30, height: 40 });" - "x = r.x;" - "y = r.y;" - "w = r.width;" - "h = r.height;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = Malikania.Rectangle({ x: 10, y: 20, width: 30, height: 40 });" + "x = r.x;" + "y = r.y;" + "w = r.width;" + "h = r.height;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(30U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(40U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 30U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 40U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_new) { - try { - const auto ret = duk_peval_string(m_ctx, - "r = new Malikania.Rectangle({ x: 10, y: 20, width: 30, height: 40 });" - "x = r.x;" - "y = r.y;" - "w = r.width;" - "h = r.height;" - ); + const auto ret = duk_peval_string(m_ctx, + "r = new Malikania.Rectangle({ x: 10, y: 20, width: 30, height: 40 });" + "x = r.x;" + "y = r.y;" + "w = r.width;" + "h = r.height;" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(10, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(20, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(30U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(40U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 10); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 20); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 30U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 40U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -182,54 +166,46 @@ BOOST_AUTO_TEST_CASE(constructor_arg_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Rectangle(null);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Rectangle(null);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "TypeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_range_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Rectangle(0, 0, -10, -10);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Rectangle(0, 0, -10, -10);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "RangeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -243,76 +219,68 @@ BOOST_AUTO_TEST_CASE(success) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto rect = dukx_require_rect(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto rect = dukx_require_rect(ctx, 0); - duk_push_int(ctx, rect.x); - duk_put_global_string(ctx, "x"); - duk_push_int(ctx, rect.y); - duk_put_global_string(ctx, "y"); - duk_push_uint(ctx, rect.width); - duk_put_global_string(ctx, "w"); - duk_push_uint(ctx, rect.height); - duk_put_global_string(ctx, "h"); + duk_push_int(ctx, rect.x); + duk_put_global_string(ctx, "x"); + duk_push_int(ctx, rect.y); + duk_put_global_string(ctx, "y"); + duk_push_uint(ctx, rect.width); + duk_put_global_string(ctx, "w"); + duk_push_uint(ctx, rect.height); + duk_put_global_string(ctx, "h"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); - - auto ret = duk_peval_string(m_ctx, "build({ x: 50, y: 80, width: 100, height: 200 });"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, "build({ x: 50, y: 80, width: 100, height: 200 });"); + + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(50, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(80, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(200U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 50); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 80); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 100U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 200U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(fail) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - dukx_require_rect(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + dukx_require_rect(ctx, 0); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, - "try {" - " build({});" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " build({});" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "Error"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -326,42 +294,38 @@ BOOST_AUTO_TEST_CASE(adjust_all) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto rect = dukx_get_rect(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto rect = dukx_get_rect(ctx, 0); - duk_push_int(ctx, rect.x); - duk_put_global_string(ctx, "x"); - duk_push_int(ctx, rect.y); - duk_put_global_string(ctx, "y"); - duk_push_uint(ctx, rect.width); - duk_put_global_string(ctx, "w"); - duk_push_uint(ctx, rect.height); + duk_push_int(ctx, rect.x); + duk_put_global_string(ctx, "x"); + duk_push_int(ctx, rect.y); + duk_put_global_string(ctx, "y"); + duk_push_uint(ctx, rect.width); + duk_put_global_string(ctx, "w"); + duk_push_uint(ctx, rect.height); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); - - const auto ret = duk_peval_string(m_ctx, "build({});"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, "build({});"); + + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "x"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "y"); - BOOST_REQUIRE_EQUAL(0, duk_to_int(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "x"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "y"); + BOOST_TEST(duk_to_int(m_ctx, -1) == 0); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/js-size/main.cpp --- a/tests/libcommon/js-size/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/js-size/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -49,94 +49,78 @@ BOOST_AUTO_TEST_CASE(constructor_default) { - try { - const auto ret = duk_peval_string(m_ctx, - "s = Malikania.Size();" - "w = s.width;" - "h = s.height;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "s = Malikania.Size();" + "w = s.width;" + "h = s.height;" + ); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_2_args) { - try { - const auto ret = duk_peval_string(m_ctx, - "s = Malikania.Size(100, 200);" - "w = s.width;" - "h = s.height;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "s = Malikania.Size(100, 200);" + "w = s.width;" + "h = s.height;" + ); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(200U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 100U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 200U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_object) { - try { - const auto ret = duk_peval_string(m_ctx, - "s = Malikania.Size({ width: 100, height: 200 });" - "w = s.width;" - "h = s.height;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "s = Malikania.Size({ width: 100, height: 200 });" + "w = s.width;" + "h = s.height;" + ); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(200U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 100U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 200U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_new) { - try { - const auto ret = duk_peval_string(m_ctx, - "s = new Malikania.Size({ width: 100, height: 200 });" - "w = s.width;" - "h = s.height;" - ); - - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + const auto ret = duk_peval_string(m_ctx, + "s = new Malikania.Size({ width: 100, height: 200 });" + "w = s.width;" + "h = s.height;" + ); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(200U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); + + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 100U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 200U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -150,132 +134,112 @@ BOOST_AUTO_TEST_CASE(constructor_arg_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Size(null);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof TypeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Size(null);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof TypeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("TypeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "TypeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_range_1) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Size(-1, 200);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Size(-1, 200);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "RangeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_range_2) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Size(100, -1);" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Size(100, -1);" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "RangeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_range_3) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Size({ width: -1, height: 200 });" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Size({ width: -1, height: 200 });" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "RangeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(constructor_range_4) { - try { - const auto ret = duk_peval_string(m_ctx, - "try {" - " Malikania.Size({ width: 100, height: -1 });" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof RangeError);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " Malikania.Size({ width: 100, height: -1 });" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof RangeError);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("RangeError", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "RangeError"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -289,66 +253,58 @@ BOOST_AUTO_TEST_CASE(success) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto size = dukx_require_size(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto size = dukx_require_size(ctx, 0); - duk_push_uint(ctx, size.width); - duk_put_global_string(ctx, "w"); - duk_push_uint(ctx, size.height); - duk_put_global_string(ctx, "h"); + duk_push_uint(ctx, size.width); + duk_put_global_string(ctx, "w"); + duk_push_uint(ctx, size.height); + duk_put_global_string(ctx, "h"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, "build({ width: 100, height: 200 });"); + const auto ret = duk_peval_string(m_ctx, "build({ width: 100, height: 200 });"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(100U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(200U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 100U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 200U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_CASE(fail) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - dukx_require_size(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + dukx_require_size(ctx, 0); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, - "try {" - " build({});" - "} catch (e) {" - " name = e.name;" - " correct = (e instanceof Error);" - "}" - ); + const auto ret = duk_peval_string(m_ctx, + "try {" + " build({});" + "} catch (e) {" + " name = e.name;" + " correct = (e instanceof Error);" + "}" + ); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "name"); - BOOST_REQUIRE_EQUAL("Error", duk_to_string(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "correct"); - BOOST_REQUIRE(duk_to_boolean(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "name"); + BOOST_TEST(duk_to_string(m_ctx, -1) == "Error"); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "correct"); + BOOST_TEST(duk_to_boolean(m_ctx, -1)); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() @@ -362,33 +318,29 @@ BOOST_AUTO_TEST_CASE(adjust_all) { - try { - duk_push_c_function(m_ctx, [] (auto ctx) { - const auto size = dukx_get_size(ctx, 0); + duk_push_c_function(m_ctx, [] (auto ctx) { + const auto size = dukx_get_size(ctx, 0); - duk_push_uint(ctx, size.width); - duk_put_global_string(ctx, "w"); - duk_push_uint(ctx, size.height); - duk_put_global_string(ctx, "h"); + duk_push_uint(ctx, size.width); + duk_put_global_string(ctx, "w"); + duk_push_uint(ctx, size.height); + duk_put_global_string(ctx, "h"); - return 0; - }, 1); - duk_put_global_string(m_ctx, "build"); + return 0; + }, 1); + duk_put_global_string(m_ctx, "build"); - const auto ret = duk_peval_string(m_ctx, "build({});"); + const auto ret = duk_peval_string(m_ctx, "build({});"); - if (ret != 0) - throw dukx_get_exception(m_ctx, -1); + if (ret != 0) + throw dukx_get_exception(m_ctx, -1); - duk_get_global_string(m_ctx, "w"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - duk_get_global_string(m_ctx, "h"); - BOOST_REQUIRE_EQUAL(0U, duk_to_uint(m_ctx, -1)); - duk_pop(m_ctx); - } catch (const std::exception &ex) { - BOOST_FAIL(ex.what()); - } + duk_get_global_string(m_ctx, "w"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); + duk_get_global_string(m_ctx, "h"); + BOOST_TEST(duk_to_uint(m_ctx, -1) == 0U); + duk_pop(m_ctx); } BOOST_AUTO_TEST_SUITE_END() diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/line/main.cpp --- a/tests/libcommon/line/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/line/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -59,7 +59,7 @@ { line line1, line2; - BOOST_REQUIRE_EQUAL(line1, line2); + BOOST_TEST(line2 == line1); } BOOST_AUTO_TEST_CASE(operator_eq1) @@ -67,7 +67,7 @@ line line1{10, 20, 30, 40}; line line2{10, 20, 30, 40}; - BOOST_REQUIRE_EQUAL(line1, line2); + BOOST_TEST(line2 == line1); } BOOST_AUTO_TEST_CASE(operator_neq) diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/libcommon/size/main.cpp --- a/tests/libcommon/size/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/libcommon/size/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -35,9 +35,9 @@ BOOST_AUTO_TEST_CASE(null) { - BOOST_REQUIRE(size().is_null()); - BOOST_REQUIRE((!size{0, 10}.is_null())); - BOOST_REQUIRE((!size{10, 0}.is_null())); + BOOST_TEST(size().is_null()); + BOOST_TEST((!size{0, 10}.is_null())); + BOOST_TEST((!size{10, 0}.is_null())); } BOOST_AUTO_TEST_CASE(standard) diff -r 16ff680a8a94 -r eaa7f85bfc22 tests/tools/tileset/main.cpp --- a/tests/tools/tileset/main.cpp Sat Oct 20 21:12:20 2018 +0200 +++ b/tests/tools/tileset/main.cpp Sat Oct 20 21:58:32 2018 +0200 @@ -45,13 +45,13 @@ for (const auto& t : list) { auto tileset = loader_.load_tileset(t); - BOOST_REQUIRE_EQUAL("worldmapchip5fo.png", tileset.image); - BOOST_REQUIRE_EQUAL(32U, tileset.cell.width); - BOOST_REQUIRE_EQUAL(32U, tileset.cell.height); - BOOST_REQUIRE_EQUAL(3U, tileset.tile_properties.size()); + BOOST_TEST(tileset.image == "worldmapchip5fo.png"); + BOOST_TEST(tileset.cell.width == 32U); + BOOST_TEST(tileset.cell.height == 32U); + BOOST_TEST(tileset.tile_properties.size() == 3U); // Index 8. - BOOST_REQUIRE_EQUAL("value", tileset.tile_properties[8]["test"]); + BOOST_TEST(tileset.tile_properties[8]["test"] == "value"); // TODO: postpone collisions once made. }