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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include <forstio/test/suite.hpp>
#include <forstio/codec/json/json.hpp>
#include "../c++/c_gen_iface.hpp"
#include <iostream>
namespace {
namespace schema {
using namespace saw::schema;
using TestStruct = Struct<
Member<Int32, "a">,
Member<Float64, "b">
>;
using TestArray = Array<
Int64, 1
>;
using TestStructArray = Struct<
Member<TestArray, "array">
>;
using TestEmptyInterface = Interface<>;
using TestOneFunctionInterface = Interface<
Member<Function<Int32, Int32>, "one">
>;
using TestStructFunctionInterface = Interface<
Member<Function<TestStruct, Int32>, "two">
>;
using TestArrayFunctionInterface = Interface<
Member<Function<TestStructArray, Int32>, "three">
>;
}
template<typename Schema>
void test_generate(std::string& res){
using namespace saw;
ring_buffer r_buff{4u * 1024u * 1024u};
{
auto eov = language_binding<Schema, binding::C>::generate(r_buff, {"kel"});
SAW_EXPECT(eov.is_value(), std::string{"Couldn't generate interface info: "} + std::string{eov.get_error().get_message()});
}
res = convert_to_string(r_buff);
}
SAW_TEST("CIface Empty Interface"){
using namespace saw;
std::string res;
test_generate<schema::TestEmptyInterface>(res);
std::cout<<"\n"<<res<<"\n"<<std::endl;
}
SAW_TEST("CIface One Function Interface"){
using namespace saw;
std::string res;
test_generate<schema::TestOneFunctionInterface>(res);
std::cout<<"\n"<<res<<"\n"<<std::endl;
}
/*
SAW_TEST("CIface Struct Function Interface"){
using namespace saw;
std::string res;
test_generate<schema::TestStructFunctionInterface>(res);
std::cout<<"\n"<<res<<"\n"<<std::endl;
}
SAW_TEST("CIface Array Function Interface"){
using namespace saw;
std::string res;
test_generate<schema::TestArrayFunctionInterface>(res);
std::cout<<"\n"<<res<<"\n"<<std::endl;
}
*/
}
|