Skip to content

Commit

Permalink
Add test_alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed May 8, 2024
1 parent bb2f88b commit f65e6be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ boost_test(TYPE run SOURCES test_uuid.cpp LINK_LIBRARIES Boost::container_hash C
boost_test(TYPE run SOURCES test_uuid.cpp LINK_LIBRARIES Boost::container_hash COMPILE_DEFINITIONS BOOST_UUID_NO_SIMD=1 BOOST_UUID_REPORT_IMPLEMENTATION=1 NAME test_uuid_no_simd)
boost_test(TYPE run SOURCES test_uuid_2.cpp)

boost_test(TYPE run SOURCES test_alignment.cpp)

boost_test(TYPE run SOURCES test_comparison.cpp COMPILE_DEFINITIONS BOOST_UUID_REPORT_IMPLEMENTATION=1)
boost_test(TYPE run SOURCES test_comparison.cpp COMPILE_DEFINITIONS BOOST_UUID_NO_SIMD=1 BOOST_UUID_REPORT_IMPLEMENTATION=1 NAME test_comparison_no_simd)

Expand Down
6 changes: 5 additions & 1 deletion test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ alias test_headers : [ test_headers ] ;

run test_include1.cpp test_include2.cpp ;

# main test
# main tests

run test_uuid.cpp
: : : <define>BOOST_UUID_REPORT_IMPLEMENTATION ;
run test_uuid.cpp : : : <define>BOOST_UUID_NO_SIMD <define>BOOST_UUID_REPORT_IMPLEMENTATION : test_uuid_no_simd ;
run test_uuid_2.cpp ;

# test type properties

run test_alignment.cpp ;

# test comparison

run test_comparison.cpp
Expand Down
29 changes: 29 additions & 0 deletions test/test_alignment.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

#include <boost/uuid/uuid.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>

using namespace boost::uuids;

struct X1
{
unsigned char a;
uuid b;
};

struct X2
{
unsigned char a[2];
uuid b;
};

int main()
{
BOOST_TEST_EQ( offsetof(X1, b), 1 );
BOOST_TEST_EQ( offsetof(X2, b), 2 );

return boost::report_errors();
}

0 comments on commit f65e6be

Please sign in to comment.