summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-26 22:00:59 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-26 22:43:52 +0300
commit6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0 (patch)
treef85816a3ec1aaaedabfb89fba18b4e696197c495
parente443619d5e77a8d63c23dcf0a418135bc6c1d174 (diff)
downloadmanaplus-6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0.tar.gz
manaplus-6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0.tar.bz2
manaplus-6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0.tar.xz
manaplus-6bfb9a42a3a9689e451ab1a0bc88e8744a3212f0.zip
Convert tests for files into catch format.
-rw-r--r--src/Makefile.am4
-rw-r--r--src/utils/files_unittest.cc15
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;