summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorljfa-ag <ljfa-ag@web.de>2015-07-15 18:27:51 +0200
committerljfa-ag <ljfa-ag@web.de>2015-07-15 18:27:51 +0200
commit1434698cc01d9e5b2c73ef7b9fc83de034a96241 (patch)
tree81fc603dbeae2ae5f7abd215777e57d020fb0434
parent6fb5d9850e0fb08c3cd7bdb7dd4f60a03dd0a948 (diff)
downloadProject-Tick-1434698cc01d9e5b2c73ef7b9fc83de034a96241.tar.gz
Project-Tick-1434698cc01d9e5b2c73ef7b9fc83de034a96241.zip
Add tests for primitive numeric limits
-rw-r--r--include/primitive_detail.h4
-rw-r--r--test/nbttest.cpp9
2 files changed, 13 insertions, 0 deletions
diff --git a/include/primitive_detail.h b/include/primitive_detail.h
index dea7ff225f..aaf33ff563 100644
--- a/include/primitive_detail.h
+++ b/include/primitive_detail.h
@@ -20,8 +20,12 @@
#ifndef PRIMITIVE_DETAIL_H_INCLUDED
#define PRIMITIVE_DETAIL_H_INCLUDED
+#include <limits>
#include <type_traits>
+static_assert(std::numeric_limits<float>::is_iec559 && std::numeric_limits<double>::is_iec559,
+ "The floating point values for NBT must conform to IEC 559/IEEE 754");
+
///@cond
namespace nbt
{
diff --git a/test/nbttest.cpp b/test/nbttest.cpp
index 3b72c102e5..516202c57c 100644
--- a/test/nbttest.cpp
+++ b/test/nbttest.cpp
@@ -52,6 +52,15 @@ void test_tag_primitive()
ASSERT(7 == static_cast<int>(tag));
ASSERT(tag_double() == 0.0);
+
+ ASSERT(tag_byte(INT8_MAX).get() == INT8_MAX);
+ ASSERT(tag_byte(INT8_MIN).get() == INT8_MIN);
+ ASSERT(tag_short(INT16_MAX).get() == INT16_MAX);
+ ASSERT(tag_short(INT16_MIN).get() == INT16_MIN);
+ ASSERT(tag_int(INT32_MAX).get() == INT32_MAX);
+ ASSERT(tag_int(INT32_MIN).get() == INT32_MIN);
+ ASSERT(tag_long(INT64_MAX).get() == INT64_MAX);
+ ASSERT(tag_long(INT64_MIN).get() == INT64_MIN);
std::clog << "test_tag_primitive passed" << std::endl;
}