From 6188a54ce95b47cc6bd398d7f2eb45d061857e45 Mon Sep 17 00:00:00 2001 From: costan Date: Thu, 21 Mar 2019 16:15:30 -0700 Subject: leveldb: Add tests for empty keys and values. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=239695281 --- db/db_test.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'db') diff --git a/db/db_test.cc b/db/db_test.cc index e889a74..3ab4aee 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -558,6 +558,26 @@ TEST(DBTest, Empty) { } while (ChangeOptions()); } +TEST(DBTest, EmptyKey) { + do { + ASSERT_OK(Put("", "v1")); + ASSERT_EQ("v1", Get("")); + ASSERT_OK(Put("", "v2")); + ASSERT_EQ("v2", Get("")); + } while (ChangeOptions()); +} + +TEST(DBTest, EmptyValue) { + do { + ASSERT_OK(Put("key", "v1")); + ASSERT_EQ("v1", Get("key")); + ASSERT_OK(Put("key", "")); + ASSERT_EQ("", Get("key")); + ASSERT_OK(Put("key", "v2")); + ASSERT_EQ("v2", Get("key")); + } while (ChangeOptions()); +} + TEST(DBTest, ReadWrite) { do { ASSERT_OK(Put("foo", "v1")); -- cgit v1.2.1