Skip to content

Commit 378dc90

Browse files
committed
Add lightweight_test_eq_ptr; tests EQ and NE with various pointer types.
1 parent cc765ab commit 378dc90

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

test/Jamfile.v2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ run lightweight_test_with_test.cpp
177177
: : : $(pedantic-errors) ;
178178
run-fail lightweight_test_with_fail.cpp ;
179179

180+
run lightweight_test_eq_ptr.cpp
181+
: : : $(pedantic-errors) ;
182+
180183
run is_same_test.cpp ;
181184

182185
run typeinfo_test.cpp ;

test/lightweight_test_eq_ptr.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright 2025 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/core/lightweight_test.hpp>
6+
#include <boost/config.hpp>
7+
8+
int main()
9+
{
10+
{
11+
char const* p = "12";
12+
13+
BOOST_TEST_EQ( p, p );
14+
BOOST_TEST_NE( p, p + 1 );
15+
}
16+
17+
{
18+
wchar_t const* p = L"12";
19+
20+
BOOST_TEST_EQ( p, p );
21+
BOOST_TEST_NE( p, p + 1 );
22+
}
23+
24+
#if !defined( BOOST_NO_CXX11_CHAR16_T )
25+
26+
{
27+
char16_t const* p = u"12";
28+
29+
BOOST_TEST_EQ( p, p );
30+
BOOST_TEST_NE( p, p + 1 );
31+
}
32+
33+
#endif
34+
35+
#if !defined( BOOST_NO_CXX11_CHAR32_T )
36+
37+
{
38+
char32_t const* p = U"12";
39+
40+
BOOST_TEST_EQ( p, p );
41+
BOOST_TEST_NE( p, p + 1 );
42+
}
43+
44+
#endif
45+
46+
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
47+
48+
{
49+
char8_t const* p = u8"12";
50+
51+
BOOST_TEST_EQ( p, p );
52+
BOOST_TEST_NE( p, p + 1 );
53+
}
54+
55+
#endif
56+
57+
{
58+
int v;
59+
int volatile* p = &v;
60+
61+
BOOST_TEST_EQ( p, p );
62+
BOOST_TEST_NE( p, p + 1 );
63+
}
64+
65+
{
66+
int v;
67+
int const volatile* p = &v;
68+
69+
BOOST_TEST_EQ( p, p );
70+
BOOST_TEST_NE( p, p + 1 );
71+
}
72+
73+
{
74+
char v;
75+
char volatile* p = &v;
76+
77+
BOOST_TEST_EQ( p, p );
78+
BOOST_TEST_NE( p, p + 1 );
79+
}
80+
81+
{
82+
char v;
83+
char const volatile* p = &v;
84+
85+
BOOST_TEST_EQ( p, p );
86+
BOOST_TEST_NE( p, p + 1 );
87+
}
88+
89+
{
90+
wchar_t v;
91+
wchar_t volatile* p = &v;
92+
93+
BOOST_TEST_EQ( p, p );
94+
BOOST_TEST_NE( p, p + 1 );
95+
}
96+
97+
{
98+
wchar_t v;
99+
wchar_t const volatile* p = &v;
100+
101+
BOOST_TEST_EQ( p, p );
102+
BOOST_TEST_NE( p, p + 1 );
103+
}
104+
105+
return boost::report_errors();
106+
}

0 commit comments

Comments
 (0)