summaryrefslogtreecommitdiff
path: root/modules/lang/tests/c_transfer.cpp
diff options
context:
space:
mode:
authorClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-12 17:30:21 +0200
committerClaudius 'keldu' Holeksa <mail@keldu.de>2024-09-12 17:30:21 +0200
commit18bf2f08ee86fd1ed0a663d256e1c7d3142827d7 (patch)
treea8c0aca4dc1439ccfc6b746cafbb087f84a3e9bd /modules/lang/tests/c_transfer.cpp
parent2e3efd182c00eb12305644d855a2f19594a0627d (diff)
lang module separating from tools
Diffstat (limited to 'modules/lang/tests/c_transfer.cpp')
-rw-r--r--modules/lang/tests/c_transfer.cpp132
1 files changed, 132 insertions, 0 deletions
diff --git a/modules/lang/tests/c_transfer.cpp b/modules/lang/tests/c_transfer.cpp
new file mode 100644
index 0000000..43c4a3e
--- /dev/null
+++ b/modules/lang/tests/c_transfer.cpp
@@ -0,0 +1,132 @@
+#include <forstio/test/suite.hpp>
+#include <forstio/codec/json/json.hpp>
+
+#include "../c++/c_transfer.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">,
+ Member<UInt64, "un_int_num">
+>;
+
+using TestStructMore = Struct<
+ Member<Int64, "int">,
+ Member<UInt16, "uint">,
+ Member<Float32, "float">,
+ Member<Float64, "double">
+>;
+
+/*
+using TestEmptyInterface = Interface<>;
+
+using TestOneFunctionInterface = Interface<
+ Member<Function<Int32, Int32>, "one">
+>;
+
+using TestStructFunctionInterface = Interface<
+ Member<Function<TestStruct, Int32>, "two">
+>;
+
+using TestArrayFunctionInterface = Interface<
+ Member<Function<TestArray, Int32>, "three">
+>;
+
+using TestStructArrayFunctionInterface = Interface<
+ Member<Function<TestStructArray, Int32>, "three">
+>;
+
+using TestMultiFunctionInterface = Interface<
+ Member<Function<TestArray, Float32>, "foo">,
+ Member<Function<Float64, Int8>, "bar">,
+ Member<Function<UInt32, TestArray>, "baz">,
+ Member<Function<UInt32, Float64>, "banana">,
+ Member<Function<TestStructMore, Float32>, "struct">
+>;
+*/
+}
+
+/*
+template<typename Schema>
+void test_generate(std::string& res, std::string& src){
+ using namespace saw;
+
+ ring_buffer r_buff{4u * 1024u * 1024u};
+ ring_buffer r_src_buff{4u * 1024u * 1024u};
+
+ {
+ auto eov = language_binding<Schema, encode::NativeRaw, binding::SyncC>::generate(r_buff, r_src_buff, {"prefix"});
+ 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);
+ src = convert_to_string(r_src_buff);
+}
+*/
+
+/*
+SAW_TEST("CIface Empty Interface"){
+ using namespace saw;
+
+ std::string res;
+ std::string src;
+ test_generate<schema::TestEmptyInterface>(res,src);
+
+ std::cout<<"\n"<<res<<"\n"<<std::endl;
+ std::cout<<"\nSource\n"<<src<<"\n"<<std::endl;
+}
+
+SAW_TEST("CIface One Function Interface"){
+ using namespace saw;
+
+ std::string res;
+ std::string src;
+ test_generate<schema::TestOneFunctionInterface>(res, src);
+ std::cout<<"\n"<<res<<"\n"<<std::endl;
+ std::cout<<"\nSource\n"<<src<<"\n"<<std::endl;
+}
+
+SAW_TEST("CIface Multi Function Interface"){
+ using namespace saw;
+
+ std::string res;
+ std::string src;
+ test_generate<schema::TestMultiFunctionInterface>(res, src);
+ std::cout<<"\n"<<res<<"\n"<<std::endl;
+ std::cout<<"\nSource\n"<<src<<"\n"<<std::endl;
+}
+
+SAW_TEST("CIface Array Function Interface"){
+ using namespace saw;
+
+ std::string res;
+ std::string src;
+ test_generate<schema::TestArrayFunctionInterface>(res, src);
+ std::cout<<"\n"<<res<<"\n"<<std::endl;
+ std::cout<<"\nSource\n"<<src<<"\n"<<std::endl;
+}
+
+SAW_TEST("CIface Struct Array Function Interface"){
+ using namespace saw;
+
+ std::string res;
+ std::string src;
+ test_generate<schema::TestStructArrayFunctionInterface>(res, src);
+ std::cout<<"\n"<<res<<"\n"<<std::endl;
+ std::cout<<"\nSource\n"<<src<<"\n"<<std::endl;
+}
+*/
+}