From 18764e4ac308da093e849969ab749d53b9f2e7aa Mon Sep 17 00:00:00 2001 From: Luc Pelletier Date: Sun, 19 Dec 2021 12:33:04 -0500 Subject: [PATCH] Add test for dynamic_format_arg_store's move ctor --- test/args-test.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/args-test.cc b/test/args-test.cc index e793cb5c..32098dfb 100644 --- a/test/args-test.cc +++ b/test/args-test.cc @@ -171,3 +171,21 @@ TEST(args_test, throw_on_copy) { } EXPECT_EQ(fmt::vformat("{}", store), "foo"); } + +TEST(args_test, move_constructor) { + const int test_integer = 42; + const char* const test_c_string = "foo"; + + auto store_uptr = + std::make_unique>(); + store_uptr->push_back(test_integer); + store_uptr->push_back(std::string(test_c_string)); + store_uptr->push_back(fmt::arg("a1", test_c_string)); + + fmt::dynamic_format_arg_store moved_store( + std::move(*store_uptr)); + store_uptr.reset(); + EXPECT_EQ( + fmt::vformat("{} {} {a1}", moved_store), + std::to_string(test_integer) + " " + test_c_string + " " + test_c_string); +}