From 1434698cc01d9e5b2c73ef7b9fc83de034a96241 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Wed, 15 Jul 2015 18:27:51 +0200 Subject: Add tests for primitive numeric limits --- include/primitive_detail.h | 4 ++++ test/nbttest.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) 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 #include +static_assert(std::numeric_limits::is_iec559 && std::numeric_limits::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(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; } -- cgit 0.0.5-2-1-g0f52