Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests: Modularize unit testing
Split unit tests into separate files under src/unittest/
Give better unittest diagnostics
Clean up some code
  • Loading branch information
kwolekr committed Apr 26, 2015
1 parent 45a77c8 commit 7220ca9
Show file tree
Hide file tree
Showing 25 changed files with 3,402 additions and 2,502 deletions.
17 changes: 16 additions & 1 deletion build/android/jni/Android.mk
Expand Up @@ -198,7 +198,6 @@ LOCAL_SRC_FILES := \
jni/src/sound_openal.cpp \
jni/src/staticobject.cpp \
jni/src/subgame.cpp \
jni/src/test.cpp \
jni/src/tool.cpp \
jni/src/treegen.cpp \
jni/src/version.cpp \
Expand All @@ -212,6 +211,22 @@ LOCAL_SRC_FILES := \
jni/src/util/sha1.cpp \
jni/src/util/string.cpp \
jni/src/util/timetaker.cpp \
jni/src/unittest/test.cpp \
jni/src/unittest/test_collision.cpp \
jni/src/unittest/test_compression.cpp \
jni/src/unittest/test_connection.cpp \
jni/src/unittest/test_filepath.cpp \
jni/src/unittest/test_inventory.cpp \
jni/src/unittest/test_mapnode.cpp \
jni/src/unittest/test_nodedef.cpp \
jni/src/unittest/test_noise.cpp \
jni/src/unittest/test_profiler.cpp \
jni/src/unittest/test_serialization.cpp \
jni/src/unittest/test_settings.cpp \
jni/src/unittest/test_socket.cpp \
jni/src/unittest/test_utilities.cpp \
jni/src/unittest/test_voxelalgorithms.cpp \
jni/src/unittest/test_voxelmanipulator.cpp \
jni/src/touchscreengui.cpp \
jni/src/database-leveldb.cpp \
jni/src/settings.cpp \
Expand Down
8 changes: 2 additions & 6 deletions src/CMakeLists.txt
Expand Up @@ -278,13 +278,9 @@ add_custom_target(GenerateVersion
add_subdirectory(jthread)
add_subdirectory(network)
add_subdirectory(script)
add_subdirectory(unittest)
add_subdirectory(util)


set (unittests_SRCS
test.cpp
)

set(common_SRCS
ban.cpp
cavegen.cpp
Expand Down Expand Up @@ -360,7 +356,7 @@ set(common_SRCS
${JTHREAD_SRCS}
${common_SCRIPT_SRCS}
${UTIL_SRCS}
${unittests_SRCS}
${UNITTEST_SRCS}
)


Expand Down
6 changes: 6 additions & 0 deletions src/filesys.cpp
Expand Up @@ -662,6 +662,12 @@ std::string RemoveRelativePathComponents(std::string path)
return path.substr(0, pos);
}

const char *GetFilenameFromPath(const char *path)
{
const char *filename = strrchr(path, DIR_DELIM_CHAR);
return filename ? filename + 1 : path;
}

bool safeWriteToFile(const std::string &path, const std::string &content)
{
std::string tmp_file = path + ".~mt";
Expand Down
4 changes: 4 additions & 0 deletions src/filesys.h
Expand Up @@ -103,6 +103,10 @@ std::string RemoveLastPathComponent(const std::string &path,
// this does not resolve symlinks and check for existence of directories.
std::string RemoveRelativePathComponents(std::string path);

// Return the filename from a path or the entire path if no directory delimiter
// is found.
const char *GetFilenameFromPath(const char *path);

bool safeWriteToFile(const std::string &path, const std::string &content);

}//fs
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Expand Up @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mainmenumanager.h"
#include "irrlichttypes_extrabloated.h"
#include "debug.h"
#include "test.h"
#include "unittest/test.h"
#include "server.h"
#include "filesys.h"
#include "version.h"
Expand Down

0 comments on commit 7220ca9

Please sign in to comment.