From 1f54ebabfd26e48b8a9fc90222a842bfe34be052 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 9 Feb 2024 17:06:57 -0400 Subject: [PATCH] Group encoding/decoding source code into `src/runtime` Signed-off-by: Juan Cruz Viotti --- CMakeLists.txt | 6 ++-- src/cli/CMakeLists.txt | 3 +- src/cli/command_decode.cc | 2 +- src/cli/command_encode.cc | 2 +- src/decoder/CMakeLists.txt | 16 ---------- src/encoder/CMakeLists.txt | 16 ---------- .../sourcemeta/jsonbinpack/encoder_varint.h | 30 ------------------- src/encoding/CMakeLists.txt | 14 --------- src/numeric/CMakeLists.txt | 8 ----- src/parser/CMakeLists.txt | 2 +- .../include/sourcemeta/jsonbinpack/parser.h | 2 +- src/parser/v1_any.h | 2 +- src/parser/v1_array.h | 3 +- src/parser/v1_enum.h | 2 +- src/parser/v1_integer.h | 2 +- src/parser/v1_number.h | 2 +- src/parser/v1_string.h | 2 +- src/runtime/CMakeLists.txt | 25 ++++++++++++++++ .../include/sourcemeta/jsonbinpack/runtime.h | 8 +++++ .../sourcemeta/jsonbinpack/runtime_decoder.h} | 15 +++++----- .../jsonbinpack/runtime_decoder_basic.h} | 14 ++++----- .../jsonbinpack/runtime_decoder_zigzag.h} | 4 +-- .../sourcemeta/jsonbinpack/runtime_encoder.h} | 17 ++++++----- .../jsonbinpack/runtime_encoder_basic.h} | 14 ++++----- .../jsonbinpack/runtime_encoder_context.h} | 4 +-- .../jsonbinpack/runtime_encoder_real.h} | 4 +-- .../jsonbinpack/runtime_encoder_zigzag.h} | 4 +-- .../jsonbinpack/runtime_encoding.h} | 4 +-- .../jsonbinpack/runtime_encoding_tag.h} | 6 ++-- .../jsonbinpack/runtime_encoding_wrap.h} | 9 ++---- .../sourcemeta/jsonbinpack/runtime_numeric.h} | 4 +-- .../sourcemeta/jsonbinpack/runtime_varint.h} | 28 ++++++++++++++--- test/decoder/CMakeLists.txt | 2 +- test/decoder/decode_any_test.cc | 2 +- test/decoder/decode_array_test.cc | 3 +- test/decoder/decode_enum_test.cc | 2 +- test/decoder/decode_integer_test.cc | 2 +- test/decoder/decode_number_test.cc | 2 +- test/decoder/decode_object_test.cc | 3 +- test/decoder/decode_string_test.cc | 2 +- test/decoder/decode_test.cc | 2 +- test/decoder/decode_traits_test.cc | 2 +- test/decoder/decode_varint_test.cc | 14 ++++----- test/decoder/decode_zigzag_test.cc | 2 +- test/e2e/CMakeLists.txt | 5 ++-- test/e2e/runner.cc | 3 +- test/encoder/CMakeLists.txt | 2 +- test/encoder/encode_any_test.cc | 2 +- test/encoder/encode_array_test.cc | 3 +- test/encoder/encode_context_test.cc | 2 +- test/encoder/encode_enum_test.cc | 2 +- test/encoder/encode_integer_test.cc | 2 +- test/encoder/encode_number_test.cc | 2 +- test/encoder/encode_object_test.cc | 3 +- test/encoder/encode_real_test.cc | 2 +- test/encoder/encode_string_test.cc | 2 +- test/encoder/encode_test.cc | 2 +- test/encoder/encode_traits_test.cc | 2 +- test/encoder/encode_varint_test.cc | 14 ++++----- test/encoder/encode_zigzag_test.cc | 2 +- test/encoding/CMakeLists.txt | 2 +- test/encoding/encoding_traits_test.cc | 2 +- test/encoding/encoding_wrap_test.cc | 3 +- test/numeric/CMakeLists.txt | 2 +- .../numeric_closest_smallest_exponent_test.cc | 3 +- test/numeric/numeric_divide_ceil_test.cc | 5 ++-- test/numeric/numeric_divide_floor_test.cc | 5 ++-- test/numeric/numeric_uint_max_test.cc | 7 +++-- test/parser/CMakeLists.txt | 2 +- 69 files changed, 176 insertions(+), 217 deletions(-) delete mode 100644 src/decoder/CMakeLists.txt delete mode 100644 src/encoder/CMakeLists.txt delete mode 100644 src/encoder/include/sourcemeta/jsonbinpack/encoder_varint.h delete mode 100644 src/encoding/CMakeLists.txt delete mode 100644 src/numeric/CMakeLists.txt create mode 100644 src/runtime/CMakeLists.txt create mode 100644 src/runtime/include/sourcemeta/jsonbinpack/runtime.h rename src/{decoder/include/sourcemeta/jsonbinpack/decoder.h => runtime/include/sourcemeta/jsonbinpack/runtime_decoder.h} (98%) rename src/{decoder/include/sourcemeta/jsonbinpack/decoder_basic.h => runtime/include/sourcemeta/jsonbinpack/runtime_decoder_basic.h} (88%) rename src/{decoder/include/sourcemeta/jsonbinpack/decoder_zigzag.h => runtime/include/sourcemeta/jsonbinpack/runtime_decoder_zigzag.h} (74%) rename src/{encoder/include/sourcemeta/jsonbinpack/encoder.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoder.h} (98%) rename src/{encoder/include/sourcemeta/jsonbinpack/encoder_basic.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoder_basic.h} (84%) rename src/{encoder/include/sourcemeta/jsonbinpack/encoder_context.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoder_context.h} (96%) rename src/{encoder/include/sourcemeta/jsonbinpack/encoder_real.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoder_real.h} (93%) rename src/{encoder/include/sourcemeta/jsonbinpack/encoder_zigzag.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoder_zigzag.h} (75%) rename src/{encoding/include/sourcemeta/jsonbinpack/encoding.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoding.h} (99%) rename src/{encoding/include/sourcemeta/jsonbinpack/encoding_tag.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoding_tag.h} (94%) rename src/{encoding/include/sourcemeta/jsonbinpack/encoding_wrap.h => runtime/include/sourcemeta/jsonbinpack/runtime_encoding_wrap.h} (86%) rename src/{numeric/include/sourcemeta/jsonbinpack/numeric.h => runtime/include/sourcemeta/jsonbinpack/runtime_numeric.h} (96%) rename src/{decoder/include/sourcemeta/jsonbinpack/decoder_varint.h => runtime/include/sourcemeta/jsonbinpack/runtime_varint.h} (51%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6074cc76..1e85be144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,10 +25,7 @@ find_package(JSONToolkit REQUIRED) # Runtime if(JSONBINPACK_RUNTIME OR JSONBINPACK_CLI OR JSONBINPACK_COMPILER) - add_subdirectory(src/numeric) - add_subdirectory(src/encoding) - add_subdirectory(src/encoder) - add_subdirectory(src/decoder) + add_subdirectory(src/runtime) endif() # Compiler @@ -67,6 +64,7 @@ if(JSONBINPACK_TESTS) enable_testing() if(JSONBINPACK_RUNTIME OR JSONBINPACK_CLI OR JSONBINPACK_COMPILER) + # TODO: Group into a single runtime test module add_subdirectory(test/numeric) add_subdirectory(test/encoding) add_subdirectory(test/encoder) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 5a1085745..900570724 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -8,8 +8,7 @@ target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::mapper) target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::parser) target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::schemas) -target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::encoder) -target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::decoder) +target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::runtime) target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsontoolkit::json) target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsontoolkit::jsonschema) diff --git a/src/cli/command_decode.cc b/src/cli/command_decode.cc index 4eaf845ec..f991ba011 100644 --- a/src/cli/command_decode.cc +++ b/src/cli/command_decode.cc @@ -3,9 +3,9 @@ #include "resolver.h" #include -#include #include #include +#include #include #include diff --git a/src/cli/command_encode.cc b/src/cli/command_encode.cc index d05151efa..222366ef8 100644 --- a/src/cli/command_encode.cc +++ b/src/cli/command_encode.cc @@ -3,9 +3,9 @@ #include "resolver.h" #include -#include #include #include +#include #include #include diff --git a/src/decoder/CMakeLists.txt b/src/decoder/CMakeLists.txt deleted file mode 100644 index c5549899f..000000000 --- a/src/decoder/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME decoder - FOLDER "JSON BinPack/Decoder" - PRIVATE_HEADERS varint.h zigzag.h basic.h) - -if(JSONBINPACK_INSTALL) - noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME decoder) -endif() - -sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_decoder) - -target_link_libraries(sourcemeta_jsonbinpack_decoder INTERFACE - sourcemeta::jsontoolkit::json) -target_link_libraries(sourcemeta_jsonbinpack_decoder INTERFACE - sourcemeta::jsonbinpack::numeric) -target_link_libraries(sourcemeta_jsonbinpack_decoder INTERFACE - sourcemeta::jsonbinpack::encoding) diff --git a/src/encoder/CMakeLists.txt b/src/encoder/CMakeLists.txt deleted file mode 100644 index a63f18e32..000000000 --- a/src/encoder/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME encoder - FOLDER "JSON BinPack/Encoder" - PRIVATE_HEADERS varint.h zigzag.h real.h basic.h context.h) - -if(JSONBINPACK_INSTALL) - noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME encoder) -endif() - -sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_encoder) - -target_link_libraries(sourcemeta_jsonbinpack_encoder INTERFACE - sourcemeta::jsontoolkit::json) -target_link_libraries(sourcemeta_jsonbinpack_encoder INTERFACE - sourcemeta::jsonbinpack::numeric) -target_link_libraries(sourcemeta_jsonbinpack_encoder INTERFACE - sourcemeta::jsonbinpack::encoding) diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder_varint.h b/src/encoder/include/sourcemeta/jsonbinpack/encoder_varint.h deleted file mode 100644 index 3aa620f70..000000000 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder_varint.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_VARINT_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_VARINT_H_ - -#include // std::uint8_t, std::uint64_t -#include // std::basic_ostream - -namespace sourcemeta::jsonbinpack::encoder { - -// This encoder does not handle negative integers. Use ZigZag first instead. -template -auto varint(std::basic_ostream &stream, - const std::uint64_t value) -> std::basic_ostream & { - constexpr std::uint8_t LEAST_SIGNIFICANT_BITS{0b01111111}; - constexpr std::uint8_t MOST_SIGNIFICANT_BIT{0b10000000}; - constexpr std::uint8_t SHIFT{7}; - std::uint64_t accumulator = value; - - while (accumulator > LEAST_SIGNIFICANT_BITS) { - stream.put(static_cast( - (accumulator & LEAST_SIGNIFICANT_BITS) | MOST_SIGNIFICANT_BIT)); - accumulator >>= SHIFT; - } - - stream.put(static_cast(accumulator)); - return stream; -} - -} // namespace sourcemeta::jsonbinpack::encoder - -#endif diff --git a/src/encoding/CMakeLists.txt b/src/encoding/CMakeLists.txt deleted file mode 100644 index f6084445a..000000000 --- a/src/encoding/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME encoding - FOLDER "JSON BinPack/Encoding" - PRIVATE_HEADERS tag.h wrap.h) - -if(JSONBINPACK_INSTALL) - noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME encoding) -endif() - -sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_encoding) - -target_link_libraries(sourcemeta_jsonbinpack_encoding INTERFACE - sourcemeta::jsontoolkit::json) -target_link_libraries(sourcemeta_jsonbinpack_encoding INTERFACE - sourcemeta::jsonbinpack::numeric) diff --git a/src/numeric/CMakeLists.txt b/src/numeric/CMakeLists.txt deleted file mode 100644 index f97cc4e39..000000000 --- a/src/numeric/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME numeric - FOLDER "JSON BinPack/Numeric") - -if(JSONBINPACK_INSTALL) - noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME numeric) -endif() - -sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_numeric) diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt index f0699eb40..04ca89428 100644 --- a/src/parser/CMakeLists.txt +++ b/src/parser/CMakeLists.txt @@ -11,4 +11,4 @@ sourcemeta_jsonbinpack_add_compile_options(PRIVATE sourcemeta_jsonbinpack_parser target_link_libraries(sourcemeta_jsonbinpack_parser PUBLIC sourcemeta::jsontoolkit::json) target_link_libraries(sourcemeta_jsonbinpack_parser PRIVATE - sourcemeta::jsonbinpack::encoding) + sourcemeta::jsonbinpack::runtime) diff --git a/src/parser/include/sourcemeta/jsonbinpack/parser.h b/src/parser/include/sourcemeta/jsonbinpack/parser.h index eb6a29210..50a225fca 100644 --- a/src/parser/include/sourcemeta/jsonbinpack/parser.h +++ b/src/parser/include/sourcemeta/jsonbinpack/parser.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_H_ #define SOURCEMETA_JSONBINPACK_PARSER_H_ -#include +#include #include namespace sourcemeta::jsonbinpack { diff --git a/src/parser/v1_any.h b/src/parser/v1_any.h index c5cff435a..a5840683e 100644 --- a/src/parser/v1_any.h +++ b/src/parser/v1_any.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ANY_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_ANY_H_ -#include +#include #include namespace sourcemeta::jsonbinpack::parser::v1 { diff --git a/src/parser/v1_array.h b/src/parser/v1_array.h index 16dce36f3..d3d0c7d17 100644 --- a/src/parser/v1_array.h +++ b/src/parser/v1_array.h @@ -1,9 +1,8 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ARRAY_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_ARRAY_H_ -#include -#include #include +#include #include #include // std::transform diff --git a/src/parser/v1_enum.h b/src/parser/v1_enum.h index 35dec3a3f..213ac73f7 100644 --- a/src/parser/v1_enum.h +++ b/src/parser/v1_enum.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ENUM_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_ENUM_H_ -#include +#include #include #include // assert diff --git a/src/parser/v1_integer.h b/src/parser/v1_integer.h index 72b15c0b0..0ed29ac75 100644 --- a/src/parser/v1_integer.h +++ b/src/parser/v1_integer.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_INTEGER_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_INTEGER_H_ -#include +#include #include #include // assert diff --git a/src/parser/v1_number.h b/src/parser/v1_number.h index 20fee6852..acaa76c68 100644 --- a/src/parser/v1_number.h +++ b/src/parser/v1_number.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_NUMBER_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_NUMBER_H_ -#include +#include #include namespace sourcemeta::jsonbinpack::parser::v1 { diff --git a/src/parser/v1_string.h b/src/parser/v1_string.h index 562681766..930eb5636 100644 --- a/src/parser/v1_string.h +++ b/src/parser/v1_string.h @@ -1,7 +1,7 @@ #ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_STRING_H_ #define SOURCEMETA_JSONBINPACK_PARSER_V1_STRING_H_ -#include +#include #include #include // assert diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt new file mode 100644 index 000000000..303bfb2a2 --- /dev/null +++ b/src/runtime/CMakeLists.txt @@ -0,0 +1,25 @@ +noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime + FOLDER "JSON BinPack/Runtime" + PRIVATE_HEADERS + decoder.h + decoder_basic.h + decoder_zigzag.h + encoder.h + encoder_basic.h + encoder_context.h + encoder_real.h + encoder_zigzag.h + encoding.h + encoding_tag.h + encoding_wrap.h + varint.h + numeric.h) + +if(JSONBINPACK_INSTALL) + noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime) +endif() + +sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_runtime) + +target_link_libraries(sourcemeta_jsonbinpack_runtime INTERFACE + sourcemeta::jsontoolkit::json) diff --git a/src/runtime/include/sourcemeta/jsonbinpack/runtime.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime.h new file mode 100644 index 000000000..dc171d259 --- /dev/null +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime.h @@ -0,0 +1,8 @@ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_H_ + +#include +#include +#include + +#endif diff --git a/src/decoder/include/sourcemeta/jsonbinpack/decoder.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder.h similarity index 98% rename from src/decoder/include/sourcemeta/jsonbinpack/decoder.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder.h index 2e82f50b3..f64630565 100644 --- a/src/decoder/include/sourcemeta/jsonbinpack/decoder.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder.h @@ -1,15 +1,16 @@ -#ifndef SOURCEMETA_JSONBINPACK_DECODER_H_ -#define SOURCEMETA_JSONBINPACK_DECODER_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_H_ /// @defgroup decoder Decoder /// @brief A set of procedures to deserialize a bit-string given a Encoding /// Schema -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + #include #include // assert diff --git a/src/decoder/include/sourcemeta/jsonbinpack/decoder_basic.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_basic.h similarity index 88% rename from src/decoder/include/sourcemeta/jsonbinpack/decoder_basic.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_basic.h index 929f38a0a..e64ce7468 100644 --- a/src/decoder/include/sourcemeta/jsonbinpack/decoder_basic.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_basic.h @@ -1,8 +1,8 @@ -#ifndef SOURCEMETA_JSONBINPACK_DECODER_BASIC_H_ -#define SOURCEMETA_JSONBINPACK_DECODER_BASIC_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_BASIC_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_BASIC_H_ -#include -#include +#include +#include #include // assert #include // std::ceil @@ -55,12 +55,10 @@ template class BasicDecoder { return word; } - inline auto get_varint() -> std::uint64_t { - return decoder::varint(this->stream); - } + inline auto get_varint() -> std::uint64_t { return varint(this->stream); } inline auto get_varint_zigzag() -> std::int64_t { - const std::uint64_t value = decoder::varint(this->stream); + const std::uint64_t value = varint(this->stream); return decoder::zigzag(value); } diff --git a/src/decoder/include/sourcemeta/jsonbinpack/decoder_zigzag.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_zigzag.h similarity index 74% rename from src/decoder/include/sourcemeta/jsonbinpack/decoder_zigzag.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_zigzag.h index 22dedde56..f7b112974 100644 --- a/src/decoder/include/sourcemeta/jsonbinpack/decoder_zigzag.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_decoder_zigzag.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_DECODER_ZIGZAG_H_ -#define SOURCEMETA_JSONBINPACK_DECODER_ZIGZAG_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_ZIGZAG_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_ZIGZAG_H_ #include // std::uint64_t, std::int64_t diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder.h similarity index 98% rename from src/encoder/include/sourcemeta/jsonbinpack/encoder.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder.h index 6d53a64f5..582f54d91 100644 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder.h @@ -1,16 +1,17 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_H_ /// @defgroup encoder Encoder /// @brief A set of procedures to serialize a JSON document given a Encoding /// Schema -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #include #include // std::abs diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder_basic.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_basic.h similarity index 84% rename from src/encoder/include/sourcemeta/jsonbinpack/encoder_basic.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_basic.h index 8f6684959..f507128db 100644 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder_basic.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_basic.h @@ -1,9 +1,9 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_BASIC_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_BASIC_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_BASIC_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_BASIC_H_ -#include -#include -#include +#include +#include +#include #include // std::find_if #include // assert @@ -40,11 +40,11 @@ template class BasicEncoder { } inline auto put_varint(const std::uint64_t value) -> void { - encoder::varint(this->stream, value); + varint(this->stream, value); } inline auto put_varint_zigzag(const std::int64_t value) -> void { - encoder::varint(this->stream, encoder::zigzag(value)); + varint(this->stream, encoder::zigzag(value)); } inline auto put_string_utf8(const std::basic_string &string, diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder_context.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_context.h similarity index 96% rename from src/encoder/include/sourcemeta/jsonbinpack/encoder_context.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_context.h index f9773c7df..a570d8c26 100644 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder_context.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_context.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_CONTEXT_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_CONTEXT_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_CONTEXT_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_CONTEXT_H_ #include // assert #include // std::cbegin, std::cend diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder_real.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_real.h similarity index 93% rename from src/encoder/include/sourcemeta/jsonbinpack/encoder_real.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_real.h index 023f8301d..c4a2c5cf6 100644 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder_real.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_real.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_REAL_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_REAL_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_REAL_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_REAL_H_ #include // assert #include // std::modf, std::floor, std::isfinite diff --git a/src/encoder/include/sourcemeta/jsonbinpack/encoder_zigzag.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_zigzag.h similarity index 75% rename from src/encoder/include/sourcemeta/jsonbinpack/encoder_zigzag.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_zigzag.h index 4a7172595..749803ed4 100644 --- a/src/encoder/include/sourcemeta/jsonbinpack/encoder_zigzag.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoder_zigzag.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODER_ZIGZAG_H_ -#define SOURCEMETA_JSONBINPACK_ENCODER_ZIGZAG_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_ZIGZAG_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_ZIGZAG_H_ #include // std::abs #include // std::uint64_t, std::int64_t diff --git a/src/encoding/include/sourcemeta/jsonbinpack/encoding.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding.h similarity index 99% rename from src/encoding/include/sourcemeta/jsonbinpack/encoding.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding.h index fb4a3856a..c86c5383e 100644 --- a/src/encoding/include/sourcemeta/jsonbinpack/encoding.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODING_H_ -#define SOURCEMETA_JSONBINPACK_ENCODING_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_H_ /// @defgroup encoding Encodings /// diff --git a/src/encoding/include/sourcemeta/jsonbinpack/encoding_tag.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_tag.h similarity index 94% rename from src/encoding/include/sourcemeta/jsonbinpack/encoding_tag.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_tag.h index 5a78c1021..a237c605a 100644 --- a/src/encoding/include/sourcemeta/jsonbinpack/encoding_tag.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_tag.h @@ -1,7 +1,7 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODING_TAG_H_ -#define SOURCEMETA_JSONBINPACK_ENCODING_TAG_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_TAG_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_TAG_H_ -#include +#include namespace sourcemeta::jsonbinpack::tag { diff --git a/src/encoding/include/sourcemeta/jsonbinpack/encoding_wrap.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_wrap.h similarity index 86% rename from src/encoding/include/sourcemeta/jsonbinpack/encoding_wrap.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_wrap.h index 228ed40f1..9829a03bf 100644 --- a/src/encoding/include/sourcemeta/jsonbinpack/encoding_wrap.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_encoding_wrap.h @@ -1,10 +1,7 @@ -#ifndef SOURCEMETA_JSONBINPACK_ENCODING_WRAP_H_ -#define SOURCEMETA_JSONBINPACK_ENCODING_WRAP_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_WRAP_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODING_WRAP_H_ -// TODO: Do not compile this file as part of the runtime. It logically belongs -// to the compiler - -#include +#include #include // std::transform #include // std::initializer_list diff --git a/src/numeric/include/sourcemeta/jsonbinpack/numeric.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_numeric.h similarity index 96% rename from src/numeric/include/sourcemeta/jsonbinpack/numeric.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_numeric.h index 2f17e2aab..9de3fcbab 100644 --- a/src/numeric/include/sourcemeta/jsonbinpack/numeric.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_numeric.h @@ -1,5 +1,5 @@ -#ifndef SOURCEMETA_JSONBINPACK_NUMERIC_H_ -#define SOURCEMETA_JSONBINPACK_NUMERIC_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_NUMERIC_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_NUMERIC_H_ #include // assert #include // std::abs diff --git a/src/decoder/include/sourcemeta/jsonbinpack/decoder_varint.h b/src/runtime/include/sourcemeta/jsonbinpack/runtime_varint.h similarity index 51% rename from src/decoder/include/sourcemeta/jsonbinpack/decoder_varint.h rename to src/runtime/include/sourcemeta/jsonbinpack/runtime_varint.h index 14d70f1e4..a80351af2 100644 --- a/src/decoder/include/sourcemeta/jsonbinpack/decoder_varint.h +++ b/src/runtime/include/sourcemeta/jsonbinpack/runtime_varint.h @@ -1,11 +1,31 @@ -#ifndef SOURCEMETA_JSONBINPACK_DECODER_VARINT_H_ -#define SOURCEMETA_JSONBINPACK_DECODER_VARINT_H_ +#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_VARINT_H_ +#define SOURCEMETA_JSONBINPACK_RUNTIME_VARINT_H_ #include // assert #include // std::uint8_t, std::uint64_t #include // std::basic_istream +#include // std::basic_ostream -namespace sourcemeta::jsonbinpack::decoder { +namespace sourcemeta::jsonbinpack { + +// This encoder does not handle negative integers. Use ZigZag first instead. +template +auto varint(std::basic_ostream &stream, + const std::uint64_t value) -> std::basic_ostream & { + constexpr std::uint8_t LEAST_SIGNIFICANT_BITS{0b01111111}; + constexpr std::uint8_t MOST_SIGNIFICANT_BIT{0b10000000}; + constexpr std::uint8_t SHIFT{7}; + std::uint64_t accumulator = value; + + while (accumulator > LEAST_SIGNIFICANT_BITS) { + stream.put(static_cast( + (accumulator & LEAST_SIGNIFICANT_BITS) | MOST_SIGNIFICANT_BIT)); + accumulator >>= SHIFT; + } + + stream.put(static_cast(accumulator)); + return stream; +} template auto varint(std::basic_istream &stream) -> std::uint64_t { @@ -34,6 +54,6 @@ auto varint(std::basic_istream &stream) -> std::uint64_t { return result; } -} // namespace sourcemeta::jsonbinpack::decoder +} // namespace sourcemeta::jsonbinpack #endif diff --git a/test/decoder/CMakeLists.txt b/test/decoder/CMakeLists.txt index 8867bc077..071b5aae9 100644 --- a/test/decoder/CMakeLists.txt +++ b/test/decoder/CMakeLists.txt @@ -18,7 +18,7 @@ sourcemeta_jsonbinpack_add_compile_options( target_link_libraries(sourcemeta_jsonbinpack_decoder_unit PRIVATE GTest::gtest GTest::gtest_main) target_link_libraries(sourcemeta_jsonbinpack_decoder_unit - PRIVATE sourcemeta::jsonbinpack::decoder) + PRIVATE sourcemeta::jsonbinpack::runtime) target_link_libraries(sourcemeta_jsonbinpack_decoder_unit PRIVATE sourcemeta::jsontoolkit::json) diff --git a/test/decoder/decode_any_test.cc b/test/decoder/decode_any_test.cc index 0511c5a11..b08c4120b 100644 --- a/test/decoder/decode_any_test.cc +++ b/test/decoder/decode_any_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include #include diff --git a/test/decoder/decode_array_test.cc b/test/decoder/decode_array_test.cc index 96762af17..d58d4d47c 100644 --- a/test/decoder/decode_array_test.cc +++ b/test/decoder/decode_array_test.cc @@ -2,8 +2,7 @@ #include "decode_utils.h" -#include -#include +#include #include #include diff --git a/test/decoder/decode_enum_test.cc b/test/decoder/decode_enum_test.cc index 5b7ef4624..a09cb1896 100644 --- a/test/decoder/decode_enum_test.cc +++ b/test/decoder/decode_enum_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include #include // std::move diff --git a/test/decoder/decode_integer_test.cc b/test/decoder/decode_integer_test.cc index 25af1261d..0fed8f262 100644 --- a/test/decoder/decode_integer_test.cc +++ b/test/decoder/decode_integer_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include #include // std::numeric_limits diff --git a/test/decoder/decode_number_test.cc b/test/decoder/decode_number_test.cc index 4922d240f..af9b9bf01 100644 --- a/test/decoder/decode_number_test.cc +++ b/test/decoder/decode_number_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include TEST(Decoder, DOUBLE_VARINT_TUPLE_5) { diff --git a/test/decoder/decode_object_test.cc b/test/decoder/decode_object_test.cc index 3adefef60..b9a422406 100644 --- a/test/decoder/decode_object_test.cc +++ b/test/decoder/decode_object_test.cc @@ -2,8 +2,7 @@ #include "decode_utils.h" -#include -#include +#include #include TEST(Decoder, FIXED_TYPED_ARBITRARY_OBJECT__no_length_string__integer) { diff --git a/test/decoder/decode_string_test.cc b/test/decoder/decode_string_test.cc index f7a2b5260..410710eca 100644 --- a/test/decoder/decode_string_test.cc +++ b/test/decoder/decode_string_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include TEST(Decoder, UTF8_STRING_NO_LENGTH_foo_bar) { diff --git a/test/decoder/decode_test.cc b/test/decoder/decode_test.cc index c33882d8a..34b7636fe 100644 --- a/test/decoder/decode_test.cc +++ b/test/decoder/decode_test.cc @@ -2,7 +2,7 @@ #include "decode_utils.h" -#include +#include #include TEST(Decoder, generic_decode_BOUNDED_MULTIPLE_8BITS_ENUM_FIXED) { diff --git a/test/decoder/decode_traits_test.cc b/test/decoder/decode_traits_test.cc index 64f1febc9..7e72b79f2 100644 --- a/test/decoder/decode_traits_test.cc +++ b/test/decoder/decode_traits_test.cc @@ -1,6 +1,6 @@ #include -#include +#include #include // std::char_traits #include diff --git a/test/decoder/decode_varint_test.cc b/test/decoder/decode_varint_test.cc index 15371b7d4..3c5a263bf 100644 --- a/test/decoder/decode_varint_test.cc +++ b/test/decoder/decode_varint_test.cc @@ -2,34 +2,34 @@ #include "decode_utils.h" -#include +#include #include #include // std::numeric_limits TEST(Decoder, varint_0x01) { InputByteStream stream{0x01}; - EXPECT_EQ(sourcemeta::jsonbinpack::decoder::varint(stream), 1); + EXPECT_EQ(sourcemeta::jsonbinpack::varint(stream), 1); } TEST(Decoder, varint_0x17) { InputByteStream stream{0x17}; - EXPECT_EQ(sourcemeta::jsonbinpack::decoder::varint(stream), 23); + EXPECT_EQ(sourcemeta::jsonbinpack::varint(stream), 23); } TEST(Decoder, varint_0xac_0x02) { InputByteStream stream{{0xac, 0x02}}; - EXPECT_EQ(sourcemeta::jsonbinpack::decoder::varint(stream), 300); + EXPECT_EQ(sourcemeta::jsonbinpack::varint(stream), 300); } TEST(Decoder, varint_0xdf_0x89_0x03) { InputByteStream stream{{0xdf, 0x89, 0x03}}; - EXPECT_EQ(sourcemeta::jsonbinpack::decoder::varint(stream), 50399); + EXPECT_EQ(sourcemeta::jsonbinpack::varint(stream), 50399); } TEST(Decoder, varint_0xfe_0xff_0xff_0xff_0x0f) { InputByteStream stream{{0xfe, 0xff, 0xff, 0xff, 0x0f}}; - const std::uint64_t result{sourcemeta::jsonbinpack::decoder::varint(stream)}; + const std::uint64_t result{sourcemeta::jsonbinpack::varint(stream)}; const std::uint64_t expected{4294967294}; EXPECT_EQ(result, expected); } @@ -39,7 +39,7 @@ TEST(Decoder, varint_uint64_max) { // (1)1111111 (1)1111111 (1)1111111 (1)1111111 (1)1111111 (0)0000001 InputByteStream stream{ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01}}; - const std::uint64_t result{sourcemeta::jsonbinpack::decoder::varint(stream)}; + const std::uint64_t result{sourcemeta::jsonbinpack::varint(stream)}; const std::uint64_t expected{18446744073709551615U}; EXPECT_EQ(result, expected); } diff --git a/test/decoder/decode_zigzag_test.cc b/test/decoder/decode_zigzag_test.cc index 69d5f59ba..7d8d886ea 100644 --- a/test/decoder/decode_zigzag_test.cc +++ b/test/decoder/decode_zigzag_test.cc @@ -1,6 +1,6 @@ #include -#include +#include #include #include // std::numeric_limits diff --git a/test/e2e/CMakeLists.txt b/test/e2e/CMakeLists.txt index 21afa1914..824cf9a79 100644 --- a/test/e2e/CMakeLists.txt +++ b/test/e2e/CMakeLists.txt @@ -3,10 +3,9 @@ target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsontoolki target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::canonicalizer) target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::mapper) target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::parser) -target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::encoder) -target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::decoder) +target_link_libraries(jsonbinpack_e2e_test_runner PRIVATE sourcemeta::jsonbinpack::runtime) set_target_properties(jsonbinpack_e2e_test_runner - PROPERTIES FOLDER "Misc") + PROPERTIES FOLDER "JSON BinPack/E2E") macro(add_jsonbinpack_e2e_test_schemaless name) add_test(NAME e2e.${name}.schema-less diff --git a/test/e2e/runner.cc b/test/e2e/runner.cc index 1f09d74a8..bc15a269e 100644 --- a/test/e2e/runner.cc +++ b/test/e2e/runner.cc @@ -1,8 +1,7 @@ #include -#include -#include #include #include +#include #include #include diff --git a/test/encoder/CMakeLists.txt b/test/encoder/CMakeLists.txt index 3020ab270..a0dcf0066 100644 --- a/test/encoder/CMakeLists.txt +++ b/test/encoder/CMakeLists.txt @@ -20,7 +20,7 @@ sourcemeta_jsonbinpack_add_compile_options( target_link_libraries(sourcemeta_jsonbinpack_encoder_unit PRIVATE GTest::gtest GTest::gtest_main) target_link_libraries(sourcemeta_jsonbinpack_encoder_unit - PRIVATE sourcemeta::jsonbinpack::encoder) + PRIVATE sourcemeta::jsonbinpack::runtime) target_link_libraries(sourcemeta_jsonbinpack_encoder_unit PRIVATE sourcemeta::jsontoolkit::json) diff --git a/test/encoder/encode_any_test.cc b/test/encoder/encode_any_test.cc index 852e9486a..b927d392d 100644 --- a/test/encoder/encode_any_test.cc +++ b/test/encoder/encode_any_test.cc @@ -3,7 +3,7 @@ #include #include "encode_utils.h" -#include +#include #include TEST(Encoder, ANY_PACKED_TYPE_TAG_BYTE_PREFIX__null) { diff --git a/test/encoder/encode_array_test.cc b/test/encoder/encode_array_test.cc index 2aeb439ea..aece3decf 100644 --- a/test/encoder/encode_array_test.cc +++ b/test/encoder/encode_array_test.cc @@ -3,8 +3,7 @@ #include #include "encode_utils.h" -#include -#include +#include #include TEST(Encoder, FIXED_TYPED_ARRAY_0_1_2__no_prefix_encodings) { diff --git a/test/encoder/encode_context_test.cc b/test/encoder/encode_context_test.cc index 2ac279b68..75f64d961 100644 --- a/test/encoder/encode_context_test.cc +++ b/test/encoder/encode_context_test.cc @@ -4,7 +4,7 @@ #include #include -#include +#include TEST(Encoder, context_record_string) { sourcemeta::jsonbinpack::encoder::Context context; diff --git a/test/encoder/encode_enum_test.cc b/test/encoder/encode_enum_test.cc index 9adb97876..6e302f42b 100644 --- a/test/encoder/encode_enum_test.cc +++ b/test/encoder/encode_enum_test.cc @@ -4,7 +4,7 @@ #include // std::vector #include "encode_utils.h" -#include +#include #include TEST(Encoder, BYTE_CHOICE_INDEX_1__1_0_0) { diff --git a/test/encoder/encode_integer_test.cc b/test/encoder/encode_integer_test.cc index a68f85749..7b47b2093 100644 --- a/test/encoder/encode_integer_test.cc +++ b/test/encoder/encode_integer_test.cc @@ -3,7 +3,7 @@ #include // std::numeric_limits #include "encode_utils.h" -#include +#include #include TEST(Encoder, BOUNDED_MULTIPLE_8BITS_ENUM_FIXED__minus_5_minus_5_minus_1_1) { diff --git a/test/encoder/encode_number_test.cc b/test/encoder/encode_number_test.cc index 11f8e8197..d0cda87f1 100644 --- a/test/encoder/encode_number_test.cc +++ b/test/encoder/encode_number_test.cc @@ -1,7 +1,7 @@ #include #include "encode_utils.h" -#include +#include #include TEST(Encoder, DOUBLE_VARINT_TUPLE_5) { diff --git a/test/encoder/encode_object_test.cc b/test/encoder/encode_object_test.cc index cb9ecd5d9..6d563e671 100644 --- a/test/encoder/encode_object_test.cc +++ b/test/encoder/encode_object_test.cc @@ -1,8 +1,7 @@ #include #include "encode_utils.h" -#include -#include +#include #include TEST(Encoder, FIXED_TYPED_ARBITRARY_OBJECT__no_length_string__integer) { diff --git a/test/encoder/encode_real_test.cc b/test/encoder/encode_real_test.cc index b4173044d..2d41b8ace 100644 --- a/test/encoder/encode_real_test.cc +++ b/test/encoder/encode_real_test.cc @@ -1,6 +1,6 @@ #include -#include +#include TEST(Encoder, real_digits_1) { const double input{3.14}; diff --git a/test/encoder/encode_string_test.cc b/test/encoder/encode_string_test.cc index bb301b65f..a1ad759e6 100644 --- a/test/encoder/encode_string_test.cc +++ b/test/encoder/encode_string_test.cc @@ -1,7 +1,7 @@ #include #include "encode_utils.h" -#include +#include #include TEST(Encoder, UTF8_STRING_NO_LENGTH_foo_bar) { diff --git a/test/encoder/encode_test.cc b/test/encoder/encode_test.cc index bd19eeda9..8aace374d 100644 --- a/test/encoder/encode_test.cc +++ b/test/encoder/encode_test.cc @@ -1,7 +1,7 @@ #include #include "encode_utils.h" -#include +#include #include TEST(Encoder, generic_encode_BOUNDED_MULTIPLE_8BITS_ENUM_FIXED) { diff --git a/test/encoder/encode_traits_test.cc b/test/encoder/encode_traits_test.cc index 037760a68..dd29978bc 100644 --- a/test/encoder/encode_traits_test.cc +++ b/test/encoder/encode_traits_test.cc @@ -3,7 +3,7 @@ #include // std::char_traits #include -#include +#include using CharT = char; using Traits = std::char_traits; diff --git a/test/encoder/encode_varint_test.cc b/test/encoder/encode_varint_test.cc index 535073267..84b6ffeb9 100644 --- a/test/encoder/encode_varint_test.cc +++ b/test/encoder/encode_varint_test.cc @@ -3,42 +3,42 @@ #include // std::numeric_limits #include "encode_utils.h" -#include +#include TEST(Encoder, varint_1) { OutputByteStream stream{}; - sourcemeta::jsonbinpack::encoder::varint(stream, 1); + sourcemeta::jsonbinpack::varint(stream, 1); EXPECT_BYTES(stream, {0x01}); } TEST(Encoder, varint_23) { OutputByteStream stream{}; - sourcemeta::jsonbinpack::encoder::varint(stream, 23); + sourcemeta::jsonbinpack::varint(stream, 23); EXPECT_BYTES(stream, {0x17}); } TEST(Encoder, varint_300) { OutputByteStream stream{}; - sourcemeta::jsonbinpack::encoder::varint(stream, 300); + sourcemeta::jsonbinpack::varint(stream, 300); EXPECT_BYTES(stream, {0xac, 0x02}); } TEST(Encoder, varint_50399) { OutputByteStream stream{}; - sourcemeta::jsonbinpack::encoder::varint(stream, 50399); + sourcemeta::jsonbinpack::varint(stream, 50399); EXPECT_BYTES(stream, {0xdf, 0x89, 0x03}); } TEST(Encoder, varint_4294967294) { OutputByteStream stream{}; - sourcemeta::jsonbinpack::encoder::varint(stream, 4294967294); + sourcemeta::jsonbinpack::varint(stream, 4294967294); EXPECT_BYTES(stream, {0xfe, 0xff, 0xff, 0xff, 0x0f}); } TEST(Encoder, varint_uint64_max) { OutputByteStream stream{}; const std::uint64_t value = std::numeric_limits::max(); - sourcemeta::jsonbinpack::encoder::varint(stream, value); + sourcemeta::jsonbinpack::varint(stream, value); // The input is 18446744073709551615 // In hex: 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff // In binary: 11111111 11111111 11111111 11111111 11111111 11111111 11111111 diff --git a/test/encoder/encode_zigzag_test.cc b/test/encoder/encode_zigzag_test.cc index 057fa46df..e90d7374d 100644 --- a/test/encoder/encode_zigzag_test.cc +++ b/test/encoder/encode_zigzag_test.cc @@ -2,7 +2,7 @@ #include // std::numeric_limits -#include +#include TEST(Encoder, zigzag_int_0_0) { const int value = 0; diff --git a/test/encoding/CMakeLists.txt b/test/encoding/CMakeLists.txt index d73fb9264..468049453 100644 --- a/test/encoding/CMakeLists.txt +++ b/test/encoding/CMakeLists.txt @@ -7,7 +7,7 @@ sourcemeta_jsonbinpack_add_compile_options( target_link_libraries(sourcemeta_jsonbinpack_encoding_unit PRIVATE GTest::gtest GTest::gtest_main) target_link_libraries(sourcemeta_jsonbinpack_encoding_unit - PRIVATE sourcemeta::jsonbinpack::encoding) + PRIVATE sourcemeta::jsonbinpack::runtime) target_link_libraries(sourcemeta_jsonbinpack_encoding_unit PRIVATE sourcemeta::jsontoolkit::json) diff --git a/test/encoding/encoding_traits_test.cc b/test/encoding/encoding_traits_test.cc index c2ba03576..1df9ff618 100644 --- a/test/encoding/encoding_traits_test.cc +++ b/test/encoding/encoding_traits_test.cc @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/test/encoding/encoding_wrap_test.cc b/test/encoding/encoding_wrap_test.cc index 3a8bdebe9..4cbce203d 100644 --- a/test/encoding/encoding_wrap_test.cc +++ b/test/encoding/encoding_wrap_test.cc @@ -1,5 +1,4 @@ -#include -#include +#include #include #include diff --git a/test/numeric/CMakeLists.txt b/test/numeric/CMakeLists.txt index 3e8b38da5..f80c510e3 100644 --- a/test/numeric/CMakeLists.txt +++ b/test/numeric/CMakeLists.txt @@ -9,7 +9,7 @@ sourcemeta_jsonbinpack_add_compile_options( target_link_libraries(sourcemeta_jsonbinpack_numeric_unit PRIVATE GTest::gtest GTest::gtest_main) target_link_libraries(sourcemeta_jsonbinpack_numeric_unit - PRIVATE sourcemeta::jsonbinpack::numeric) + PRIVATE sourcemeta::jsonbinpack::runtime) gtest_discover_tests(sourcemeta_jsonbinpack_numeric_unit) set_target_properties(sourcemeta_jsonbinpack_numeric_unit diff --git a/test/numeric/numeric_closest_smallest_exponent_test.cc b/test/numeric/numeric_closest_smallest_exponent_test.cc index 8d95d466a..90a5da3cb 100644 --- a/test/numeric/numeric_closest_smallest_exponent_test.cc +++ b/test/numeric/numeric_closest_smallest_exponent_test.cc @@ -1,5 +1,6 @@ #include -#include + +#include TEST(JSONBinPack_numeric, closest_smallest_exponent_2_2_1_2) { EXPECT_EQ(sourcemeta::jsonbinpack::closest_smallest_exponent(2, 2, 1, 2), 1); diff --git a/test/numeric/numeric_divide_ceil_test.cc b/test/numeric/numeric_divide_ceil_test.cc index f2e688fa8..eba43d646 100644 --- a/test/numeric/numeric_divide_ceil_test.cc +++ b/test/numeric/numeric_divide_ceil_test.cc @@ -1,8 +1,9 @@ -#include #include + +#include #include -#include +#include TEST(JSONBinPack_numeric, divide_ceil_simple_positive) { const std::int64_t dividend{10}; diff --git a/test/numeric/numeric_divide_floor_test.cc b/test/numeric/numeric_divide_floor_test.cc index 9a6d5cdd4..d42bd84e4 100644 --- a/test/numeric/numeric_divide_floor_test.cc +++ b/test/numeric/numeric_divide_floor_test.cc @@ -1,8 +1,9 @@ -#include #include + +#include #include -#include +#include TEST(JSONBinPack_numeric, divide_floor_simple_positive) { const std::int64_t dividend{10}; diff --git a/test/numeric/numeric_uint_max_test.cc b/test/numeric/numeric_uint_max_test.cc index dc83f85c9..7001cf8e3 100644 --- a/test/numeric/numeric_uint_max_test.cc +++ b/test/numeric/numeric_uint_max_test.cc @@ -1,8 +1,9 @@ -#include // std::uint8_t #include -#include // std::numeric_limits -#include +#include // std::uint8_t +#include // std::numeric_limits + +#include TEST(JSONBinPack_numeric, uint_max_8) { EXPECT_EQ(sourcemeta::jsonbinpack::uint_max<8>, diff --git a/test/parser/CMakeLists.txt b/test/parser/CMakeLists.txt index e2c4d935e..f6396d1f8 100644 --- a/test/parser/CMakeLists.txt +++ b/test/parser/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(sourcemeta_jsonbinpack_parser_unit target_link_libraries(sourcemeta_jsonbinpack_parser_unit PRIVATE sourcemeta::jsonbinpack::parser) target_link_libraries(sourcemeta_jsonbinpack_parser_unit - PRIVATE sourcemeta::jsonbinpack::encoding) + PRIVATE sourcemeta::jsonbinpack::runtime) target_link_libraries(sourcemeta_jsonbinpack_parser_unit PRIVATE sourcemeta::jsontoolkit::json) gtest_discover_tests(sourcemeta_jsonbinpack_parser_unit)