mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-10-16 18:56:56 +02:00
Add user-defined string literals to create buffers
This commit is contained in:
@@ -250,6 +250,38 @@ TEST_CASE("const_buffer creation with str_buffer", "[buffer]")
|
||||
CHECK(std::string(static_cast<const char*>(b2.data()), b2.size()) == "hello");
|
||||
}
|
||||
|
||||
TEST_CASE("const_buffer creation with zbuf string literal char", "[buffer]")
|
||||
{
|
||||
using namespace zmq::literals;
|
||||
constexpr zmq::const_buffer b = "hello"_zbuf;
|
||||
CHECK(b.size() == 5);
|
||||
CHECK(std::memcmp(b.data(), "hello", b.size()) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("const_buffer creation with zbuf string literal wchar_t", "[buffer]")
|
||||
{
|
||||
using namespace zmq::literals;
|
||||
constexpr zmq::const_buffer b = L"hello"_zbuf;
|
||||
CHECK(b.size() == 5 * sizeof(wchar_t));
|
||||
CHECK(std::memcmp(b.data(), L"hello", b.size()) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("const_buffer creation with zbuf string literal char16_t", "[buffer]")
|
||||
{
|
||||
using namespace zmq::literals;
|
||||
constexpr zmq::const_buffer b = u"hello"_zbuf;
|
||||
CHECK(b.size() == 5 * sizeof(char16_t));
|
||||
CHECK(std::memcmp(b.data(), u"hello", b.size()) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("const_buffer creation with zbuf string literal char32_t", "[buffer]")
|
||||
{
|
||||
using namespace zmq::literals;
|
||||
constexpr zmq::const_buffer b = U"hello"_zbuf;
|
||||
CHECK(b.size() == 5 * sizeof(char32_t));
|
||||
CHECK(std::memcmp(b.data(), U"hello", b.size()) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("buffer of structs", "[buffer]")
|
||||
{
|
||||
struct some_pod
|
||||
|
Reference in New Issue
Block a user