diff --git a/test_functions.cpp b/test_functions.cpp index 21cf279d..798a6905 100644 --- a/test_functions.cpp +++ b/test_functions.cpp @@ -36,28 +36,28 @@ void test_free_func2(std::function f, int arg1) { } int overloaded(int x) { - std::cout << x << std::endl; + INFO(x); return 3; } int overloaded(int x, int y) { - std::cout << x << " " << y << std::endl; + INFO(x << " " << y); return 7; } int overloaded(int x, int y, int z) { - std::cout << x << " " << y << " " << z << std::endl; + INFO(x << " " << y << " " << z); return 11; } int non_overloaded(int x, int y, int z) { - std::cout << x << " " << y << " " << z << std::endl; + INFO(x << " " << y << " " << z); return 13; } namespace sep { int plop_xyz(int x, int y, std::string z) { - std::cout << x << " " << y << " " << z << std::endl; + INFO(x << " " << y << " " << z); return 11; } } @@ -156,9 +156,9 @@ TEST_CASE("functions/deducing-return-order-and-multi-get", "Check if return orde std::tuple tcpp = lua.get("f")(); std::tuple tlua = lua.get("g")(); std::tuple tluaget = lua.get("x", "y", "z"); - std::cout << "cpp: " << std::get<0>(tcpp) << ',' << std::get<1>(tcpp) << ',' << std::get<2>(tcpp) << std::endl; - std::cout << "lua: " << std::get<0>(tlua) << ',' << std::get<1>(tlua) << ',' << std::get<2>(tlua) << std::endl; - std::cout << "lua xyz: " << lua.get("x") << ',' << lua.get("y") << ',' << lua.get("z") << std::endl; + INFO("cpp: " << std::get<0>(tcpp) << ',' << std::get<1>(tcpp) << ',' << std::get<2>(tcpp)); + INFO("lua: " << std::get<0>(tlua) << ',' << std::get<1>(tlua) << ',' << std::get<2>(tlua)); + INFO("lua xyz: " << lua.get("x") << ',' << lua.get("y") << ',' << lua.get("z")); REQUIRE(tcpp == triple); REQUIRE(tlua == triple); REQUIRE(tluaget == triple); @@ -264,11 +264,11 @@ TEST_CASE("functions/function_result-protected_function_result", "Function resul // Some function; just using a lambda to be cheap auto doomfx = []() { - std::cout << "doomfx called" << std::endl; + INFO("doomfx called"); throw std::runtime_error(unhandlederrormessage); }; auto luadoomfx = [&lua]() { - std::cout << "luadoomfx called" << std::endl; + INFO("luadoomfx called"); // Does not bypass error function, will call it luaL_error(lua.lua_state(), unhandlederrormessage); }; @@ -276,7 +276,7 @@ TEST_CASE("functions/function_result-protected_function_result", "Function resul lua.set_function("luadoom", luadoomfx); auto cpphandlerfx = [](std::string x) { - std::cout << "c++ handler called with: " << x << std::endl; + INFO("c++ handler called with: " << x); return handlederrormessage; }; lua.set_function("cpphandler", cpphandlerfx); diff --git a/test_strings.cpp b/test_strings.cpp index c0b28be8..98396e20 100644 --- a/test_strings.cpp +++ b/test_strings.cpp @@ -25,10 +25,10 @@ TEST_CASE("stack/strings", "test that strings can be roundtripped") { static const char16_t utf16str[] = { 0xD83C, 0xDF4C, 0x20, 0x6665, 0x20, 0x46, 0x6F, 0x6F, 0x20, 0xA9, 0x20, 0x62, 0x61, 0x72, 0x20, 0xD834, 0xDF06, 0x20, 0x62, 0x61, 0x7A, 0x20, 0x2603, 0x20, 0x71, 0x75, 0x78, 0x00 }; static const char32_t utf32str[] = { 0x1F34C, 0x0020, 0x6665, 0x0020, 0x0046, 0x006F, 0x006F, 0x0020, 0x00A9, 0x0020, 0x0062, 0x0061, 0x0072, 0x0020, 0x1D306, 0x0020, 0x0062, 0x0061, 0x007A, 0x0020, 0x2603, 0x0020, 0x0071, 0x0075, 0x0078, 0x00 }; #ifdef _WIN32 - std::cout << "win32 widestr" << std::endl; + INFO("win32 widestr"); static const wchar_t widestr[] = { 0xD83C, 0xDF4C, 0x20, 0x6665, 0x20, 0x46, 0x6F, 0x6F, 0x20, 0xA9, 0x20, 0x62, 0x61, 0x72, 0x20, 0xD834, 0xDF06, 0x20, 0x62, 0x61, 0x7A, 0x20, 0x2603, 0x20, 0x71, 0x75, 0x78, 0x00 }; #else - std::cout << "non-windows widestr" << std::endl; + INFO("non-windows widestr"); static const wchar_t widestr[] = { 0x1F34C, 0x0020, 0x6665, 0x0020, 0x0046, 0x006F, 0x006F, 0x0020, 0x00A9, 0x0020, 0x0062, 0x0061, 0x0072, 0x0020, 0x1D306, 0x0020, 0x0062, 0x0061, 0x007A, 0x0020, 0x2603, 0x0020, 0x0071, 0x0075, 0x0078, 0x00 }; #endif static const std::string utf8str_s = utf8str; @@ -37,11 +37,11 @@ TEST_CASE("stack/strings", "test that strings can be roundtripped") { static const std::wstring widestr_s = widestr; #ifdef SOL_CODECVT_SUPPORT - std::cout << "sizeof(wchar_t): " << sizeof(wchar_t) << std::endl; - std::cout << "sizeof(char16_t): " << sizeof(char16_t) << std::endl; - std::cout << "sizeof(char32_t): " << sizeof(char32_t) << std::endl; - std::cout << "utf8str: " << utf8str << std::endl; - std::cout << "utf8str_s: " << utf8str_s << std::endl; + INFO("sizeof(wchar_t): " << sizeof(wchar_t)); + INFO("sizeof(char16_t): " << sizeof(char16_t)); + INFO("sizeof(char32_t): " << sizeof(char32_t)); + INFO("utf8str: " << utf8str); + INFO("utf8str_s: " << utf8str_s); lua["utf8"] = utf8str; lua["utf16"] = utf16str; diff --git a/test_tables.cpp b/test_tables.cpp index afa53eb6..f50d7da2 100644 --- a/test_tables.cpp +++ b/test_tables.cpp @@ -13,7 +13,7 @@ #include "test_stack_guard.hpp" std::string free_function() { - std::cout << "free_function()" << std::endl; + INFO("free_function()"); return "test"; } @@ -31,13 +31,13 @@ std::map test_table_return_three() { struct object { std::string operator() () { - std::cout << "member_test()" << std::endl; + INFO("member_test()"); return "test"; } }; int plop_xyz(int x, int y, std::string z) { - std::cout << x << " " << y << " " << z << std::endl; + INFO(x << " " << y << " " << z); return 11; } @@ -381,7 +381,7 @@ TEST_CASE("tables/functions-variables", "Check if tables and function calls work lua.get("os").set_function("fun", []() { - std::cout << "stateless lambda()" << std::endl; + INFO("stateless lambda()"); return "test"; } ); @@ -407,7 +407,7 @@ TEST_CASE("tables/functions-variables", "Check if tables and function calls work int breakit = 50; lua.get("os").set_function("fun", [&breakit]() { - std::cout << "stateful lambda()" << std::endl; + INFO("stateful lambda()"); return "test"; } ); @@ -526,7 +526,7 @@ TEST_CASE("tables/operator[]-optional", "Test if proxies on tables can lazily ev REQUIRE(non_nope.value() == 1); REQUIRE(non_nope2.value() == 1); - std::cout << "Keys: nope, kek, hah" << std::endl; + INFO("Keys: nope, kek, hah"); lua.set(std::make_tuple("nope", "kek", "hah"), 35); sol::optional non_nope3 = lua["nope"]["kek"]["hah"].get>(); sol::optional non_nope4 = lua.get>(std::make_tuple("nope", "kek", "hah")); diff --git a/test_usertypes.cpp b/test_usertypes.cpp index 9b980f76..4c92cf0a 100644 --- a/test_usertypes.cpp +++ b/test_usertypes.cpp @@ -686,8 +686,8 @@ TEST_CASE("usertype/overloading", "Check if overloading works properly for usert TEST_CASE("usertype/overloading_values", "ensure overloads handle properly") { struct overloading_test { - int print(int i) { std::cout << "Integer print: " << i << std::endl; return 500 + i; } - int print() { std::cout << "No param print." << std::endl; return 500; } + int print(int i) { INFO("Integer print: " << i); return 500 + i; } + int print() { INFO("No param print."); return 500; } }; sol::state lua; @@ -929,7 +929,7 @@ t = thing(256) )"); thing& y = lua["t"]; - std::cout << y.v << std::endl; + INFO(y.v); REQUIRE(y.v == 256); } @@ -1025,7 +1025,7 @@ TEST_CASE("usertype/coverage", "try all the things") { "writeonlypropbark", sol::property(&ext_getset::set) ); - std::cout << "usertype created" << std::endl; + INFO("usertype created"); lua.script(R"( e = ext_getset() @@ -1036,7 +1036,7 @@ print(w) int w = lua["w"]; REQUIRE(w == (56 + 50 + 14 + 14)); - std::cout << "REQUIRE(w) successful" << std::endl; + INFO("REQUIRE(w) successful"); lua.script(R"( e:set(500) @@ -1050,7 +1050,7 @@ y = e.sget(20) REQUIRE(x == 500); REQUIRE(y == 40); - std::cout << "REQUIRE(x, y) successful" << std::endl; + INFO("REQUIRE(x, y) successful"); lua.script(R"( e.bark = 5001 @@ -1069,7 +1069,7 @@ print(b) REQUIRE(a == 5001); REQUIRE(b == 9700); - std::cout << "REQUIRE(a, b) successful" << std::endl; + INFO("REQUIRE(a, b) successful"); lua.script(R"( c = e.readonlybark @@ -1085,7 +1085,7 @@ print(d) REQUIRE(c == 9700); REQUIRE(d == 56); - std::cout << "REQUIRE(c, d) successful" << std::endl; + INFO("REQUIRE(c, d) successful"); lua.script(R"( e.writeonlypropbark = 500 @@ -1097,14 +1097,14 @@ print(e.bark) int z = lua["z"]; REQUIRE(z == 500); - std::cout << "REQUIRE(z) successful" << std::endl; + INFO("REQUIRE(z) successful"); REQUIRE_THROWS(lua.script("e.readonlybark = 24")); - std::cout << "REQUIRE_THROWS 1 successful" << std::endl; + INFO("REQUIRE_THROWS 1 successful"); REQUIRE_THROWS(lua.script("e.readonlypropbark = 500")); - std::cout << "REQUIRE_THROWS 2 successful" << std::endl; + INFO("REQUIRE_THROWS 2 successful"); REQUIRE_THROWS(lua.script("y = e.writeonlypropbark")); - std::cout << "REQUIRE_THROWS 3 successful" << std::endl; + INFO("REQUIRE_THROWS 3 successful"); } diff --git a/tests.cpp b/tests.cpp index 8bf4bbdd..f52efccb 100644 --- a/tests.cpp +++ b/tests.cpp @@ -14,9 +14,13 @@ bool func_opt_ret_bool(sol::optional i) { if (i) - std::cout << i.value() << std::endl; + { + INFO(i.value()); + } else - std::cout << "optional isn't set" << std::endl; + { + INFO("optional isn't set"); + } return true; } @@ -216,7 +220,7 @@ TEST_CASE("interop/null-to-nil-and-back", "nil should be the given type when a p return nullptr; }); lua.set_function("rofl", [](int* x) { - std::cout << x << std::endl; + INFO(x); }); REQUIRE_NOTHROW(lua.script("x = lol()\n" "rofl(x)\n" @@ -232,38 +236,38 @@ TEST_CASE("utilities/this_state", "Ensure this_state argument can be gotten anyw } static int with_state_2(int a, sol::this_state l, int b) { - std::cout << "inside with_state_2" << std::endl; + INFO("inside with_state_2"); lua_State* L = l; - std::cout << "L is" << (void*)L << std::endl; + INFO("L is" << (void*)L); int c = lua_gettop(L); return a * b + (c - c); } }; sol::state lua; - std::cout << "created lua state" << std::endl; + INFO("created lua state"); lua.open_libraries(sol::lib::base); lua.new_usertype("bark", "with_state", &bark::with_state ); - std::cout << "setting b and with_state_2" << std::endl; + INFO("setting b and with_state_2"); bark b; lua.set("b", &b); lua.set("with_state_2", bark::with_state_2); - std::cout << "finished setting" << std::endl; - std::cout << "getting fx" << std::endl; + INFO("finished setting"); + INFO("getting fx"); sol::function fx = lua["with_state_2"]; - std::cout << "calling fx" << std::endl; + INFO("calling fx"); int a = fx(25, 25); - std::cout << "finished setting fx" << std::endl; - std::cout << "calling a script" << std::endl; + INFO("finished setting fx"); + INFO("calling a script"); lua.script("a = with_state_2(25, 25)"); - std::cout << "calling c script" << std::endl; + INFO("calling c script"); lua.script("c = b:with_state(25, 25)"); - std::cout << "getting a" << std::endl; + INFO("getting a"); int la = lua["a"]; - std::cout << "getting b" << std::endl; + INFO("getting b"); int lc = lua["c"]; REQUIRE(lc == 50);