summaryrefslogtreecommitdiffstats
path: root/tests/LoadablePieces/LoadablePieces.cpp
diff options
context:
space:
mode:
authorworktycho <work.tycho@gmail.com>2015-06-19 20:41:28 +0200
committerworktycho <work.tycho@gmail.com>2015-06-19 20:41:28 +0200
commit33d68572a61fa1c2201278b8bf4f77c73371930e (patch)
tree44a986bb7f90beee57a5bdc842c720fd657618bb /tests/LoadablePieces/LoadablePieces.cpp
parentCheck the return value of InflateString (diff)
parentAdded cubeset file format docs. (diff)
downloadcuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar.gz
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar.bz2
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar.lz
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar.xz
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.tar.zst
cuberite-33d68572a61fa1c2201278b8bf4f77c73371930e.zip
Diffstat (limited to 'tests/LoadablePieces/LoadablePieces.cpp')
-rw-r--r--tests/LoadablePieces/LoadablePieces.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/LoadablePieces/LoadablePieces.cpp b/tests/LoadablePieces/LoadablePieces.cpp
new file mode 100644
index 000000000..cce43eee1
--- /dev/null
+++ b/tests/LoadablePieces/LoadablePieces.cpp
@@ -0,0 +1,57 @@
+
+// LoadablePieces.cpp
+
+// Implements the LoadablePieces test main entrypoint
+
+#include "Globals.h"
+#ifdef _WIN32
+ #include <direct.h>
+ #define GetCurrentFolder _getcwd
+#else
+ #include <unistd.h>
+ #define GetCurrentFolder getcwd
+#endif
+#include "Generating/PrefabPiecePool.h"
+
+
+
+
+
+static int DoTest(void)
+{
+ cPrefabPiecePool test;
+ auto res = test.LoadFromFile("Test.cubeset", true);
+ if (!res)
+ {
+ LOGWARNING("Loading from file \"Test.cubeset\" failed.");
+ return 1;
+ }
+ LOG("Loaded %u regular pieces and %u starting pieces", static_cast<unsigned>(test.GetAllPiecesCount()), static_cast<unsigned>(test.GetStartingPiecesCount()));
+
+ // Check that we loaded all the pieces:
+ testassert(test.GetAllPiecesCount() == 1);
+ testassert(test.GetStartingPiecesCount() == 1);
+
+ return 0;
+}
+
+
+
+
+
+int main(int argc, char * argv[])
+{
+ // Print the current directory for reference:
+ char folder[FILENAME_MAX];
+ GetCurrentFolder(folder, sizeof(folder));
+ LOG("Running cPrefabPiecePool test from folder \"%s\".", folder);
+
+ // Run the test:
+ int res = DoTest();
+ LOG("cPrefabPiecePool loading test done: %s", (res == 0) ? "success" : "failure");
+ return res;
+}
+
+
+
+