mirror of
https://github.com/boostorg/endian.git
synced 2025-07-30 04:27:24 +02:00
Update cmake_install_test, cmake_subdir_test
This commit is contained in:
@ -7,12 +7,11 @@ cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_endian REQUIRED)
|
||||
find_package(boost_core REQUIRED)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::endian Boost::core)
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::endian)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
31
test/cmake_install_test/main.cpp
Normal file
31
test/cmake_install_test/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/arithmetic.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#define BOOST_TEST_EQ(x, y) assert((x)==(y))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::endian;
|
||||
|
||||
{
|
||||
little_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
|
||||
}
|
||||
|
||||
{
|
||||
big_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
|
||||
}
|
||||
}
|
@ -7,33 +7,12 @@ cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../.. boostorg/endian)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
|
||||
# boost_add_subdir
|
||||
|
||||
function(boost_add_subdir name)
|
||||
|
||||
add_subdirectory(../../../${name} boostorg/${name})
|
||||
|
||||
endfunction()
|
||||
|
||||
# primary dependencies
|
||||
|
||||
boost_add_subdir(config)
|
||||
boost_add_subdir(core)
|
||||
boost_add_subdir(static_assert)
|
||||
boost_add_subdir(type_traits)
|
||||
|
||||
# secondary dependencies
|
||||
|
||||
boost_add_subdir(assert)
|
||||
boost_add_subdir(throw_exception)
|
||||
|
||||
# --target check
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::endian Boost::core)
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::endian)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
31
test/cmake_subdir_test/main.cpp
Normal file
31
test/cmake_subdir_test/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019, 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/arithmetic.hpp>
|
||||
#include <cassert>
|
||||
|
||||
#define BOOST_TEST_EQ(x, y) assert((x)==(y))
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::endian;
|
||||
|
||||
{
|
||||
little_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
|
||||
}
|
||||
|
||||
{
|
||||
big_uint32_t v( 0x01020304 );
|
||||
|
||||
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
|
||||
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
|
||||
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
|
||||
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user