Fix moves of any when value isInBuffer

This was copying the pointer to the other's value in other.buffer.
This commit is contained in:
Ben Clayton
2020-06-10 13:51:21 +01:00
parent 2f607e077a
commit f0c28f93dd
2 changed files with 27 additions and 2 deletions

View File

@@ -40,6 +40,7 @@ TEST(Any, EmptyConstruct) {
ASSERT_FALSE(any.is<dap::integer>());
ASSERT_FALSE(any.is<dap::number>());
ASSERT_FALSE(any.is<dap::object>());
ASSERT_FALSE(any.is<dap::string>());
ASSERT_FALSE(any.is<dap::array<dap::integer>>());
ASSERT_FALSE(any.is<dap::AnyTestObject>());
}
@@ -62,6 +63,12 @@ TEST(Any, Number) {
ASSERT_EQ(any.get<dap::number>(), dap::number(123.0f));
}
TEST(Any, String) {
dap::any any(dap::string("hello world"));
ASSERT_TRUE(any.is<dap::string>());
ASSERT_EQ(any.get<dap::string>(), dap::string("hello world"));
}
TEST(Any, Array) {
using array = dap::array<dap::integer>;
dap::any any(array({10, 20, 30}));
@@ -116,6 +123,12 @@ TEST(Any, Assign) {
ASSERT_TRUE(any.is<dap::AnyTestObject>());
ASSERT_EQ(any.get<dap::AnyTestObject>().i, 5);
ASSERT_EQ(any.get<dap::AnyTestObject>().n, 3.0);
any = dap::string("hello world");
ASSERT_FALSE(any.is<dap::integer>());
ASSERT_FALSE(any.is<dap::boolean>());
ASSERT_FALSE(any.is<dap::AnyTestObject>());
ASSERT_TRUE(any.is<dap::string>());
ASSERT_EQ(any.get<dap::string>(), dap::string("hello world"));
}
TEST(Any, Reset) {