diff options
author | tycho <work.tycho@gmail.com> | 2015-12-15 22:46:22 +0100 |
---|---|---|
committer | tycho <work.tycho@gmail.com> | 2016-01-18 17:31:46 +0100 |
commit | 3a39639b1e3bbd272548c7afbf64c33d45d1fefb (patch) | |
tree | aeaf384d5265671f9bddb31d8e90b8519b1af69b | |
parent | Merge pull request #2895 from LogicParrot/readme (diff) | |
download | cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar.gz cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar.bz2 cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar.lz cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar.xz cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.tar.zst cuberite-3a39639b1e3bbd272548c7afbf64c33d45d1fefb.zip |
-rw-r--r-- | src/WorldStorage/FastNBT.cpp | 7 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/WorldStorage/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/WorldStorage/FastNBT/CMakeLists.txt | 18 | ||||
-rw-r--r-- | tests/WorldStorage/FastNBT/Parse.cpp | 26 | ||||
-rw-r--r-- | tests/WorldStorage/FastNBT/creatable.cpp | 7 |
6 files changed, 64 insertions, 0 deletions
diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 1a81a6469..d4e781af1 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -64,6 +64,13 @@ bool cParsedNBT::Parse(void) // Data too short return false; } + + if (m_Data == nullptr) + { + // Invalid Data + return false; + } + if (m_Data[0] != TAG_Compound) { // The top-level tag must be a Compound diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bdab4bc58..81f0da471 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,3 +11,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(ChunkData) add_subdirectory(Network) add_subdirectory(LoadablePieces) +add_subdirectory(WorldStorage) diff --git a/tests/WorldStorage/CMakeLists.txt b/tests/WorldStorage/CMakeLists.txt new file mode 100644 index 000000000..bdb61688d --- /dev/null +++ b/tests/WorldStorage/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +add_subdirectory(FastNBT) diff --git a/tests/WorldStorage/FastNBT/CMakeLists.txt b/tests/WorldStorage/FastNBT/CMakeLists.txt new file mode 100644 index 000000000..1f6f0ef8d --- /dev/null +++ b/tests/WorldStorage/FastNBT/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 2.6) + +enable_testing() + +include_directories(${CMAKE_SOURCE_DIR}/src/) + + +add_definitions(-DTEST_GLOBALS=1) +add_library(TestFastNBT ${CMAKE_SOURCE_DIR}/src/WorldStorage/FastNBT.cpp ${CMAKE_SOURCE_DIR}/src/StringUtils.cpp) + +add_executable(fastnbt-creatable-exe creatable.cpp) +target_link_libraries(fastnbt-creatable-exe TestFastNBT) +add_test(NAME fastnbt-creatable-test COMMAND fastnbt-creatable-exe) + + +add_executable(fastnbt-parse-exe Parse.cpp) +target_link_libraries(fastnbt-parse-exe TestFastNBT) +add_test(NAME fastnbt-parse-test COMMAND fastnbt-parse-exe) diff --git a/tests/WorldStorage/FastNBT/Parse.cpp b/tests/WorldStorage/FastNBT/Parse.cpp new file mode 100644 index 000000000..a57e5861e --- /dev/null +++ b/tests/WorldStorage/FastNBT/Parse.cpp @@ -0,0 +1,26 @@ +#include "Globals.h" +#include "WorldStorage/FastNBT.h" + +int main() { + { + cParsedNBT nbt{nullptr, 0}; + + testassert(!nbt.IsValid()); + } + + { + cParsedNBT nbt{nullptr, 2}; + + testassert(!nbt.IsValid()); + } + { + cParsedNBT nbt{"", 3}; + + testassert(!nbt.IsValid()); + } + { + cParsedNBT nbt{nullptr, 3}; + + testassert(!nbt.IsValid()); + } +} diff --git a/tests/WorldStorage/FastNBT/creatable.cpp b/tests/WorldStorage/FastNBT/creatable.cpp new file mode 100644 index 000000000..677071c3d --- /dev/null +++ b/tests/WorldStorage/FastNBT/creatable.cpp @@ -0,0 +1,7 @@ +#include "Globals.h" +#include "WorldStorage/FastNBT.h" + +int main() { + cParsedNBT{}; + cFastNBTWriter test{}; +} |