Make executable for test follow rules for main file (nw)

Make normal notation for require (nw)
Split properly tests (nw)
master
Miodrag Milanovic 2016-11-12 14:54:21 +01:00
parent 3c577aedb8
commit 75c6c0f059
4 changed files with 81 additions and 12 deletions

View File

@ -21,6 +21,49 @@ project("mametests")
targetdir(MAME_DIR)
end
configuration { "x64", "Release" }
targetsuffix "64"
if _OPTIONS["PROFILE"] then
targetsuffix "64p"
end
configuration { "x64", "Debug" }
targetsuffix "64d"
if _OPTIONS["PROFILE"] then
targetsuffix "64dp"
end
configuration { "x32", "Release" }
targetsuffix ""
if _OPTIONS["PROFILE"] then
targetsuffix "p"
end
configuration { "x32", "Debug" }
targetsuffix "d"
if _OPTIONS["PROFILE"] then
targetsuffix "dp"
end
configuration { "Native", "Release" }
targetsuffix ""
if _OPTIONS["PROFILE"] then
targetsuffix "p"
end
configuration { "Native", "Debug" }
targetsuffix "d"
if _OPTIONS["PROFILE"] then
targetsuffix "dp"
end
configuration { "mingw*" or "vs*" }
targetextension ".exe"
configuration { "rpi" }
targetextension ""
configuration { }
links {
@ -42,6 +85,7 @@ project("mametests")
files {
MAME_DIR .. "tests/main.cpp",
MAME_DIR .. "tests/lib/util/corestr.cpp",
MAME_DIR .. "tests/lib/util/options.cpp",
MAME_DIR .. "tests/emu/attotime.cpp",
}

View File

@ -7,5 +7,5 @@
TEST_CASE("convert 1 sec to attotime", "[emu]")
{
attotime value = attotime::from_seconds(1);
REQUIRE(1000000000000000000 == value.as_attoseconds());
REQUIRE(value.as_attoseconds() == U64(1000000000000000000));
}

View File

@ -5,29 +5,39 @@
TEST_CASE("String make upper", "[util]")
{
std::string value = "test";
REQUIRE("TEST" == strmakeupper(value));
REQUIRE(strmakeupper(value) == "TEST");
}
TEST_CASE("String make lower", "[util]")
{
std::string value = "ValUE";
REQUIRE("value" == strmakelower(value));
REQUIRE(strmakelower(value) == "value");
}
TEST_CASE("String replace", "[util]")
{
std::string value = "Main string";
REQUIRE(1 == strreplace(value,"str","aaa"));
REQUIRE("Main aaaing" == value);
REQUIRE(4 == strreplace(value,"a","b"));
REQUIRE(strreplace(value,"str","aaa") == 1);
REQUIRE(value == "Main aaaing");
REQUIRE(strreplace(value,"a","b") == 4);
}
TEST_CASE("String trimming", "[util]")
TEST_CASE("String replace counting", "[util]")
{
std::string value = "Main aaaing";
REQUIRE(strreplace(value,"a","b") == 4);
}
TEST_CASE("String trimming spaces", "[util]")
{
std::string value = " a value for test ";
REQUIRE("a value for test" == strtrimspace(value));
value = "\r\n\ta value for test\r\n\n\r";
REQUIRE("a value for test" == strtrimspace(value));
REQUIRE(strtrimspace(value) == "a value for test");
}
TEST_CASE("String trimming all special", "[util]")
{
std::string value = "\r\n\ta value for test\r\n\n\r";
REQUIRE(strtrimspace(value) == "a value for test");
}
TEST_CASE("String replace chars", "[util]")
@ -37,7 +47,7 @@ TEST_CASE("String replace chars", "[util]")
strreplacechr(value,'e','E');
strreplacechr(value,'i','I');
strreplacechr(value,'o','O');
REQUIRE("StrIng fOr dOIng rEplAcEs" == value);
REQUIRE(value == "StrIng fOr dOIng rEplAcEs");
}
TEST_CASE("String delete char", "[util]")
@ -47,6 +57,6 @@ TEST_CASE("String delete char", "[util]")
strdelchr(value,'e');
strdelchr(value,'i');
strdelchr(value,'o');
REQUIRE("Strng fr dng dlts" == value);
REQUIRE(value == "Strng fr dng dlts");
}

View File

@ -0,0 +1,15 @@
#include "catch.hpp"
#include "options.h"
TEST_CASE("Empty options should return first as nullptr", "[util]")
{
core_options options;
REQUIRE(options.first() == nullptr);
}
TEST_CASE("Empty options should have iterators same", "[util]")
{
core_options options;
REQUIRE(options.begin() == options.end());
}