From 3c577aedb88337775be37d564b6ebe1a3d74c8c3 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 12 Nov 2016 11:12:11 +0100 Subject: Converted existing test to catch framework (nw) --- scripts/src/tests.lua | 39 +-------------------------------------- tests/emu/attotime.cpp | 7 ++++--- tests/lib/util/corestr.cpp | 33 +++++++++++++++++---------------- tests/main.cpp | 11 ++--------- 4 files changed, 24 insertions(+), 66 deletions(-) diff --git a/scripts/src/tests.lua b/scripts/src/tests.lua index e0a8da88d75..662f6ac0c20 100644 --- a/scripts/src/tests.lua +++ b/scripts/src/tests.lua @@ -8,37 +8,6 @@ -- Rules for building tests -- --------------------------------------------------------------------------- --------------------------------------------------- --- GoogleTest library objects --------------------------------------------------- - -project "gtest" - uuid "fa306a8d-fb10-4d4a-9d2e-fdb9076407b4" - kind "StaticLib" - - configuration { "gmake or ninja" } - buildoptions { - "-Wno-undef", - "-Wno-unused-variable", - } - - configuration { "vs*" } -if _OPTIONS["vs"]=="intel-15" then - buildoptions { - "/Qwd1195", -- error #1195: conversion from integer to smaller pointer - } -end - - configuration { } - - includedirs { - MAME_DIR .. "3rdparty/googletest/googletest/include", - MAME_DIR .. "3rdparty/googletest/googletest", - } - files { - MAME_DIR .. "3rdparty/googletest/googletest/src/gtest-all.cc", - } - project("mametests") uuid ("66d4c639-196b-4065-a411-7ee9266564f5") @@ -52,15 +21,9 @@ project("mametests") targetdir(MAME_DIR) end - configuration { "gmake or ninja" } - buildoptions { - "-Wno-undef", - } - configuration { } links { - "gtest", "utils", ext_lib("expat"), ext_lib("zlib"), @@ -68,7 +31,7 @@ project("mametests") } includedirs { - MAME_DIR .. "3rdparty/googletest/googletest/include", + MAME_DIR .. "3rdparty/catch/single_include", MAME_DIR .. "src/osd", MAME_DIR .. "src/emu", MAME_DIR .. "src/lib/util", diff --git a/tests/emu/attotime.cpp b/tests/emu/attotime.cpp index 7d170c32abe..e37954b249f 100644 --- a/tests/emu/attotime.cpp +++ b/tests/emu/attotime.cpp @@ -1,10 +1,11 @@ -#include "gtest/gtest.h" +#include "catch.hpp" + #include "emucore.h" #include "eminline.h" #include "attotime.h" -TEST(attotime,as_attoseconds) +TEST_CASE("convert 1 sec to attotime", "[emu]") { attotime value = attotime::from_seconds(1); - EXPECT_EQ(1000000000000000000, value.as_attoseconds()); + REQUIRE(1000000000000000000 == value.as_attoseconds()); } diff --git a/tests/lib/util/corestr.cpp b/tests/lib/util/corestr.cpp index 3da0bc75541..5bf752a4818 100644 --- a/tests/lib/util/corestr.cpp +++ b/tests/lib/util/corestr.cpp @@ -1,51 +1,52 @@ -#include "gtest/gtest.h" +#include "catch.hpp" + #include "corestr.h" -TEST(corestr,strmakeupper) +TEST_CASE("String make upper", "[util]") { std::string value = "test"; - EXPECT_STREQ("TEST", strmakeupper(value).c_str()); + REQUIRE("TEST" == strmakeupper(value)); } -TEST(corestr,strmakelower) +TEST_CASE("String make lower", "[util]") { std::string value = "ValUE"; - EXPECT_STREQ("value", strmakelower(value).c_str()); + REQUIRE("value" == strmakelower(value)); } -TEST(corestr,strreplace) +TEST_CASE("String replace", "[util]") { std::string value = "Main string"; - EXPECT_EQ(1, strreplace(value,"str","aaa")); - EXPECT_STREQ("Main aaaing", value.c_str()); - EXPECT_EQ(4, strreplace(value,"a","b")); + REQUIRE(1 == strreplace(value,"str","aaa")); + REQUIRE("Main aaaing" == value); + REQUIRE(4 == strreplace(value,"a","b")); } -TEST(corestr,strtrimspace) +TEST_CASE("String trimming", "[util]") { std::string value = " a value for test "; - EXPECT_STREQ("a value for test", strtrimspace(value).c_str()); + REQUIRE("a value for test" == strtrimspace(value)); value = "\r\n\ta value for test\r\n\n\r"; - EXPECT_STREQ("a value for test", strtrimspace(value).c_str()); + REQUIRE("a value for test" == strtrimspace(value)); } -TEST(corestr,strreplacechr) +TEST_CASE("String replace chars", "[util]") { std::string value = "String for doing replaces"; strreplacechr(value,'a','A'); strreplacechr(value,'e','E'); strreplacechr(value,'i','I'); strreplacechr(value,'o','O'); - EXPECT_STREQ("StrIng fOr dOIng rEplAcEs", value.c_str()); + REQUIRE("StrIng fOr dOIng rEplAcEs" == value); } -TEST(corestr,strdelchr) +TEST_CASE("String delete char", "[util]") { std::string value = "String for doing deletes"; strdelchr(value,'a'); strdelchr(value,'e'); strdelchr(value,'i'); strdelchr(value,'o'); - EXPECT_STREQ("Strng fr dng dlts", value.c_str()); + REQUIRE("Strng fr dng dlts" == value); } diff --git a/tests/main.cpp b/tests/main.cpp index 5a07b837186..0c7c351f437 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,9 +1,2 @@ -#include -#include "gtest/gtest.h" - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} - +#define CATCH_CONFIG_MAIN +#include "catch.hpp" -- cgit v1.2.3-70-g09d2