Skip to content

Commit b278d5b

Browse files
committed
Moved files around and added interface library.
1 parent 6ed1f06 commit b278d5b

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
obj/*
2-
bin/*
1+
obj
2+
bin
33
*.depend
44
*_build_log.html
55
*.layout
@@ -10,11 +10,12 @@ main.hpp
1010
main.cpp
1111
*.png
1212
.vscode
13+
build
1314

14-
tests/bin/*
15-
tests/build/*
16-
tests/obj/*
15+
tests/bin
16+
tests/build
17+
tests/obj
1718
tests/*.cbp
1819
tests/*.depend
1920
tests/*build_log.html
20-
tests/cairo-wrap/*
21+
tests/cairo-wrap

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
add_library(interval-tree INTERFACE)
4+
5+
target_include_directories(interval-tree INTERFACE ./include)
6+
7+
add_subdirectory(tests)

interval_tree.hpp renamed to include/interval_tree/interval_tree.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include <string>
77
#include <memory>
8-
#include <cassert>
98
#include <cstdio>
109
#include <stdexcept>
1110
#include <iterator>
@@ -44,7 +43,8 @@ namespace lib_interval_tree
4443
: low_{low}
4544
, high_{high}
4645
{
47-
assert(low <= high);
46+
if (low > high)
47+
throw std::invalid_argument("Low border is not lower or equal to high border.");
4848
}
4949
#else
5050
#if __cplusplus >= 201703L
@@ -1128,9 +1128,9 @@ namespace lib_interval_tree
11281128
static bool find_all_i
11291129
(
11301130
typename std::conditional<std::is_same<IteratorT, iterator>::value, ThisType, ThisType const>::type* self,
1131-
node_type* ptr,
1132-
interval_type const& ival,
1133-
FunctionT const& on_find,
1131+
node_type* ptr,
1132+
interval_type const& ival,
1133+
FunctionT const& on_find,
11341134
ComparatorFunctionT const& compare
11351135
)
11361136
{
@@ -1219,8 +1219,8 @@ namespace lib_interval_tree
12191219
static bool overlap_find_all_i
12201220
(
12211221
typename std::conditional<std::is_same<IteratorT, iterator>::value, ThisType, ThisType const>::type* self,
1222-
node_type* ptr,
1223-
interval_type const& ival,
1222+
node_type* ptr,
1223+
interval_type const& ival,
12241224
FunctionT const& on_find
12251225
)
12261226
{
File renamed without changes.
File renamed without changes.

tests/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ file(GLOB sources "*.cpp")
2424
# Add Executable
2525
add_executable(tree-tests ${sources})
2626

27-
target_link_libraries(tree-tests gtest gmock)
28-
27+
target_link_libraries(tree-tests PRIVATE gtest gmock interval-tree)
2928
# Options
3029
if(DRAW_EXAMPLES)
3130
target_compile_definitions(tree-tests PRIVATE -DINTERVAL_TREE_DO_DRAWINGS=1)
3231
find_library(LCAIRO_WRAP NAMES cairo_wrap PATHS "../../cairo-wrap/build" STATIC)
33-
target_link_libraries(tree-tests ${LCAIRO_WRAP} cairo)
34-
target_include_directories(tree-tests PRIVATE .. ../..)
32+
target_link_libraries(tree-tests PRIVATE ${LCAIRO_WRAP} cairo)
3533
endif()
3634

3735
# Compiler Options

tests/interval_tests.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ TEST_F(IntervalTests, FailBadBorders)
3737
[[maybe_unused]] auto ival = types::interval_type{1, 0};
3838
};
3939

40-
EXPECT_DEATH(f(), "low <= high");
40+
ASSERT_THROW(f(), std::invalid_argument);
4141
}
4242

4343
TEST_F(IntervalTests, ShallCreateInterval)

tests/tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "gtest/gtest.h"
22
#include "gmock/gmock.h"
33

4-
#include "../interval_tree.hpp"
4+
#include <interval_tree/interval_tree.hpp>
55
#include "typedefs.hpp"
66
//#include "example_drawings.hpp"
77

0 commit comments

Comments
 (0)