From 6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 26 May 2015 22:00:59 +0300 Subject: Convert tests for files into catch format. --- src/Makefile.am | 4 ++-- src/utils/files_unittest.cc | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 1627353e7..02bf00a34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1517,8 +1517,8 @@ manaplustests_CXXFLAGS = ${manaplus_CXXFLAGS} \ manaplustests_SOURCES = ${manaplus_SOURCES} \ animatedsprite_unittest.cc \ gui/fonts/textchunklist_unittest.cc \ - gui/widgets/browserbox_unittest.cc -# utils/files_unittest.cc \ + gui/widgets/browserbox_unittest.cc \ + utils/files_unittest.cc # utils/stringutils_unittest.cc \ # utils/xmlutils_unittest.cc \ # resources/dye_unittest.cc \ diff --git a/src/utils/files_unittest.cc b/src/utils/files_unittest.cc index 63e1fc271..4adfea8c9 100644 --- a/src/utils/files_unittest.cc +++ b/src/utils/files_unittest.cc @@ -20,17 +20,16 @@ #include "utils/files.h" +#include "catch.hpp" #include "logger.h" #include "utils/physfstools.h" -#include "gtest/gtest.h" - #include "resources/resourcemanager.h" #include "debug.h" -static void init() +TEST_CASE("Files renameFile", "files") { PHYSFS_init("manaplus"); dirSeparator = "/"; @@ -38,11 +37,7 @@ static void init() ResourceManager *resman = ResourceManager::getInstance(); resman->addToSearchPath("data", false); resman->addToSearchPath("../data", false); -} -TEST(Files, renameFile) -{ - init(); const int sz = 1234567; char *buf = new char[sz]; for (int f = 0; f < sz; f ++) @@ -54,17 +49,17 @@ TEST(Files, renameFile) fwrite(buf, 1, sz, file); fclose(file); - EXPECT_EQ(0, Files::renameFile(name1, name2)); + REQUIRE(0 == Files::renameFile(name1, name2)); char *buf2 = new char[sz]; FILE *file2 = fopen(name2.c_str(), "rb"); - EXPECT_NE(nullptr, file2); + REQUIRE_FALSE(nullptr == file2); fread(buf2, 1, sz, file2); fclose(file2); ::remove(name1.c_str()); ::remove(name2.c_str()); for (int f = 0; f < sz; f ++) - EXPECT_EQ(buf[f], buf2[f]); + REQUIRE(buf[f] == buf2[f]); delete [] buf; delete [] buf2; -- cgit v1.2.3-60-g2f50