7 Commits

Author SHA1 Message Date
Mindaugas Vinkelis
c0fc083c9d Additional improvements for v5.2.2 release
* migration to github actions
* additionally build tests/examples on windows and macos
2021-08-31 22:16:47 +03:00
michael-mueller-git
bcd03b4d68 Add Missing header (#82)
* add missing header to develop
* add test to check include files
* fix missing includes
* improve test target names

Co-authored-by: arch <arch@local>
2021-08-24 09:28:15 +03:00
Mindaugas Vinkelis
4ff80c6426 fix: std::variant access with get_if using index 2021-05-31 08:12:28 +03:00
Mindaugas Vinkelis
126a6c2971 Merge pull request #77 from robbert-vdh/feature/nontrivial-variant-deserialization
Avoid reinitializing nontrivial std::variant
2021-05-29 09:31:51 +03:00
Robbert van der Helm
d1830a263b Avoid reinitializing nontrivial std::variant #76
When deserializing into an `std::variant<Ts...>` and the object we're
deserializing into already holds the requested variant, then we should
try to deserialize into the existing object instead of recreating it if
the variant is a nontrivial type. This is important when the object has
a default constructor that performs a nontrivial amount of work, or when
the object contains heap data that would need to be reallocated when
recreating the object.
2021-05-28 14:55:59 +02:00
Mindaugas Vinkelis
47f6f9248a Merge pull request #75 from victorstewart/16b
add 16 byte value (aka uint128_t) usage
2021-05-28 14:23:30 +03:00
Victor Stewart
9688cb03d2 add 16 byte value (aka uint128_t) usage 2021-05-15 21:03:56 +00:00
30 changed files with 279 additions and 57 deletions

62
.github/workflows/on_linux.yml vendored Normal file
View File

@@ -0,0 +1,62 @@
name: On Linux
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
config:
- name: "Ubuntu 18.04 with Clang 3.9"
cxx_ver: 11
compiler: clang
compiler_ver: 3.9
- name: "Ubuntu 18.04 with GCC 5.0"
cxx_ver: 11
compiler: gcc
compiler_ver: 5
- name: "Ubuntu 18.04 with GCC 11.0"
cxx_ver: 17
compiler: gcc
compiler_ver: 11
- name: "Ubuntu 18.04 with Clang 13"
cxx_ver: 17
compiler: clang
compiler_ver: 13
steps:
- name: Prepare specific Clang version
if: ${{ matrix.config.compiler == 'clang' }}
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-13 main"
sudo apt update
sudo apt install clang-${{ matrix.config.compiler_ver}}
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${{ matrix.config.compiler_ver}} 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${{ matrix.config.compiler_ver}} 100
- name: Prepare specific GCC version
if: ${{ matrix.config.compiler == 'gcc' }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install g++-${{ matrix.config.compiler_ver}}
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-${{ matrix.config.compiler_ver}} 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${{ matrix.config.compiler_ver}} 100
- name: Installing GTest
run: |
sudo add-apt-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get install libgmock-dev
- uses: actions/checkout@v2
- name: Configure
run: cmake -S . -B build -DBITSERY_BUILD_TESTS=ON -DBITSERY_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=${{ matrix.config.cxx_ver }}
- name: Build
run: cmake --build build
- name: Run tests
run: ctest --test-dir build/tests

26
.github/workflows/on_mac.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: On Mac
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
jobs:
build:
name: macOS Latest
runs-on: macos-latest
steps:
- name: Installing GTest
run: |
git clone https://github.com/google/googletest.git
cd googletest
git checkout release-1.11.0
cmake -S . -B build
cmake --build build --target install
- uses: actions/checkout@v2
- name: Configure
run: cmake -S . -B build -DBITSERY_BUILD_TESTS=ON -DBITSERY_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=17
- name: Build
run: cmake --build build
- name: Run tests
run: ctest --test-dir build/tests

29
.github/workflows/on_windows.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
name: On Windows
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
jobs:
build:
name: Windows MSVC Latest
runs-on: windows-latest
steps:
- name: Installing GTest
run: |
git clone https://github.com/google/googletest.git
cd googletest
git checkout release-1.11.0
cmake -S . -B build -Dgtest_force_shared_crt=ON
cmake --build build --config Release --target install
- uses: actions/checkout@v2
- name: Configure
run: cmake -S . -B build -DBITSERY_BUILD_TESTS=ON -DBITSERY_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /permissive- /EHsc"
env:
CMAKE_PREFIX_PATH: "C:/Program Files (x86)/googletest-distribution/"
- name: Build
run: cmake --build build --config Release
- name: Run tests
run: ctest --test-dir build/tests

View File

@@ -1,3 +1,19 @@
# [5.2.2](https://github.com/fraillt/bitsery/compare/v5.2.1...v5.2.2) (2021-08-31)
### Improvements
* add 16 byte value support #75 (thanks to [Victor Stewart](https://github.com/victorstewart))
* avoid reinitializing nontrivial std::variant #77 (thanks to [Robbert van der Helm](https://github.com/robbert-vdh))
* avoid reinitializing nontrivial std::optional.
### Bug fixes
* fix missing headers for GCC11, also added test to check includes #82 (thanks to [michael-mueller-git](https://github.com/michael-mueller-git))
* fixed **StdBitset** to build on macOS (proxy type, returned by `[]` operator wasn't correctly converted to unsigned integral type).
### Other notes
* migrated to [Github actions](https://docs.github.com/en/actions) for running tests.
* fixes few warnings on MSVC compiler.
* now tests are also run on macOS and Windows.
# [5.2.1](https://github.com/fraillt/bitsery/compare/v5.2.0...v5.2.1) (2020-11-14)
### Improvements

View File

@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(bitsery
LANGUAGES CXX
VERSION 5.2.1)
VERSION 5.2.2)
#======== build options ===================================
option(BITSERY_BUILD_EXAMPLES "Build examples" OFF)

View File

@@ -1,6 +1,8 @@
# Bitsery
[![Build Status](https://travis-ci.org/fraillt/bitsery.svg?branch=master)](https://travis-ci.org/fraillt/bitsery)
[![Build On Windows](https://github.com/fraillt/bitsery/actions/workflows/on_windows.yml/badge.svg)](https://github.com/fraillt/bitsery/actions/workflows/on_windows.yml)
[![Build On Mac](https://github.com/fraillt/bitsery/actions/workflows/on_mac.yml/badge.svg)](https://github.com/fraillt/bitsery/actions/workflows/on_mac.yml)
[![Build On Linux](https://github.com/fraillt/bitsery/actions/workflows/on_linux.yml/badge.svg)](https://github.com/fraillt/bitsery/actions/workflows/on_linux.yml)
[![Join the chat at https://gitter.im/bitsery/Lobby](https://badges.gitter.im/bitsery/Lobby.svg)](https://gitter.im/bitsery/Lobby)
Header only C++ binary serialization library.
@@ -30,17 +32,17 @@ All cross-platform requirements are enforced at compile time, so serialized data
Look at the numbers and features list, and decide yourself.
| library | data size | serialize | deserialize |
| ---------------- | --------- | --------- | ----------- |
| bitsery | 6913B | 959ms | 927ms |
| bitsery_compress | 4213B | 1282ms | 1115ms |
| boost | 11037B | 9826ms | 8313ms |
| cereal | 10413B | 6324ms | 5698ms |
| flatbuffers | 14924B | 5129ms | 2142ms |
| protobuf | 10018B | 11966ms | 13919ms |
| yas | 10463B | 1908ms | 1217ms |
| library | data size | ser time | des time |
| ----------- | --------- | -------- | -------- |
| bitsery | 6913B | 1119ms | 1166ms |
| boost | 11037B | 15391ms | 12912ms |
| cereal | 10413B | 10518ms | 10245ms |
| flatbuffers | 14924B | 9075ms | 3701ms |
| msgpack | 8857B | 3340ms | 13842ms |
| protobuf | 10018B | 21229ms | 22077ms |
| yas | 10463B | 2107ms | 1554ms |
*benchmarked on Ubuntu with GCC 8.3.0, more details can be found [here](https://github.com/fraillt/cpp_serializers_benchmark.git)*
*benchmarked on Ubuntu with GCC 10.3.0, more details can be found [here](https://github.com/fraillt/cpp_serializers_benchmark.git)*
If still not convinced read more in library [motivation](doc/design/README.md) section.
@@ -98,10 +100,7 @@ Works with C++11 compiler, no additional dependencies, include `<bitsery/bitsery
## Platforms
This library was tested on
* Windows: Visual Studio 2015, MinGW (GCC 5.2)
* Linux: GCC 5.4, Clang 3.9
* OS X Mavericks: AppleClang 8
Library is tested on all major compilers on Windows, Linux and macOS.
There is a patch that allows using bitsery with non-fully compatible C++11 compilers.
* CentOS 7 with gcc 4.8.2.

View File

@@ -41,7 +41,7 @@ void serialize(S& s, MyVariant& o) {
s.ext(o, bitsery::ext::StdTuple{
// this is convenient callable object to specify integral value size
// it is different equivalent to lambda [](auto& s, float&o) { s.value4b(o);}
bitsery::ext::OverloadValue<float, 4>{},
bitsery::ext::OverloadValue<float, 4>{},
// it is not required to provide MyStruct overload, because it we have defined 'serialize' function for it
});
},
@@ -66,7 +66,7 @@ void serialize(S& s, MyVariant& o) {
// also note, that first parameter (serializer) is also "auto", this is required, so that it would be least specialized case
// otherwise it will not compile if you any ext::Overload* helper defined, because it will have ambiguous definitions
// (ext::OverLoad* defines (templated_type& s, concrete_type& o) and lambda would be (concrete_type& s, templated_type& o))
[](auto& , auto& ) {
[](auto& , auto&) {
assert(false);
}
});
@@ -81,8 +81,7 @@ using InputAdapter = bitsery::InputBufferAdapter<Buffer>;
int main() {
//set some random data
MyVariant data{MyTuple{-7549, {{-451, 2, 968, 75, 4, 156, 49}, 874.4f}}};
// MyVariant data{MyStruct{{-451, 2, 968, 75, 4, 156, 49}, 874.4f}};
MyVariant data{ MyTuple{-7549, {{-451, 2, 968, 75, 4, 156, 49}, 874.4f}} };
MyVariant res{};
//create buffer to store data
@@ -94,19 +93,18 @@ int main() {
//same as serialization, but returns deserialization state as a pair
//first = error code, second = is buffer was successfully read from begin to the end.
auto state = bitsery::quickDeserialization<InputAdapter>({buffer.begin(), writtenSize}, res);
auto state = bitsery::quickDeserialization<InputAdapter>({ buffer.begin(), writtenSize }, res);
assert(state.first == bitsery::ReaderError::NoError && state.second);
assert(data == res);
}
#else
#if defined(_MSC_VER)
#pragma message("example works only on c++17")
#pragma message("C++17 and /Zc:__cplusplus option is required to enable this example")
#else
#warning "example works only on c++17"
#pragma message("C++17 is required to enable this example")
#endif
int main() {
return 0;
}
#endif

View File

@@ -23,6 +23,10 @@
#ifndef BITSERY_ADAPTER_MEASURE_SIZE_H
#define BITSERY_ADAPTER_MEASURE_SIZE_H
#include <cstddef>
#include <type_traits>
#include "../details/adapter_common.h"
namespace bitsery {

View File

@@ -26,6 +26,7 @@
#include "../details/adapter_common.h"
#include "../traits/array.h"
#include <ios>
#include <limits>
namespace bitsery {

View File

@@ -26,7 +26,7 @@
#define BITSERY_MAJOR_VERSION 5
#define BITSERY_MINOR_VERSION 2
#define BITSERY_PATCH_VERSION 1
#define BITSERY_PATCH_VERSION 2
#define BITSERY_QUOTE_MACRO(name) #name
#define BITSERY_BUILD_VERSION_STR(major,minor, patch) \

View File

@@ -25,6 +25,7 @@
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_MAP_H
#include <map>
#include <limits>
#include "../ext/std_map.h"
namespace bitsery {

View File

@@ -25,6 +25,7 @@
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_QUEUE_H
#include "../ext/std_queue.h"
#include <limits>
namespace bitsery {
template<typename S, typename T, typename C>

View File

@@ -25,6 +25,7 @@
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_SET_H
#include <set>
#include <limits>
#include "../ext/std_set.h"
namespace bitsery {

View File

@@ -24,6 +24,7 @@
#ifndef BITSERY_BRIEF_SYNTAX_TYPE_STD_STACK_H
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_STACK_H
#include <limits>
#include "../ext/std_stack.h"
namespace bitsery {

View File

@@ -25,6 +25,7 @@
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_UNORDERED_MAP_H
#include <unordered_map>
#include <limits>
#include "../ext/std_map.h"
namespace bitsery {

View File

@@ -24,6 +24,7 @@
#ifndef BITSERY_BRIEF_SYNTAX_TYPE_STD_UNORDERED_SET_H
#define BITSERY_BRIEF_SYNTAX_TYPE_STD_UNORDERED_SET_H
#include <limits>
#include <unordered_set>
#include "../ext/std_set.h"

View File

@@ -369,6 +369,9 @@ namespace bitsery {
template<typename T>
void value8b(T &&v) { value<8>(std::forward<T>(v)); }
template<typename T>
void value16b(T &&v) { value<16>(std::forward<T>(v)); }
template<typename T, typename Ext>
void ext1b(T &v, Ext &&extension) { ext<1, T, Ext>(v, std::forward<Ext>(extension)); }
@@ -381,6 +384,9 @@ namespace bitsery {
template<typename T, typename Ext>
void ext8b(T &v, Ext &&extension) { ext<8, T, Ext>(v, std::forward<Ext>(extension)); }
template<typename T, typename Ext>
void ext16b(T &v, Ext &&extension) { ext<16, T, Ext>(v, std::forward<Ext>(extension)); }
template<typename T>
void text1b(T &str, size_t maxSize) { text<1>(str, maxSize); }
@@ -411,6 +417,9 @@ namespace bitsery {
template<typename T>
void container8b(T &&obj, size_t maxSize) { container<8>(std::forward<T>(obj), maxSize); }
template<typename T>
void container16b(T &&obj, size_t maxSize) { container<16>(std::forward<T>(obj), maxSize); }
template<typename T>
void container1b(T &&obj) { container<1>(std::forward<T>(obj)); }
@@ -423,6 +432,9 @@ namespace bitsery {
template<typename T>
void container8b(T &&obj) { container<8>(std::forward<T>(obj)); }
template<typename T>
void container16b(T &&obj) { container<16>(std::forward<T>(obj)); }
private:
void readSize(size_t& size, size_t maxSize) {

View File

@@ -24,6 +24,7 @@
#define BITSERY_DETAILS_BRIEF_SYNTAX_COMMON_H
#include "../traits/core/traits.h"
#include "serialization_common.h"
#include <limits>
namespace bitsery {

View File

@@ -75,6 +75,8 @@ namespace bitsery {
struct FtorExtValue4b: FtorExtValue<4, Ext> {};
template <typename Ext>
struct FtorExtValue8b: FtorExtValue<8, Ext> {};
template <typename Ext>
struct FtorExtValue16b: FtorExtValue<16, Ext> {};
template<typename Ext>
struct FtorExtObject : public Ext {

View File

@@ -103,7 +103,7 @@ namespace bitsery {
template<typename Writer, size_t N>
void serializeLeftoverImpl(Writer& w, const std::bitset<N> &obj, size_t from, size_t to, std::integral_constant<bool, true>) const {
for (auto i = from; i < to; ++i) {
w.writeBits(obj[i], 1);
w.writeBits(obj[i] ? 1u : 0u, 1);
}
}
@@ -126,7 +126,7 @@ namespace bitsery {
for (auto i = from; i < to; ++i) {
uint8_t res = 0u;
r.readBits(res, 1);
obj[i] = res;
obj[i] = res == 1;
}
}

View File

@@ -56,13 +56,26 @@ namespace bitsery {
if (_alignBeforeData)
des.adapter().align();
if (exists) {
obj = ::bitsery::Access::create<T>();
fnc(des, *obj);
deserialize_impl(des, obj, fnc, std::is_trivial<T>{});
} else {
obj = std::nullopt;
}
}
private:
template<typename Des, typename T, typename Fnc>
void deserialize_impl(Des &des, std::optional<T> &obj, Fnc &&fnc, std::true_type) const {
obj = ::bitsery::Access::create<T>();
fnc(des, *obj);
}
template<typename Des, typename T, typename Fnc>
void deserialize_impl(Des &des, std::optional<T> &obj, Fnc &&fnc, std::false_type) const {
if (!obj) {
obj = ::bitsery::Access::create<T>();
}
fnc(des, *obj);
}
bool _alignBeforeData;
};
}

View File

@@ -54,6 +54,17 @@ namespace bitsery {
this->execIndex(index, obj, [this, &des](auto& data, auto index) {
constexpr size_t Index = decltype(index)::value;
using TElem = typename std::variant_alternative<Index, std::variant<Ts...>>::type;
// Reinitializing nontrivial types may be expensive especially when they
// reference heap data, so if `data` is already holding the requested
// variant then we'll deserialize into the existing object
if constexpr (!std::is_trivial_v<TElem>) {
if (auto item = std::get_if<Index>(&data)) {
this->serializeType(des, *item);
return;
}
}
TElem item = ::bitsery::Access::create<TElem>();
this->serializeType(des, item);
data = std::variant<Ts...>(std::in_place_index_t<Index>{}, std::move(item));

View File

@@ -27,6 +27,7 @@
#include "details/serialization_common.h"
#include "details/adapter_common.h"
#include <cassert>
#include <limits>
namespace bitsery {
@@ -367,6 +368,9 @@ namespace bitsery {
template<typename T>
void value8b(T &&v) { value<8>(std::forward<T>(v)); }
template<typename T>
void value16b(T &&v) { value<16>(std::forward<T>(v)); }
template<typename T, typename Ext>
void ext1b(const T &v, Ext &&extension) { ext<1, T, Ext>(v, std::forward<Ext>(extension)); }
@@ -379,6 +383,9 @@ namespace bitsery {
template<typename T, typename Ext>
void ext8b(const T &v, Ext &&extension) { ext<8, T, Ext>(v, std::forward<Ext>(extension)); }
template<typename T, typename Ext>
void ext16b(const T &v, Ext &&extension) { ext<16, T, Ext>(v, std::forward<Ext>(extension)); }
template<typename T>
void text1b(const T &str, size_t maxSize) { text<1>(str, maxSize); }
@@ -409,6 +416,9 @@ namespace bitsery {
template<typename T>
void container8b(T &&obj, size_t maxSize) { container<8>(std::forward<T>(obj), maxSize); }
template<typename T>
void container16b(T &&obj, size_t maxSize) { container<16>(std::forward<T>(obj), maxSize); }
template<typename T>
void container1b(T &&obj) { container<1>(std::forward<T>(obj)); }
@@ -421,6 +431,9 @@ namespace bitsery {
template<typename T>
void container8b(T &&obj) { container<8>(std::forward<T>(obj)); }
template<typename T>
void container16b(T &&obj) { container<16>(std::forward<T>(obj)); }
private:

0
scripts/show_coverage.sh Executable file → Normal file
View File

View File

@@ -20,8 +20,9 @@
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
cmake_minimum_required(VERSION 3.10)
project(bitsery_tests CXX)
cmake_minimum_required(VERSION 3.11)
project(bitsery_tests
LANGUAGES CXX)
find_package(GTest 1.10 REQUIRED)
@@ -62,4 +63,40 @@ if (ParentDir)
# add headers so IDE correctly show them
target_sources(bitsery.dummy_for_ide PRIVATE ${HeadersForIDE} serialization_test_utils.h)
target_link_libraries(bitsery.dummy_for_ide PRIVATE GTest::Main Bitsery::bitsery)
# creates a "check_includes" target to verify if all headers has required includes
# to simplify things a little bit, it only works with modern compiler (C++17)
# as some bitsery extensions require C++17 compliant compiler.
if("cxx_std_17" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
add_library(check_includes OBJECT)
target_compile_features(check_includes PRIVATE cxx_std_17)
file(WRITE ${CMAKE_BINARY_DIR}/check_includes.in "
// generated by CMake to verify header includes.
// we need exactly 201703L, because some compilers with experimental C++17 support
// provides bigger number than 201402L (C++14) but doesn't actually has enough
// functionality to build these files
#if __cplusplus >= 201703L
#include \"@HeaderFile@\"
#elif defined(_MSC_VER)
#pragma message(\"/Zc:__cplusplus option is required to enable check_includes\")
#else
#define XSTR(x) STR(x)
#define STR(x) #x
#pragma message (\"`__cplusplus` macro value should be 201703L or greater, actual value is: \" XSTR(__cplusplus))
#endif
")
file(GLOB_RECURSE HeaderFiles "${ParentDir}/include/bitsery/*.h")
foreach (HeaderFile ${HeaderFiles})
SET(CHK_TARGET_NAME "chk_inc_${HeaderFile}")
STRING(REPLACE "${ParentDir}/include/bitsery/" "" CHK_TARGET_NAME ${CHK_TARGET_NAME})
STRING(REGEX REPLACE "/" "_" CHK_TARGET_NAME ${CHK_TARGET_NAME})
STRING(REGEX REPLACE "\\\\" "_" CHK_TARGET_NAME ${CHK_TARGET_NAME})
configure_file(${CMAKE_BINARY_DIR}/check_includes.in "${CHK_TARGET_NAME}.cpp")
target_sources(check_includes PRIVATE "${CHK_TARGET_NAME}.cpp")
endforeach ()
else()
message(WARNING "`check_includes` target will be disabled, as it require compiler with C++17 support.")
endif()
endif()

View File

@@ -39,12 +39,10 @@
#if __cplusplus > 201402L
#include <bitsery/brief_syntax/tuple.h>
#include <bitsery/brief_syntax/variant.h>
#elif defined(_MSC_VER)
#pragma message("C++17 and /Zc:__cplusplus option is required to enable std::tuple and std::variant brief syntax tests")
#else
/*#if defined(_MSC_VER)
#pragma message("tuple and variant only works with c++17")
#else
#warning "tuple and variant only works with c++17"
#endif*/
#pragma message("C++17 is required to enable std::tuple and std::variant brief syntax tests")
#endif
#include <gmock/gmock.h>

View File

@@ -41,7 +41,7 @@ TEST(SerializationContext, WhenContextIsNotTupleThenReturnThisContext) {
TEST(SerializationContext, WhenContextIsTupleThenReturnsTupleElements) {
MultipleTypesContext ctx{5, 798.654, 'F'};
MultipleTypesContext ctx{5, 798.654f, 'F'};
BasicSerializationContext<MultipleTypesContext> c1;
auto& ser1 = c1.createSerializer(ctx);
@@ -59,7 +59,7 @@ TEST(SerializationContext, WhenContextDoesntExistsThenContextOrNullReturnsNull)
*ser.contextOrNull<int>() = 2;
EXPECT_THAT(ctx1, Eq(2));
MultipleTypesContext ctx2{5, 798.654, 'F'};
MultipleTypesContext ctx2{5, 798.654f, 'F'};
BasicSerializationContext<MultipleTypesContext> c2;
auto& des = c2.createDeserializer(ctx2);
EXPECT_THAT(des.contextOrNull<double>(), ::testing::IsNull());
@@ -105,4 +105,4 @@ TEST(SerializationContext, WhenMultipleConvertibleTypesExistsThenFirstMatchIsTak
//Base will not be accessable in this case, because Derived is first valid match
EXPECT_THAT(des.context<Base>().value, Eq(std::get<1>(ctx2).value));
}
}
}

View File

@@ -120,10 +120,8 @@ TEST(SerializeExtensionStdOptional, NoAlignAfterStateWriteRead) {
EXPECT_THAT(t1.value(), Eq(r1.value()));
}
#elif defined(_MSC_VER)
#pragma message("C++17 and /Zc:__cplusplus option is required to enable std::optional tests")
#else
/*#if defined(_MSC_VER)
#pragma message("Tests for StdOptional requires C++17")
#else
#warning "Tests for StdOptional requires C++17"
#endif*/
#pragma message("C++17 is required to enable std::optional tests")
#endif

View File

@@ -102,8 +102,8 @@ private:
};
TEST(SerializeExtensionStdTuple, NonDefaultConstructable) {
std::tuple<NonDefaultConstructable> t1{34};
std::tuple<NonDefaultConstructable> r1{8};
std::tuple<NonDefaultConstructable> t1{34.0f};
std::tuple<NonDefaultConstructable> r1{8.0f};
SerializationContext ctx;
ctx.createSerializer().ext(t1, bitsery::ext::StdTuple{
[](auto& s, NonDefaultConstructable& v) {
@@ -118,10 +118,8 @@ TEST(SerializeExtensionStdTuple, NonDefaultConstructable) {
EXPECT_THAT(t1, Eq(r1));
}
#elif defined(_MSC_VER)
#pragma message("C++17 and /Zc:__cplusplus option is required to enable std::tuple tests")
#else
/*#if defined(_MSC_VER)
#pragma message("Tests for StdTuple requires C++17")
#else
#warning "Tests for StdTuple requires C++17"
#endif*/
#endif
#pragma message("C++17 is required to enable std::tuple tests")
#endif

View File

@@ -167,10 +167,8 @@ TEST(SerializeExtensionStdVariant, CorrectlyHandleMonoState) {
}
#elif defined(_MSC_VER)
#pragma message("C++17 and /Zc:__cplusplus option is required to enable std::variant tests")
#else
/*#if defined(_MSC_VER)
#pragma message("Tests for StdVariant requires C++17")
#else
#warning "Tests for StdVariant requires C++17"
#endif*/
#pragma message("C++17 is required to enable std::variant tests")
#endif