From 73fac05aa07a0dd16f7061baddd4b934c7855fed Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 10 Jun 2023 23:45:17 +0200 Subject: c++: Setting up testing progress --- tests/.nix/derivation.nix | 2 ++ tests/SConstruct | 2 +- tests/codec-json.cpp | 22 ++++++++++++++++++++++ tests/core.cpp | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/codec-json.cpp (limited to 'tests') 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 +#include + +namespace { +SAW_TEST("Int32 write"){ + using namespace saw; + data native_int; + data json_int; + + native_int.set(44123); + + codec json_codec; + + error_or 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 namespace { -SAW_TEST { +SAW_TEST("Test") { } } -- cgit v1.2.3