Skip to content
Snippets Groups Projects
Commit 4b27a9c5 authored by Irene Zhang's avatar Irene Zhang
Browse files

updating with a test case for kvstore backend, will add more later

parent c111bf53
No related branches found
No related tags found
No related merge requests found
...@@ -4,3 +4,5 @@ SRCS += $(addprefix $(d), \ ...@@ -4,3 +4,5 @@ SRCS += $(addprefix $(d), \
kvstore.cc lockserver.cc versionstore.cc) kvstore.cc lockserver.cc versionstore.cc)
LIB-backend := $(o)kvstore.o $(o)versionstore.o $(o)lockserver.o LIB-backend := $(o)kvstore.o $(o)versionstore.o $(o)lockserver.o
include $(d)tests/Rules.mk
\ No newline at end of file
d := $(dir $(lastword $(MAKEFILE_LIST)))
#
# gtest-based tests
#
GTEST_SRCS += $(addprefix $(d), \
kvstore-test.cc)
$(d)kvstore-test: $(o)kvstore-test.o $(LIB-transport) $(LIB-common) $(LIB-backend) $(GTEST_MAIN)
TEST_BINS += $(d)kvstore-test
\ No newline at end of file
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
/***********************************************************************
*
* kvstore-test.cc:
* test cases for simple key-value store class
*
* Copyright 2015 Irene Zhang <iyzhang@cs.washington.edu>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************/
#include "store/common/backend/kvstore.h"
#include <gtest/gtest.h>
TEST(KVStore, Put)
{
KVStore store;
EXPECT_TRUE(store.put("test1", "abc"));
EXPECT_TRUE(store.put("test2", "def"));
EXPECT_TRUE(store.put("test1", "xyz"));
EXPECT_TRUE(store.put("test3", "abc"));
}
TEST(KVStore, Get)
{
KVStore store;
std::string val;
EXPECT_TRUE(store.put("test1", "abc"));
EXPECT_TRUE(store.get("test1", val));
EXPECT_EQ(val, "abc");
EXPECT_TRUE(store.put("test2", "def"));
EXPECT_TRUE(store.get("test2", val));
EXPECT_EQ(val, "def");
EXPECT_TRUE(store.put("test1", "xyz"));
EXPECT_TRUE(store.get("test1", val));
EXPECT_EQ(val, "xyz");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment