summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-11-12 11:12:11 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-11-12 11:12:11 +0100
commit3c577aedb88337775be37d564b6ebe1a3d74c8c3 (patch)
treec326df51d5621310a595f5df6303a722a61fbe3c
parentbe98f6b83acf489daefe604e238e4657940b1e64 (diff)
Converted existing test to catch framework (nw)
-rw-r--r--scripts/src/tests.lua39
-rw-r--r--tests/emu/attotime.cpp7
-rw-r--r--tests/lib/util/corestr.cpp33
-rw-r--r--tests/main.cpp11
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 <stdio.h>
-#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"