summaryrefslogtreecommitdiff
path: root/modules/codec/tests/csv.cpp
blob: 507d4cb681032b16c5b14e1e1c2a0643db0d8efe (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
43
44
45
46
47
48
49
50
#include <forstio/test/suite.h>
#include "../c++/data.h"
#include "../c++/csv.h"

#include <iostream>

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

using ZeroDimArray = Array<Int32,0>;
using OneDimArray = Array<Int32,1>;
using TwoDimArray = Array<Int32,2>;
using ThreeDimArray = Array<Int32,3>;

using TestStruct = Struct<
	Member<String, "string">,
	Member<UInt64, "number">
>;

using TestUnion = Union<
	Member<TwoDimArray, "two_dim_array">,
	Member<UInt64, "number">
>;

using TestTuple = Tuple<
	TwoDimArray,
	UInt64
>;

using TestInt32Pair = Tuple<
	Int32,
	Int32
>;

SAW_TEST("Codec Csv Encode Basic"){
	using namespace saw;

	data <TestStruct, encode::Native> native_data;
	native_data.template get<"string">().set("foo");
	native_data.template get<"number">().set(140u);

	data <TestStruct, encode::Csv> csv_data;
	codec<TestStruct, encode::Csv> csv_codec;

	auto eov = csv_codec.encode(native_data, csv_data);
	SAW_EXPECT(eov.is_value(), "Couldn't encode data");
}
}
}