]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/system/test/snprintf_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / system / test / snprintf_test.cpp
1 // Copyright 2021 Peter Dimov.
2 // Distributed under the Boost Software License, Version 1.0.
3 // http://www.boost.org/LICENSE_1_0.txt
4
5 #include <boost/system/detail/snprintf.hpp>
6 #include <boost/core/lightweight_test.hpp>
7
8 int main()
9 {
10 {
11 char buffer[ 64 ];
12 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
13
14 BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
15 }
16
17 {
18 char buffer[ 64 ];
19 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
20
21 BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
22 }
23
24 {
25 char buffer[ 15 ];
26 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
27
28 BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
29 }
30
31 {
32 char buffer[ 14 ];
33 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
34
35 BOOST_TEST_CSTR_EQ( buffer, "...xy...151.." );
36 }
37
38 {
39 char buffer[ 5 ];
40 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
41
42 BOOST_TEST_CSTR_EQ( buffer, "...x" );
43 }
44
45 {
46 char buffer[ 1 ];
47 boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
48
49 BOOST_TEST_CSTR_EQ( buffer, "" );
50 }
51
52 {
53 char buffer[ 1 ] = { 'Q' };
54 boost::system::detail::snprintf( buffer, 0, "...%s...%d...", "xy", 151 );
55
56 BOOST_TEST_EQ( buffer[0], 'Q' );
57 }
58
59 return boost::report_errors();
60 }