-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18b82d3
commit 640e089
Showing
8 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ data/*.dat | |
.vscode/* | ||
*.pdb | ||
*.ilk | ||
.vs/ | ||
.vs/ | ||
run-tests* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(CmrCache) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
|
||
include_directories(${PROJECT_SOURCE_DIR}/vendor) | ||
|
||
find_package(Boost REQUIRED COMPONENTS system thread) | ||
|
||
if(Boost_FOUND) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
link_directories(${Boost_LIBRARY_DIRS}) | ||
endif() | ||
|
||
set(SOURCE_DIR ${PROJECT_SOURCE_DIR}/) | ||
|
||
file(GLOB SRCS ${SOURCE_DIR}/*.cpp) | ||
|
||
add_executable(cmr_cache ${SRCS}) | ||
|
||
include_directories(${Boost_INCLUDE_DIRS}) | ||
|
||
target_link_libraries(cmr_cache ${Boost_LIBRARIES}) | ||
|
||
if (UNIX AND NOT WIN32) | ||
target_link_libraries(cmr_cache pthread) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2024 Gabriel Camargo | ||
* | ||
* 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 | ||
* 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 "test_cache.cpp" | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2024 Gabriel Camargo | ||
* | ||
* 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 | ||
* 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 <gtest/gtest.h> | ||
#include "../../core/cache/cache.cpp" | ||
|
||
|
||
TEST(CacheTest, SetCommand) { | ||
Cache cache; | ||
EXPECT_TRUE(cache.set("tests", "key1", "value1")); | ||
EXPECT_TRUE(cache.set("tests", "key2", "value2")); | ||
} | ||
|
||
|
||
TEST(CacheTest, GetCommand) { | ||
Cache cache; | ||
cache.set("tests", "key1", "value1"); | ||
cache.set("tests", "key2", "value2"); | ||
|
||
EXPECT_EQ(cache.get("tests", "key1"), "value1"); | ||
EXPECT_EQ(cache.get("tests", "key2"), "value2"); | ||
EXPECT_EQ(cache.get("tests", "key3"), ""); | ||
} | ||
|
||
TEST(CacheTest, DelCommand) { | ||
Cache cache; | ||
cache.set("tests", "key1", "value1"); | ||
cache.set("tests", "key2", "value2"); | ||
|
||
EXPECT_TRUE(cache.del("tests", "key1")); | ||
EXPECT_EQ(cache.get("tests", "key1"), ""); | ||
EXPECT_TRUE(cache.del("tests", "key3")); | ||
} |