Add intrinsic_test.cpp to test/Jamfile

This commit is contained in:
Peter Dimov
2018-12-06 17:51:38 +02:00
parent bde5937912
commit 59126b39ae
2 changed files with 25 additions and 30 deletions

View File

@@ -1,28 +1,18 @@
# Boost Endian Library test Jamfile # Boost Endian Library test Jamfile
# Copyright Beman Dawes 2006, 2013 # Copyright Beman Dawes 2006, 2013
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt # See http://www.boost.org/LICENSE_1_0.txt
# See library home page at http://www.boost.org/libs/endian # See library home page at http://www.boost.org/libs/endian
project import testing ;
: requirements
<toolset>msvc:<asynch-exceptions>on run buffer_test.cpp ;
; run endian_test.cpp ;
run endian_operations_test.cpp ;
test-suite "endian" run endian_in_union_test.cpp ;
: run conversion_test.cpp ;
[ run buffer_test.cpp # sources run intrinsic_test.cpp ;
: # command line
: # input files
: # requirements
: # target name
]
[ run endian_test.cpp ]
[ run endian_operations_test.cpp ]
[ run endian_in_union_test.cpp ]
[ run conversion_test.cpp ]
# [ run floating_point_test.cpp : : : <test-info>always_show_run_output ]
;

View File

@@ -1,11 +1,11 @@
// Copyright Beman Dawes 2013 // Copyright Beman Dawes 2013
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt // http://www.boost.org/LICENSE_1_0.txt
#include "test.hpp" #include <boost/endian/detail/intrinsic.hpp>
#include <iostream> #include <boost/core/lightweight_test.hpp>
#include <boost/assert.hpp>
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
@@ -13,15 +13,20 @@ typedef unsigned long long uint64_t;
int main() int main()
{ {
std::cout << "BOOST_ENDIAN_INTRINSIC_MSG: " BOOST_ENDIAN_INTRINSIC_MSG << std::endl; std::cout << "BOOST_ENDIAN_INTRINSIC_MSG: " BOOST_ENDIAN_INTRINSIC_MSG << std::endl;
#ifndef BOOST_ENDIAN_NO_INTRINSICS #ifndef BOOST_ENDIAN_NO_INTRINSICS
uint16_t x2 = 0x1122U;
BOOST_ASSERT(BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x2) == 0x2211U); uint16_t x2 = 0x1122U;
uint32_t x4 = 0x11223344UL; BOOST_TEST_EQ( BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x2), 0x2211U );
BOOST_ASSERT(BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x4) == 0x44332211UL);
uint64_t x8 = 0x1122334455667788U; uint32_t x4 = 0x11223344UL;
BOOST_ASSERT(BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x8) == 0x8877665544332211ULL); BOOST_TEST_EQ( BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x4), 0x44332211UL );
uint64_t x8 = 0x1122334455667788U;
BOOST_TEST_EQ( BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x8), 0x8877665544332211ULL );
#endif #endif
return 0;
return boost::report_errors();
} }