#include "log.h" #include "element.h" #include "stream.h" #include #include #include #include #include class TLogElementTest: public TTestBase { UNIT_TEST_SUITE(TLogElementTest); UNIT_TEST(TestMoveCtor); UNIT_TEST(TestWith); UNIT_TEST_SUITE_END(); public: void TestMoveCtor(); void TestWith(); }; UNIT_TEST_SUITE_REGISTRATION(TLogElementTest); void TLogElementTest::TestMoveCtor() { TStringStream output; TLog log(MakeHolder(&output)); THolder src = MakeHolder(&log); TString message = "Hello, World!"; (*src) << message; THolder dst = MakeHolder(std::move(*src)); src.Destroy(); UNIT_ASSERT(output.Str() == ""); dst.Destroy(); UNIT_ASSERT(output.Str() == message); } void TLogElementTest::TestWith() { TStringStream output; TLog log(MakeHolder(&output)); THolder src = MakeHolder(&log); TString message = "Hello, World!"; (*src).With("Foo", "Bar").With("Foo", "Baz") << message; src.Destroy(); UNIT_ASSERT(output.Str() == "Hello, World!; Foo=Bar; Foo=Baz; "); }