From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/align/test/Jamfile | 24 +++ .../libs/align/test/align_down_integral_test.cpp | 59 ++++++ src/boost/libs/align/test/align_down_test.cpp | 43 ++++ src/boost/libs/align/test/align_test.cpp | 68 +++++++ .../libs/align/test/align_up_integral_test.cpp | 63 ++++++ src/boost/libs/align/test/align_up_test.cpp | 43 ++++ src/boost/libs/align/test/aligned_alloc_test.cpp | 47 +++++ .../aligned_allocator_adaptor_incomplete_test.cpp | 74 +++++++ .../align/test/aligned_allocator_adaptor_test.cpp | 156 +++++++++++++++ .../test/aligned_allocator_incomplete_test.cpp | 24 +++ .../libs/align/test/aligned_allocator_test.cpp | 106 ++++++++++ src/boost/libs/align/test/aligned_delete_test.cpp | 51 +++++ src/boost/libs/align/test/alignment_of_test.cpp | 219 +++++++++++++++++++++ src/boost/libs/align/test/assume_aligned_test.cpp | 61 ++++++ .../libs/align/test/is_aligned_integral_test.cpp | 63 ++++++ src/boost/libs/align/test/is_aligned_test.cpp | 73 +++++++ 16 files changed, 1174 insertions(+) create mode 100644 src/boost/libs/align/test/Jamfile create mode 100644 src/boost/libs/align/test/align_down_integral_test.cpp create mode 100644 src/boost/libs/align/test/align_down_test.cpp create mode 100644 src/boost/libs/align/test/align_test.cpp create mode 100644 src/boost/libs/align/test/align_up_integral_test.cpp create mode 100644 src/boost/libs/align/test/align_up_test.cpp create mode 100644 src/boost/libs/align/test/aligned_alloc_test.cpp create mode 100644 src/boost/libs/align/test/aligned_allocator_adaptor_incomplete_test.cpp create mode 100644 src/boost/libs/align/test/aligned_allocator_adaptor_test.cpp create mode 100644 src/boost/libs/align/test/aligned_allocator_incomplete_test.cpp create mode 100644 src/boost/libs/align/test/aligned_allocator_test.cpp create mode 100644 src/boost/libs/align/test/aligned_delete_test.cpp create mode 100644 src/boost/libs/align/test/alignment_of_test.cpp create mode 100644 src/boost/libs/align/test/assume_aligned_test.cpp create mode 100644 src/boost/libs/align/test/is_aligned_integral_test.cpp create mode 100644 src/boost/libs/align/test/is_aligned_test.cpp (limited to 'src/boost/libs/align/test') diff --git a/src/boost/libs/align/test/Jamfile b/src/boost/libs/align/test/Jamfile new file mode 100644 index 00000000..803af854 --- /dev/null +++ b/src/boost/libs/align/test/Jamfile @@ -0,0 +1,24 @@ +# Copyright 2014-2015 Glen Joseph Fernandes +# (glenjofe@gmail.com) +# +# Distributed under the Boost Software License, Version 1.0. +# (http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +run align_test.cpp ; +run align_down_test.cpp ; +run align_down_integral_test.cpp ; +run align_up_test.cpp ; +run align_up_integral_test.cpp ; +run aligned_alloc_test.cpp ; +run aligned_allocator_test.cpp ; +run aligned_allocator_adaptor_test.cpp ; +run aligned_delete_test.cpp ; +run alignment_of_test.cpp ; +run assume_aligned_test.cpp ; +run is_aligned_test.cpp ; +run is_aligned_integral_test.cpp ; + +compile aligned_allocator_incomplete_test.cpp ; +compile aligned_allocator_adaptor_incomplete_test.cpp ; diff --git a/src/boost/libs/align/test/align_down_integral_test.cpp b/src/boost/libs/align/test/align_down_integral_test.cpp new file mode 100644 index 00000000..c05a7d84 --- /dev/null +++ b/src/boost/libs/align/test/align_down_integral_test.cpp @@ -0,0 +1,59 @@ +/* +Copyright 2019 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include + +template +struct A { }; + +template +void test(A) +{ + T v1 = N; + BOOST_TEST(boost::alignment::align_down(v1, N) == v1); + T v2 = N + 1; + BOOST_TEST(boost::alignment::align_down(v2, N) == v1); +} + +template +void test(A<1>) +{ + T v = 1; + BOOST_TEST(boost::alignment::align_down(v, 1) == v); +} + +template +void test() +{ + test(A<1>()); + test(A<2>()); + test(A<4>()); + test(A<8>()); + test(A<16>()); + test(A<32>()); + test(A<64>()); + test(A<128>()); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +#if !defined(BOOST_NO_LONG_LONG) + test(); + test(); +#endif + test(); + test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/align_down_test.cpp b/src/boost/libs/align/test/align_down_test.cpp new file mode 100644 index 00000000..6b4d64dd --- /dev/null +++ b/src/boost/libs/align/test/align_down_test.cpp @@ -0,0 +1,43 @@ +/* +Copyright 2015 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include + +template +void test() +{ + char s[Alignment << 1]; + char* b = s; + while (!boost::alignment::is_aligned(b, Alignment)) { + ++b; + } + { + void* p = &b[Alignment]; + BOOST_TEST(boost::alignment::align_down(p, Alignment) == p); + } + { + void* p = &b[Alignment - 1]; + void* q = b; + BOOST_TEST(boost::alignment::align_down(p, Alignment) == q); + } +} + +int main() +{ + test<1>(); + test<2>(); + test<4>(); + test<8>(); + test<16>(); + test<32>(); + test<64>(); + test<128>(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/align_test.cpp b/src/boost/libs/align/test/align_test.cpp new file mode 100644 index 00000000..beea710a --- /dev/null +++ b/src/boost/libs/align/test/align_test.cpp @@ -0,0 +1,68 @@ +/* +Copyright 2014-2015 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include + +template +void test() +{ + char s[Alignment << 1]; + char* b = s; + while (!boost::alignment::is_aligned(b, Alignment)) { + ++b; + } + { + std::size_t n = Alignment; + void* p = b; + void* q = boost::alignment::align(Alignment, 1, p, n); + BOOST_TEST(q == p); + BOOST_TEST(q == b); + BOOST_TEST(boost::alignment::is_aligned(q, Alignment)); + BOOST_TEST(n == Alignment); + } + { + std::size_t n = 0; + void* p = b; + void* q = boost::alignment::align(Alignment, 1, p, n); + BOOST_TEST(q == 0); + BOOST_TEST(p == b); + BOOST_TEST(n == 0); + } + { + std::size_t n = Alignment - 1; + void* p = &b[1]; + void* q = boost::alignment::align(Alignment, 1, p, n); + BOOST_TEST(q == 0); + BOOST_TEST(p == &b[1]); + BOOST_TEST(n == Alignment - 1); + } + { + std::size_t n = Alignment; + void* p = &b[1]; + void* q = boost::alignment::align(Alignment, 1, p, n); + BOOST_TEST(q == p); + BOOST_TEST(p == &b[Alignment]); + BOOST_TEST(boost::alignment::is_aligned(q, Alignment)); + BOOST_TEST(n == 1); + } +} + +int main() +{ + test<1>(); + test<2>(); + test<4>(); + test<8>(); + test<16>(); + test<32>(); + test<64>(); + test<128>(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/align_up_integral_test.cpp b/src/boost/libs/align/test/align_up_integral_test.cpp new file mode 100644 index 00000000..ed26fb3b --- /dev/null +++ b/src/boost/libs/align/test/align_up_integral_test.cpp @@ -0,0 +1,63 @@ +/* +Copyright 2019 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include + +template +struct A { }; + +template +void test(A) +{ + T v1 = N; + BOOST_TEST(boost::alignment::align_up(v1, N) == v1); + T v2 = N - 1; + BOOST_TEST(boost::alignment::align_up(v2, N) == v1); + T v3 = N + N; + BOOST_TEST(boost::alignment::align_up(v3, N) == v3); + T v4 = N + 1; + BOOST_TEST(boost::alignment::align_up(v4, N) == v3); +} + +template +void test(A<1>) +{ + T v = 1; + BOOST_TEST(boost::alignment::align_up(v, 1) == v); +} + +template +void test() +{ + test(A<1>()); + test(A<2>()); + test(A<4>()); + test(A<8>()); + test(A<16>()); + test(A<32>()); + test(A<64>()); + test(A<128>()); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +#if !defined(BOOST_NO_LONG_LONG) + test(); + test(); +#endif + test(); + test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/align_up_test.cpp b/src/boost/libs/align/test/align_up_test.cpp new file mode 100644 index 00000000..4faa1ffd --- /dev/null +++ b/src/boost/libs/align/test/align_up_test.cpp @@ -0,0 +1,43 @@ +/* +Copyright 2015 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include + +template +void test() +{ + char s[Alignment << 1]; + char* b = s; + while (!boost::alignment::is_aligned(b, Alignment)) { + ++b; + } + { + void* p = b; + BOOST_TEST(boost::alignment::align_up(p, Alignment) == p); + } + { + void* p = &b[Alignment]; + void* q = &b[1]; + BOOST_TEST(boost::alignment::align_up(q, Alignment) == p); + } +} + +int main() +{ + test<1>(); + test<2>(); + test<4>(); + test<8>(); + test<16>(); + test<32>(); + test<64>(); + test<128>(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/aligned_alloc_test.cpp b/src/boost/libs/align/test/aligned_alloc_test.cpp new file mode 100644 index 00000000..925d77f8 --- /dev/null +++ b/src/boost/libs/align/test/aligned_alloc_test.cpp @@ -0,0 +1,47 @@ +/* +Copyright 2014 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include + +void test(std::size_t alignment) +{ + { + void* p = boost::alignment::aligned_alloc(alignment, alignment + 1); + BOOST_TEST(p != 0); + BOOST_TEST(boost::alignment::is_aligned(p, alignment)); + std::memset(p, 0, alignment); + boost::alignment::aligned_free(p); + } + { + void* p = boost::alignment::aligned_alloc(alignment, 1); + BOOST_TEST(p != 0); + BOOST_TEST(boost::alignment::is_aligned(p, alignment)); + std::memset(p, 0, 1); + boost::alignment::aligned_free(p); + } + { + void* p = boost::alignment::aligned_alloc(alignment, 0); + boost::alignment::aligned_free(p); + } +} + +int main() +{ + test(1); + test(2); + test(4); + test(8); + test(16); + test(32); + test(64); + test(128); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/aligned_allocator_adaptor_incomplete_test.cpp b/src/boost/libs/align/test/aligned_allocator_adaptor_incomplete_test.cpp new file mode 100644 index 00000000..fb72a281 --- /dev/null +++ b/src/boost/libs/align/test/aligned_allocator_adaptor_incomplete_test.cpp @@ -0,0 +1,74 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include + +template +class A { +public: + typedef T value_type; + typedef T* pointer; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind { + typedef A other; + }; + + A(int state) + : state_(state) { } + + template + A(const A& other) + : state_(other.state()) { } + + T* allocate(std::size_t size, const void* = 0) { + return static_cast(::operator new(sizeof(T) * size)); + } + + void deallocate(T* ptr, std::size_t) { + ::operator delete(ptr); + } + + int state() const { + return state_; + } + +private: + int state_; +}; + +template +inline bool +operator==(const A& a, const A& b) +{ + return a.state() == b.state(); +} + +template +inline bool +operator!=(const A& a, const A& b) +{ + return !(a == b); +} + +struct S; +struct V { }; + +void value_test() +{ + boost::alignment::aligned_allocator_adaptor > a(A(1)); + (void)a; +} + +void rebind_test() +{ + boost::alignment::aligned_allocator_adaptor > a(A(1)); + boost::alignment::aligned_allocator_adaptor >::rebind::other r(a); + (void)r; +} diff --git a/src/boost/libs/align/test/aligned_allocator_adaptor_test.cpp b/src/boost/libs/align/test/aligned_allocator_adaptor_test.cpp new file mode 100644 index 00000000..720cb657 --- /dev/null +++ b/src/boost/libs/align/test/aligned_allocator_adaptor_test.cpp @@ -0,0 +1,156 @@ +/* +Copyright 2014 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include +#include + +template +class A { +public: + typedef T value_type; + typedef T* pointer; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind { + typedef A other; + }; + + A(int state) + : state_(state) { } + + template + A(const A& other) + : state_(other.state()) { } + + T* allocate(std::size_t size, const void* = 0) { + return static_cast(::operator new(sizeof(T) * size)); + } + + void deallocate(T* ptr, std::size_t) { + ::operator delete(ptr); + } + + void construct(T* ptr, const T& value) { + ::new(static_cast(ptr)) T(value); + } + + void destroy(T* ptr) { + ptr->~T(); + } + + int state() const { + return state_; + } + +private: + int state_; +}; + +template +inline bool +operator==(const A& a, const A& b) +{ + return a.state() == b.state(); +} + +template +inline bool +operator!=(const A& a, const A& b) +{ + return !(a == b); +} + +template +void test_allocate() +{ + { + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + int* p = a.allocate(1); + BOOST_TEST(p != 0); + BOOST_TEST(boost::alignment::is_aligned(p, Alignment)); + std::memset(p, 0, 1); + a.deallocate(p, 1); + } + { + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + int* p = a.allocate(1); + int* q = a.allocate(1, p); + BOOST_TEST(q != 0); + BOOST_TEST(boost::alignment::is_aligned(q, Alignment)); + std::memset(q, 0, 1); + a.deallocate(q, 1); + a.deallocate(p, 1); + } + { + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + int* p = a.allocate(0); + a.deallocate(p, 0); + } +} + +template +void test_construct() +{ + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + int* p = a.allocate(1); + a.construct(p, 1); + BOOST_TEST(*p == 1); + a.destroy(p); + a.deallocate(p, 1); +} + +template +void test_constructor() +{ + { + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + boost::alignment::aligned_allocator_adaptor, Alignment> b(a); + BOOST_TEST(b == a); + } + { + A a(5); + boost::alignment::aligned_allocator_adaptor, Alignment> b(a); + BOOST_TEST(b.base() == a); + } +} + +template +void test_rebind() +{ + boost::alignment::aligned_allocator_adaptor, Alignment> a(5); + typename boost::alignment::aligned_allocator_adaptor, + Alignment>::template rebind::other b(a); + BOOST_TEST(b == a); +} + +template +void test() +{ + test_allocate(); + test_construct(); + test_constructor(); + test_rebind(); +} + +int main() +{ + test<1>(); + test<2>(); + test<4>(); + test<8>(); + test<16>(); + test<32>(); + test<64>(); + test<128>(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/aligned_allocator_incomplete_test.cpp b/src/boost/libs/align/test/aligned_allocator_incomplete_test.cpp new file mode 100644 index 00000000..3ab6135e --- /dev/null +++ b/src/boost/libs/align/test/aligned_allocator_incomplete_test.cpp @@ -0,0 +1,24 @@ +/* +Copyright 2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include + +struct S; +struct V { }; + +void value_test() +{ + boost::alignment::aligned_allocator a; + (void)a; +} + +void rebind_test() +{ + boost::alignment::aligned_allocator a; + boost::alignment::aligned_allocator::rebind::other r(a); + (void)r; +} diff --git a/src/boost/libs/align/test/aligned_allocator_test.cpp b/src/boost/libs/align/test/aligned_allocator_test.cpp new file mode 100644 index 00000000..c8fdf8ed --- /dev/null +++ b/src/boost/libs/align/test/aligned_allocator_test.cpp @@ -0,0 +1,106 @@ +/* +Copyright 2014 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include + +template +void test_allocate() +{ + { + boost::alignment::aligned_allocator a; + int* p = a.allocate(1); + BOOST_TEST(p != 0); + BOOST_TEST(boost::alignment::is_aligned(p, Alignment)); + std::memset(p, 0, 1); + a.deallocate(p, 1); + } + { + boost::alignment::aligned_allocator a; + int* p = a.allocate(0); + a.deallocate(p, 0); + } +} + +template +void test_construct() +{ + boost::alignment::aligned_allocator a; + int* p = a.allocate(1); + a.construct(p, 1); + BOOST_TEST(*p == 1); + a.destroy(p); + a.deallocate(p, 1); +} + +template +void test_constructor() +{ + { + boost::alignment::aligned_allocator a1; + boost::alignment::aligned_allocator a2(a1); + BOOST_TEST(a2 == a1); + } + { + boost::alignment::aligned_allocator a1; + boost::alignment::aligned_allocator a2(a1); + BOOST_TEST(a2 == a1); + } + { + boost::alignment::aligned_allocator a1; + boost::alignment::aligned_allocator a2(a1); + BOOST_TEST(a2 == a1); + } +} + +template +void test_rebind() +{ + { + boost::alignment::aligned_allocator a1; + typename boost::alignment::aligned_allocator::template rebind::other a2(a1); + BOOST_TEST(a2 == a1); + } + { + boost::alignment::aligned_allocator a1; + typename boost::alignment::aligned_allocator::template rebind::other a2(a1); + BOOST_TEST(a2 == a1); + } + { + boost::alignment::aligned_allocator a1; + typename boost::alignment::aligned_allocator::template rebind::other a2(a1); + BOOST_TEST(a2 == a1); + } +} + +template +void test() +{ + test_allocate(); + test_construct(); + test_constructor(); + test_rebind(); +} + +int main() +{ + test<1>(); + test<2>(); + test<4>(); + test<8>(); + test<16>(); + test<32>(); + test<64>(); + test<128>(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/aligned_delete_test.cpp b/src/boost/libs/align/test/aligned_delete_test.cpp new file mode 100644 index 00000000..0a00b71a --- /dev/null +++ b/src/boost/libs/align/test/aligned_delete_test.cpp @@ -0,0 +1,51 @@ +/* +Copyright 2014 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include +#include + +class type { +public: + static unsigned count; + + type() { + ++count; + } + + ~type() { + --count; + } + +private: + type(const type&); + type& operator=(const type&); +}; + +unsigned type::count = 0; + +int main() +{ + { + void* p = boost::alignment::aligned_alloc(1, 1); + char* q = ::new(p) char; + boost::alignment::aligned_delete()(q); + } + { + enum { + N = boost::alignment::alignment_of::value + }; + void* p = boost::alignment::aligned_alloc(N, sizeof(type)); + type* q = ::new(p) type; + BOOST_TEST(type::count == 1); + boost::alignment::aligned_delete()(q); + BOOST_TEST(type::count == 0); + } + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/alignment_of_test.cpp b/src/boost/libs/align/test/alignment_of_test.cpp new file mode 100644 index 00000000..7df84c6c --- /dev/null +++ b/src/boost/libs/align/test/alignment_of_test.cpp @@ -0,0 +1,219 @@ +/* +Copyright 2014 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +template +struct remove_reference { + typedef T type; +}; +#endif + +template +struct remove_all_extents { + typedef T type; +}; + +template +struct remove_all_extents { + typedef typename remove_all_extents::type type; +}; + +template +struct remove_all_extents { + typedef typename remove_all_extents::type type; +}; + +template +struct remove_cv { + typedef T type; +}; + +template +struct remove_cv { + typedef T type; +}; + +template +struct remove_cv { + typedef T type; +}; + +template +struct remove_cv { + typedef T type; +}; + +template +struct offset_value { + char value; + typename remove_cv::type>::type>::type object; +}; + +template +void test_type() +{ + enum { + N = boost::alignment::alignment_of::value + }; + BOOST_TEST(offsetof(offset_value, object) == N); +} + +template +void test_reference() +{ + test_type(); + test_type(); + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + test_type(); +#endif +} + +template +void test_array() +{ + test_reference(); + test_reference(); + test_type(); +} + +template +void test_cv() +{ + test_array(); + test_array(); + test_array(); + test_array(); +} + +template +struct Struct { + T t; +}; + +template +union Union { + T t; +}; + +template +void test() +{ + test_cv(); + test_cv >(); + test_cv >(); +} + +void test_integral() +{ + test(); + test(); + test(); + test(); + test(); + +#if !defined(BOOST_NO_CXX11_CHAR16_T) + test(); +#endif + +#if !defined(BOOST_NO_CXX11_CHAR32_T) + test(); +#endif + + test(); + test(); + test(); + test(); + test(); + test(); + +#if !defined(BOOST_NO_LONG_LONG) + test(); + test(); +#endif +} + +void test_floating_point() +{ + test(); + test(); + test(); +} + +void test_nullptr_t() +{ +#if !defined(BOOST_NO_CXX11_NULLPTR) && \ + !defined(BOOST_NO_CXX11_DECLTYPE) + test(); +#endif +} + +class X; + +void test_pointer() +{ + test(); + test(); + test(); + test(); + test(); +} + +void test_member_pointer() +{ + test(); + test(); +} + +enum E { + V = 1 +}; + +void test_enum() +{ + test(); +} + +struct S { }; +class C { }; +union U { }; + +void test_class() +{ + test(); + test(); + test(); +} + +int main() +{ + test_integral(); + test_floating_point(); + test_nullptr_t(); + test_pointer(); + test_member_pointer(); + test_enum(); + test_class(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/assume_aligned_test.cpp b/src/boost/libs/align/test/assume_aligned_test.cpp new file mode 100644 index 00000000..bf863399 --- /dev/null +++ b/src/boost/libs/align/test/assume_aligned_test.cpp @@ -0,0 +1,61 @@ +/* +Copyright 2015 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include + +void* test1(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 1); + return p; +} + +void* test2(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 2); + return p; +} + +void* test4(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 4); + return p; +} + +void* test8(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 8); + return p; +} + +void* test16(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 16); + return p; +} + +void* test32(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 32); + return p; +} + +void* test64(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 64); + return p; +} + +void* test128(void* p) +{ + BOOST_ALIGN_ASSUME_ALIGNED(p, 128); + return p; +} + +int main() +{ + return 0; +} diff --git a/src/boost/libs/align/test/is_aligned_integral_test.cpp b/src/boost/libs/align/test/is_aligned_integral_test.cpp new file mode 100644 index 00000000..862feac2 --- /dev/null +++ b/src/boost/libs/align/test/is_aligned_integral_test.cpp @@ -0,0 +1,63 @@ +/* +Copyright 2019 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include + +template +struct A { }; + +template +void test(A) +{ + T v1 = N; + BOOST_TEST(boost::alignment::is_aligned(v1, N)); + T v2 = N - 1; + BOOST_TEST(!boost::alignment::is_aligned(v2, N)); + T v3 = N + 1; + BOOST_TEST(!boost::alignment::is_aligned(v3, N)); + T v4 = N + N; + BOOST_TEST(boost::alignment::is_aligned(v4, N)); +} + +template +void test(A<1>) +{ + T v = 1; + BOOST_TEST(boost::alignment::is_aligned(v, 1)); +} + +template +void test() +{ + test(A<1>()); + test(A<2>()); + test(A<4>()); + test(A<8>()); + test(A<16>()); + test(A<32>()); + test(A<64>()); + test(A<128>()); +} + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); +#if !defined(BOOST_NO_LONG_LONG) + test(); + test(); +#endif + test(); + test(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/align/test/is_aligned_test.cpp b/src/boost/libs/align/test/is_aligned_test.cpp new file mode 100644 index 00000000..3098e8d0 --- /dev/null +++ b/src/boost/libs/align/test/is_aligned_test.cpp @@ -0,0 +1,73 @@ +/* +Copyright 2014-2015 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#include +#include +#include +#include + +template +struct A { }; + +template +void test(char* p, A) +{ + BOOST_TEST(boost::alignment::is_aligned(p, N)); + BOOST_TEST(!boost::alignment::is_aligned(p + 1, N)); +} + +void test(char* p, A<1>) +{ + BOOST_TEST(boost::alignment::is_aligned(p, 1)); +} + +template +void test() +{ + T o; + test(reinterpret_cast(&o), + A::value>()); +} + +class X; + +int main() +{ + test(); + test(); + test(); +#if !defined(BOOST_NO_CXX11_CHAR16_T) + test(); +#endif +#if !defined(BOOST_NO_CXX11_CHAR32_T) + test(); +#endif + test(); + test(); + test(); +#if !defined(BOOST_NO_LONG_LONG) && !defined(_MSC_VER) + test(); +#endif + test(); +#if !defined(BOOST_MSVC) + test(); + test(); +#endif + test(); + test(); + test(); + test(); + test(); +#if !defined(_MSC_VER) || !defined(__clang__) +#if !defined(BOOST_MSVC) + test(); + test(); +#endif +#endif + + return boost::report_errors(); +} -- cgit v1.2.3