Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lamyj committed May 12, 2024
1 parent 1038c44 commit f8ac25e
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 440 deletions.
7 changes: 7 additions & 0 deletions src/python/dicomifier/bruker/Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ ::set_field(Field const & field)
this->_fields[field.name] = field;
}

std::size_t
Dataset
::size() const
{
return this->_fields.size();
}

void
Dataset
::_load(std::string::const_iterator begin, std::string::const_iterator end)
Expand Down
2 changes: 2 additions & 0 deletions src/python/dicomifier/bruker/Dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Dataset
* (except the PixelData file)
*/
std::vector<std::string> const & get_used_files() const;

std::size_t size() const;

typedef std::map<std::string, Field>::const_iterator const_iterator;
const_iterator begin() const { return this->_fields.begin(); }
Expand Down
6 changes: 6 additions & 0 deletions src/python/dicomifier/wrappers/Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void wrap_Dataset(pybind11::module & m)
return_value_policy::reference_internal, R"doc(
Return a set of files used to create the dataset
(except the PixelData file))doc")
.def("__len__", &Dataset::size)
.def("__contains__", &Dataset::has_field)
.def(
"__getitem__", &Dataset::get_field,
Expand All @@ -53,6 +54,11 @@ void wrap_Dataset(pybind11::module & m)
[](Dataset const & d) {
return make_key_iterator(d.begin(), d.end()); },
keep_alive<0, 1>())
.def(
"keys",
[](Dataset const & d) {
return make_key_iterator(d.begin(), d.end()); },
keep_alive<0, 1>())
.def(
"items",
[](Dataset const & d) { return make_iterator(d.begin(), d.end()); },
Expand Down
29 changes: 0 additions & 29 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
find_package(
Boost 1.58 COMPONENTS filesystem system unit_test_framework REQUIRED)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../src/lib ${Boost_INCLUDE_DIRS})
add_definitions(-DBOOST_FILESYSTEM_VERSION=3 -DBOOST_TEST_DYN_LINK)
link_directories(${Boost_LIBRARY_DIRS})

file(GLOB_RECURSE tests *.cpp)
foreach(test_file ${tests})
get_filename_component(test ${test_file} NAME_WE)
add_executable(${test} ${test_file})
target_link_libraries(
${test}
libdicomifier
${Boost_LIBRARIES} ${JsonCpp_LIBRARIES})

file(READ ${test_file} content)

set(pattern "BOOST_(AUTO|FIXTURE)_TEST_CASE\\(([^),]+)")

string(REGEX MATCHALL ${pattern} cases ${content})

foreach(case ${cases})
string(REGEX REPLACE ${pattern} "\\2" case ${case})
add_test("${test}_${case}" "${test}" "--run_test=${case}")
endforeach()
endforeach()

file(GLOB_RECURSE python_tests "*.py")
add_custom_target(
PythonTests ${CMAKE_COMMAND} -E echo "Python tests" SOURCES ${python_tests})
108 changes: 0 additions & 108 deletions tests/code/bruker/Dataset.cpp

This file was deleted.

111 changes: 0 additions & 111 deletions tests/code/bruker/Field.cpp

This file was deleted.

Loading

0 comments on commit f8ac25e

Please sign in to comment.