diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.nix/derivation.nix | 2 | ||||
-rw-r--r-- | tests/SConstruct | 2 | ||||
-rw-r--r-- | tests/codec-json.cpp | 22 | ||||
-rw-r--r-- | tests/core.cpp | 2 |
4 files changed, 26 insertions, 2 deletions
diff --git a/tests/.nix/derivation.nix b/tests/.nix/derivation.nix index d5a698c..e6a109a 100644 --- a/tests/.nix/derivation.nix +++ b/tests/.nix/derivation.nix @@ -21,6 +21,8 @@ stdenvNoCC.mkDerivation { forstio.core forstio.async forstio.test + forstio.codec + forstio.codec-json ]; outputs = ["out" "dev"]; diff --git a/tests/SConstruct b/tests/SConstruct index 98eccdb..4434d20 100644 --- a/tests/SConstruct +++ b/tests/SConstruct @@ -46,7 +46,7 @@ env_vars.Add('prefix', env=Environment(ENV=os.environ, variables=env_vars, CPPPATH=[], CPPDEFINES=['SAW_UNIX'], CXXFLAGS=['-std=c++20','-g','-Wall','-Wextra'], - LIBS=['forstio-core', 'forstio-async']) + LIBS=['forstio-core', 'forstio-async', 'forstio-test']) env.__class__.add_source_files = add_kel_source_files env.Tool('compilation_db'); env.cdb = env.CompilationDatabase('compile_commands.json'); diff --git a/tests/codec-json.cpp b/tests/codec-json.cpp new file mode 100644 index 0000000..d82db14 --- /dev/null +++ b/tests/codec-json.cpp @@ -0,0 +1,22 @@ +#include <forstio/test/suite.h> +#include <forstio/codec/json/json.h> + +namespace { +SAW_TEST("Int32 write"){ + using namespace saw; + data<schema::Int32, encode::Native> native_int; + data<schema::Int32, encode::Json> json_int; + + native_int.set(44123); + + codec<schema::Int32, encode::Json> json_codec; + + error_or<void> eov = json_codec.encode(native_int, json_int); + SAW_EXPECT(eov.is_value(), "Encoding error"); + + std::string_view str_view = "44123"; + for(std::size_t i = 0; i < str_view.size(); ++i){ + SAW_EXPECT( json_int.at(i) == str_view[i], "Value is not being encoded correctly" ); + } +} +} diff --git a/tests/core.cpp b/tests/core.cpp index af19b42..0ddfcd6 100644 --- a/tests/core.cpp +++ b/tests/core.cpp @@ -1,7 +1,7 @@ #include <forstio/test/suite.h> namespace { -SAW_TEST { +SAW_TEST("Test") { } } |