Skip to content

Commit 8bb43e5

Browse files
committed
Mark exact match
1 parent 8211e70 commit 8bb43e5

12 files changed

Lines changed: 63 additions & 37 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ if(TESTS)
4747
add_subdirectory(tests)
4848
endif()
4949

50+
add_subdirectory(examples)
51+
5052
install(FILES README.md LICENSE.md
5153
DESTINATION share/doc/functional)

examples/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
add_subdirectory(simple)
4+
add_subdirectory(polygon)

examples/polygon/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
project(examples_polygon)
3+
4+
set(CMAKE_CXX_EXTENSIONS OFF)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
# Pls keep the filenames sorted
8+
set(TESTS_EXAMPLES_POLYGON_SOURCES
9+
main.cpp
10+
)
11+
12+
# TODO add 20 when we are compatible with C++20
13+
foreach(mode 23)
14+
set(target "examples_polygon_cxx${mode}")
15+
16+
add_executable("${target}" ${TESTS_EXAMPLES_POLYGON_SOURCES})
17+
target_link_libraries("${target}" include_fn)
18+
append_compilation_options("${target}" WARNINGS)
19+
add_dependencies("cxx${mode}" "${target}")
20+
set_property(TARGET "${target}" PROPERTY CXX_STANDARD "${mode}")
21+
target_compile_definitions("${target}" PRIVATE LIBFN_MODE=${mode})
22+
23+
unset(target)
24+
endforeach()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ int main(int argc, char *argv[])
152152
auto counts = count_characters(line);
153153
if (line.size() >= 3 && counts[i.required_character] > 0 && match(i.characters, counts)) {
154154
if (words.insert(line).second) {
155+
if (i.characters == counts)
156+
std::cout << "* ";
155157
std::cout << line << "\n";
156158
}
157159
}

examples/simple/CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
project(examples_simple)
3+
4+
set(CMAKE_CXX_EXTENSIONS OFF)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
# Pls keep the filenames sorted
8+
set(TESTS_EXAMPLES_SIMPLE_SOURCES
9+
main.cpp
10+
)
11+
12+
# TODO add 20 when we are compatible with C++20
13+
foreach(mode 23)
14+
set(target "examples_simple_cxx${mode}")
15+
16+
add_executable("${target}" ${TESTS_EXAMPLES_SIMPLE_SOURCES})
17+
target_link_libraries("${target}" include_fn Catch2::Catch2WithMain)
18+
append_compilation_options("${target}" WARNINGS)
19+
add_dependencies("cxx${mode}" "${target}")
20+
set_property(TARGET "${target}" PROPERTY CXX_STANDARD "${mode}")
21+
target_compile_definitions("${target}" PRIVATE LIBFN_MODE=${mode})
22+
23+
add_test(
24+
NAME "${target}"
25+
COMMAND "${target}" -r console
26+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
27+
)
28+
set_property(TEST "${target}" PROPERTY LABELS examples "cxx${mode}")
29+
30+
unset(target)
31+
endforeach()

0 commit comments

Comments
 (0)