summaryrefslogtreecommitdiff
path: root/modules/codec/tests/data_raw.cpp
blob: 26c272103d11c3388e70e9c18f8ef32e7a35580b (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
37
38
39
40
41
42
#include <forstio/test/suite.hpp>
#include "../c++/data_raw.hpp"

namespace {
namespace sch {
using namespace saw::schema;

using Int32Array = Array<
	Int32
>;
}

SAW_TEST("Data NativeRaw/Array of Primitives"){
	using namespace saw;

	data<sch::Int32Array,encode::NativeRaw> prim{4u};
	prim.at(0u).set(0);

	auto a = prim.at(0u);
	auto b = prim.at(1u);
	auto c = prim.at(2u);
	auto d = prim.at(3u);

	a.set(5);
	b.set(6);

	// Check if it's a reference being manipulated
	SAW_EXPECT(a.get() == 5, "'a' has unexpected value.");
	SAW_EXPECT(b.get() == 6, "'b' has unexpected value.");
	
	auto b1 = prim.at(1u);
	b1.set(10);
	c.set(-9);

	SAW_EXPECT(b1.get() == 10, "'b1' has unexpected value.");
	SAW_EXPECT(a.get() == 5, "'a' has unexpected value.");
	SAW_EXPECT(b.get() == 10, "'b' has unexpected value.");
	SAW_EXPECT(c.get() == -9, "'c' has unexpected value.");
	SAW_EXPECT(d.get() == 23, "'d' has unexpected value.");
}

}