Don't make anonymous frames from leading or trailing '/' in keys.

This commit is contained in:
John Ralls 2015-07-22 22:05:13 -07:00
parent 0db17f1094
commit b3bc68dc1b
3 changed files with 13 additions and 2 deletions

View File

@ -909,7 +909,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
xaccTransCommitEdit (clone);
g_free (cleanup->msg);
g_free (check->msg);
check->msg = g_strdup ("[xaccTransEqual] kvp frames differ:\n{\n => KVP_VALUE_FRAME({\n qux => KVP_VALUE_FRAME({\n quux => KVP_VALUE_FRAME({\n corge => KVP_VALUE_DOUBLE(654.321),\n}\n),\n}\n),\n}\n),\n notes => KVP_VALUE_STRING(Salt pork sausage),\n}\n\n\nvs\n\n{\n => KVP_VALUE_FRAME({\n qux => KVP_VALUE_FRAME({\n quux => KVP_VALUE_FRAME({\n corge => KVP_VALUE_DOUBLE(123.456),\n}\n),\n}\n),\n}\n),\n notes => KVP_VALUE_STRING(Salt pork sausage),\n}\n");
check->msg = g_strdup ("[xaccTransEqual] kvp frames differ:\n{\n notes => KVP_VALUE_STRING(Salt pork sausage),\n qux => KVP_VALUE_FRAME({\n quux => KVP_VALUE_FRAME({\n corge => KVP_VALUE_DOUBLE(654.321),\n}\n),\n}\n),\n}\n\n\nvs\n\n{\n notes => KVP_VALUE_STRING(Salt pork sausage),\n qux => KVP_VALUE_FRAME({\n quux => KVP_VALUE_FRAME({\n corge => KVP_VALUE_DOUBLE(123.456),\n}\n),\n}\n),\n}\n");
g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));

View File

@ -73,7 +73,8 @@ make_vector(std::string key)
Path path;
for (auto length = key.find(delim); length != std::string::npos;)
{
path.push_back(key.substr(0, length));
if (length != 0)
path.push_back(key.substr(0, length));
key = key.substr(length + 1);
length = key.find(delim);
}

View File

@ -103,6 +103,16 @@ TEST_F (KvpFrameTest, SetPathSlash)
delete v1;
}
TEST_F (KvpFrameTest, SetPathIgnoreBeginEndSlash)
{
Path path1 {"top", "/second/", "twenty-first"};
Path path2 {"top", "second", "twenty-first"};
auto v1 = new KvpValueImpl {15.0};
EXPECT_EQ (nullptr, t_root.set(path1, v1));
EXPECT_EQ (v1, t_root.get_slot(path2));
}
TEST_F (KvpFrameTest, SetPathWithCreate)
{
Path path1 {"top", "second", "twenty-first"};