-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cmake/tests and onboard a edit distance solution with compressed …
…memory usage
- Loading branch information
1 parent
b639b72
commit 1d8f4eb
Showing
8 changed files
with
101 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
.idea |
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,10 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
project(LeetCode VERSION 1.0) | ||
|
||
set (CMAKE_CXX_STANDARD 11) | ||
|
||
include_directories(PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
enable_testing() | ||
add_subdirectory(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
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,12 @@ | ||
include(FetchContent) | ||
|
||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip | ||
) | ||
|
||
FetchContent_MakeAvailable(googletest) | ||
|
||
include(GoogleTest) | ||
|
||
add_subdirectory(Dynamic_Programming) |
17 changes: 17 additions & 0 deletions
17
tests/Dynamic_Programming/072.Edit-Distance/072.Edit-Distance.t.cpp
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,17 @@ | ||
#include "gtest/gtest.h" | ||
#include <climits> // INT_MAX | ||
#include <algorithm> // std::min({}) | ||
#include <vector> | ||
#include <string> | ||
using namespace std; | ||
|
||
#include <Dynamic_Programming/072.Edit-Distance/072.Edit-Distance.cpp> | ||
|
||
TEST(edit_distance_72_test, I) | ||
{ | ||
std::string word1 = "horse"; | ||
std::string word2 = "ros"; | ||
|
||
ASSERT_EQ(Solution().minDistance2(word1, word2), 3); | ||
ASSERT_EQ(Solution().minDistance(word1, word2), 3); | ||
} |
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,9 @@ | ||
set(BINARY edit_distance_test) | ||
|
||
add_executable(${BINARY} 072.Edit-Distance.t.cpp) | ||
|
||
target_link_libraries(${BINARY} gtest_main) | ||
|
||
include(GoogleTest) | ||
|
||
gtest_discover_tests(${BINARY}) |
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 @@ | ||
add_subdirectory(072\.Edit-Distance) |