5 #ifndef NDS2_CLIENT_NDS1_COMMON_UTILS_HH
6 #define NDS2_CLIENT_NDS1_COMMON_UTILS_HH
8 #include "common/utils.hh"
17 template <
typename It >
22 for ( It cur = begin; cur != end; ++cur, ++length )
24 if ( *cur ==
'\0' || *cur ==
' ' )
39 #ifdef _NDS_IMPL_ENABLE_CATCH_TESTS_
44 #include "common/utils.hh"
47 TEST_CASE(
"There are several fields in NDS1 that are ' ' or 0 padded, given a "
48 "fixed length buffer, identify when the string ends",
52 std::vector< char > buf1{
53 '0',
'1',
'2',
'3',
'4',
'5',
' ',
' ',
' ',
' '
59 REQUIRE( span1.
data( ) == buf1.data( ) );
60 REQUIRE( span1.
size( ) == 6 );
62 std::vector< char > buf2{
'0',
'1',
'2',
'3',
'4',
'5', 0, 0, 0, 0 };
67 REQUIRE( span2.
data( ) == buf2.data( ) );
68 REQUIRE( span2.
size( ) == 6 );
70 std::vector< char > buf3{
71 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
77 REQUIRE( span3.
data( ) == buf3.data( ) );
78 REQUIRE( span3.
size( ) == 10 );
80 std::vector< char > buf4;
81 buf4.push_back(
'0' );
86 REQUIRE( span4.
data( ) == buf4.data( ) );
87 REQUIRE( span4.
size( ) == 0 );
90 #endif // _NDS_IMPL_ENABLE_CATCH_TESTS_
92 #endif // NDS2_CLIENT_NDS1_COMMON_UTILS_HH
TEST_CASE("daq_strlcpy copies strings safely when buffers are sufficiently large")
Definition: test_bsd_string.cc:9
nds_impl::common::Span< char > identify_padded_string(It begin, It end)
Definition: utils.hh:19
std::size_t size_type
Definition: utils.hh:139
pointer data() const
Definition: utils.hh:169
size_type size() const
Definition: utils.hh:154