]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/encoding/test_sstring.h
4 #include "common/sstring.hh"
6 // wrapper for sstring that implements the dencoder interface
7 class sstring_wrapper
{
8 using sstring16
= basic_sstring
<char, uint32_t, 16>;
10 using sstring24
= basic_sstring
<unsigned char, uint16_t, 24>;
13 sstring_wrapper() = default;
14 sstring_wrapper(sstring16
&& s1
, sstring24
&& s2
)
15 : s1(std::move(s1
)), s2(std::move(s2
))
18 DENC(sstring_wrapper
, w
, p
) {
24 void dump(Formatter
* f
) {
25 f
->dump_string("s1", s1
.c_str());
26 f
->dump_string("s2", reinterpret_cast<const char*>(s2
.c_str()));
28 static void generate_test_instances(std::list
<sstring_wrapper
*>& ls
) {
29 ls
.push_back(new sstring_wrapper());
30 // initialize sstrings that fit in internal storage
31 constexpr auto cstr6
= "abcdef";
32 ls
.push_back(new sstring_wrapper(sstring16
{cstr6
}, sstring24
{cstr6
}));
33 // initialize sstrings that overflow into external storage
34 constexpr auto cstr26
= "abcdefghijklmnopqrstuvwxyz";
35 ls
.push_back(new sstring_wrapper(sstring16
{cstr26
}, sstring24
{cstr26
}));
38 WRITE_CLASS_DENC(sstring_wrapper
)