summaryrefslogtreecommitdiff
path: root/libnbtplusplus/test/test_value.h
blob: 590c5bf2ccc8daa81ab6ca7d4f9286244496056d (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), 5.);

		v = value();
		v = int16_t(12345);
		TS_ASSERT_EQUALS(int32_t(v), int32_t(12345));
		TS_ASSERT_EQUALS(double(v), 12345.);

		v = value();
		v = int32_t(100000);
		TS_ASSERT_EQUALS(int64_t(v), int64_t(100000));
		TS_ASSERT_EQUALS(double(v), 100000.);

		v = value();
		v = float(3.14f);
		TS_ASSERT_EQUALS(double(v), 3.14);

		v = value();
		v = double(2.718281828);
		TS_ASSERT_EQUALS(double(v), 2.718281828);
	}
};