-
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
Showing
24 changed files
with
188 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cmake_minimum_required (VERSION 3.11) | ||
|
||
enable_testing() | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(tests) |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
project(hmmm VERSION 0.0.1 DESCRIPTION "hmmm") | ||
|
||
add_subdirectory(midori) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
add_executable(hmmm | ||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp | ||
) | ||
target_link_libraries(hmmm midori) |
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,13 @@ | ||
project(midori VERSION 0.0.1 DESCRIPTION "hmmm") | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
set(SOURCES | ||
${CMAKE_CURRENT_SOURCE_DIR}/finite_automata.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/generator.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/lexer.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/regex.cpp | ||
) | ||
|
||
add_library(midori SHARED ${SOURCES}) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,45 @@ | ||
|
||
|
||
# Download and unpack googletest at configure time | ||
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) | ||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) | ||
if(result) | ||
message(FATAL_ERROR "CMake step for googletest failed: ${result}") | ||
endif() | ||
execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) | ||
if(result) | ||
message(FATAL_ERROR "Build step for googletest failed: ${result}") | ||
endif() | ||
|
||
# Prevent overriding the parent project's compiler/linker | ||
# settings on Windows | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
|
||
# Add googletest directly to our build. This defines | ||
# the gtest and gtest_main targets. | ||
add_subdirectory( | ||
${CMAKE_CURRENT_BINARY_DIR}/googletest-src | ||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build | ||
EXCLUDE_FROM_ALL | ||
) | ||
|
||
# The gtest/gtest_main targets carry header search path | ||
# dependencies automatically when using CMake 2.8.11 or | ||
# later. Otherwise we have to add them here ourselves. | ||
if (CMAKE_VERSION VERSION_LESS 2.8.11) | ||
include_directories("${gtest_SOURCE_DIR}/include") | ||
endif() | ||
|
||
|
||
# Now simply link against gtest or gtest_main as needed. Eg | ||
add_executable(hmmmtests driver.cpp) | ||
target_link_libraries(hmmmtests gtest_main) | ||
|
||
include_directories(AFTER "${CMAKE_SOURCE_DIR}/src") | ||
target_link_libraries(hmmmtests midori) | ||
|
||
add_test(NAME hmmmtests COMMAND hmmmtests) |
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,15 @@ | ||
cmake_minimum_required(VERSION 2.8.2) | ||
|
||
project(googletest-download NONE) | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG master | ||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" | ||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "" | ||
) |
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,49 @@ | ||
#include "gtest/gtest.h" | ||
#include "midori/interval_tree.h" | ||
|
||
class IntervalTreeTest : public ::testing::Test { | ||
public: | ||
typedef IntervalTree<Int, Int> IT; | ||
}; | ||
|
||
TEST_F(IntervalTreeTest, IsBalanced) { | ||
IT a; | ||
for (Int i = 0; i < 1000; i++) { | ||
a.insert(IT::Interval(i, i + 16), i); | ||
} | ||
for (Int i = 0; i < 1000; i++) { | ||
Int j = 1000 - i; | ||
a.insert(IT::Interval(j, j + 16), j); | ||
} | ||
a.invariants(); | ||
} | ||
|
||
TEST_F(IntervalTreeTest, Find) { | ||
IT a; | ||
for (Int i = 0; i < 1000; i++) { | ||
a.insert(IT::Interval(i, i + 2), i); | ||
} | ||
ASSERT_EQ(a.find(IT::Interval(700, 716))->size(), 19); | ||
ASSERT_EQ(a.all()->size(), 1000); | ||
} | ||
|
||
TEST_F(IntervalTreeTest, Pop) { | ||
IT a; | ||
for (Int i = 0; i < 1000; i++) { | ||
a.insert(IT::Interval(i, i + 16), i); | ||
} | ||
ASSERT_EQ(a.pop(IT::Interval(700, 702))->size(), 19); | ||
ASSERT_EQ(a.all()->size(), 1000 - 19); | ||
|
||
IT b; | ||
for (Int i = 0; i < 1000; i++) { | ||
b.insert(IT::Interval(i, i), i); | ||
} | ||
ASSERT_EQ(b.pop(IT::Interval(700, 716))->size(), 17); | ||
ASSERT_EQ(b.all()->size(), 1000 - 17); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |