File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Copyright 2018-2020, 2026 Peter Dimov
2+ # Distributed under the Boost Software License, Version 1.0.
3+ # https://www.boost.org/LICENSE_1_0.txt
4+
5+ include (BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST )
6+
7+ if (NOT HAVE_BOOST_TEST)
8+ return ()
9+ endif ()
10+
11+ set (BOOST_TEST_LINK_LIBRARIES Boost::serialization Boost::core)
12+
13+ boost_test (SOURCES quick.cpp )
Original file line number Diff line number Diff line change @@ -188,3 +188,6 @@ if ! $(BOOST_ARCHIVE_LIST) {
188188 [ compile test_const_pass.cpp ]
189189 ;
190190}
191+
192+ run quick.cpp
193+ : : : <library>/boost/serialization//boost_serialization ;
Original file line number Diff line number Diff line change 1+ # Copyright 2018, 2019 Peter Dimov
2+ # Distributed under the Boost Software License, Version 1.0.
3+ # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+ cmake_minimum_required (VERSION 3.5...3.31 )
6+
7+ project (cmake_install_test LANGUAGES CXX )
8+
9+ find_package (Boost REQUIRED COMPONENTS serialization core )
10+
11+ add_executable (quick ../quick.cpp )
12+ target_link_libraries (quick Boost::serialization Boost::core )
13+
14+ enable_testing ()
15+ add_test (quick quick )
16+
17+ add_custom_target (check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND } --output-on-failure -C $<CONFIG >)
Original file line number Diff line number Diff line change 1+ # Copyright 2018, 2019 Peter Dimov
2+ # Distributed under the Boost Software License, Version 1.0.
3+ # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+ cmake_minimum_required (VERSION 3.5...3.31 )
6+
7+ project (cmake_subdir_test LANGUAGES CXX )
8+
9+ set (BOOST_INCLUDE_LIBRARIES serialization core)
10+ add_subdirectory (../../../.. boostorg/boost )
11+
12+ add_executable (quick ../quick.cpp )
13+ target_link_libraries (quick Boost::serialization Boost::core )
14+
15+ enable_testing ()
16+ add_test (quick quick )
17+
18+ add_custom_target (check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND } --output-on-failure -C $<CONFIG >)
Original file line number Diff line number Diff line change 1+ // Copyright 2026 Peter Dimov
2+ // Distributed under the Boost Software License, Version 1.0.
3+ // https://www.boost.org/LICENSE_1_0.txt
4+
5+ struct A
6+ {
7+ int x, y;
8+
9+ template <class Ar > void serialize ( Ar& ar, unsigned /* version*/ )
10+ {
11+ ar & x;
12+ ar & y;
13+ }
14+ };
15+
16+ #include < boost/archive/text_iarchive.hpp>
17+ #include < boost/archive/text_oarchive.hpp>
18+ #include < boost/core/lightweight_test.hpp>
19+ #include < sstream>
20+
21+ int main ()
22+ {
23+ std::string tmp;
24+
25+ {
26+ A a = { 1 , 2 };
27+
28+ std::ostringstream os;
29+ boost::archive::text_oarchive oa ( os );
30+
31+ oa << a;
32+
33+ tmp = os.str ();
34+ }
35+
36+ {
37+ A a = {};
38+
39+ std::istringstream is ( tmp );
40+ boost::archive::text_iarchive ia ( is );
41+
42+ ia >> a;
43+
44+ BOOST_TEST_EQ ( a.x , 1 );
45+ BOOST_TEST_EQ ( a.y , 2 );
46+ }
47+
48+ return boost::report_errors ();
49+ }
You can’t perform that action at this time.
0 commit comments