blob: db93ffdf7a95fe38015c4d32328151923b4530e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <cxxtest/TestSuite.h>
#include <cstdint>
#include "value.h"
using namespace nbt;
class value_assignment_test : public CxxTest::TestSuite
{
public:
void test_numeric_assignments()
{
value v;
v = int8_t(-5);
TS_ASSERT_EQUALS(int32_t(v), int32_t(-5));
TS_ASSERT_EQUALS(double(v), static_cast<double>(int8_t(-5)));
v = value();
v = int16_t(12345);
TS_ASSERT_EQUALS(int32_t(v), int32_t(12345));
TS_ASSERT_EQUALS(double(v), static_cast<double>(int16_t(12345)));
v = value();
v = int32_t(100000);
TS_ASSERT_EQUALS(int64_t(v), int64_t(100000));
TS_ASSERT_EQUALS(double(v), static_cast<double>(int32_t(100000)));
v = value();
v = float(3.14f);
TS_ASSERT_EQUALS(double(v), static_cast<double>(3.14f));
v = value();
v = double(2.718281828);
TS_ASSERT_EQUALS(double(v), 2.718281828);
}
};
|