Skip to content

Commit

Permalink
unit tests v2 (still not definitive, some tests are still too long, b…
Browse files Browse the repository at this point in the history
…ut it is much better)
  • Loading branch information
hschreiber committed Nov 21, 2023
1 parent 2ddf03e commit 8817950
Show file tree
Hide file tree
Showing 25 changed files with 1,478 additions and 575 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#ifndef PM_CHAIN_MATRIX_H
#define PM_CHAIN_MATRIX_H

#include <iostream> //print() only
#include <iostream> //print() only
#include <set>
#include <vector>

#include "chain_vine_swap.h" //_no_G_death_comparator
#include <utility> //std::swap, std::move & std::exchange

namespace Gudhi {
namespace persistence_matrix {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ template<class Matrix_type, class Master_matrix_type>
template<typename BirthComparatorFunction, typename DeathComparatorFunction>
inline Position_to_id_indexation_overlay<Matrix_type,Master_matrix_type>::Position_to_id_indexation_overlay(
BirthComparatorFunction&& birthComparator,
DeathComparatorFunction&& deathComparator) : matrix_(birthComparator, deathComparator)
DeathComparatorFunction&& deathComparator)
: matrix_(birthComparator, deathComparator),
nextIndex_(0),
nextID_(0)
{}

template<class Matrix_type, class Master_matrix_type>
Expand Down Expand Up @@ -253,6 +256,7 @@ Position_to_id_indexation_overlay<Matrix_type,Master_matrix_type>::insert_bounda
if (columnPositionToID_.size() <= nextIndex_) {
columnPositionToID_.resize(nextIndex_ * 2 + 1);
}

columnPositionToID_[nextIndex_++] = nextID_++;

return matrix_.insert_boundary(boundary);
Expand Down
363 changes: 331 additions & 32 deletions src/Persistence_matrix/test/CMakeLists.txt

Large diffs are not rendered by default.

124 changes: 80 additions & 44 deletions src/Persistence_matrix/test/Persistence_matrix_column_tests_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,92 @@
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "persistence_matrix"
// #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
// #define BOOST_MPL_LIMIT_LIST_SIZE 10
#include <boost/test/unit_test.hpp>
// #include <boost/mpl/list.hpp>
// #include <boost/mp11.hpp>

#include "pm_column_tests.h"
#include "pm_column_tests_boost_type_lists.h"

using option_name_list = mp_list_q<c_base_options>;
using no_row_access_columns = columns_list<no_ra_option_list<option_name_list> >;
using only_row_access_columns = columns_list<only_ra_option_list<option_name_list> >;
using z2_no_row_access_columns = columns_list<z2_no_ra_option_list<option_name_list> >;
using z2_only_row_access_columns = columns_list<z2_only_ra_option_list<option_name_list> >;
using z5_no_row_access_columns = columns_list<z5_no_ra_option_list<option_name_list> >;
using z5_only_row_access_columns = columns_list<z5_only_ra_option_list<option_name_list> >;
using z5_columns = columns_list<z5_option_list<option_name_list> >;
using z2_columns = columns_list<z2_option_list<option_name_list> >;

// using opt = Base_col_options<true,Column_types::HEAP,false,false,false>;
// using mat = Column_mini_matrix<opt>;
// typedef boost::mpl::list<Heap_column<mat> > test;
#ifdef PM_TEST_Z2
#ifdef PM_TEST_NO_ROW

using z2_no_row_access_columns = columns_list<z2_no_ra_option_list<option_name_list> >;

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_constructors, Column, no_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_constructors, Column, z2_no_row_access_columns) {
column_test_common_constructors<Column>();
column_test_base_boundary_constructors<Column>();
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_content_access, Column, z5_no_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_content_access, Column, z2_no_row_access_columns) {
std::vector<Column> matrix = build_column_matrix<Column>();
column_test_common_z5_content_access(matrix);
column_test_common_z2_content_access(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_content_access, Column, z2_no_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_operators, Column, z2_no_row_access_columns) {
std::vector<Column> matrix = build_column_matrix<Column>();
column_test_common_z2_operators(matrix);

matrix = build_column_matrix<Column>();
column_test_base_z2_operators(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_other, Column, z2_no_row_access_columns) {
column_test_base_boundary_z2_methods<Column>();
}

#else

#ifdef PM_TEST_REM_ROW
using z2_only_row_access_columns = columns_list<z2_only_ra_r_option_list<option_name_list> >;
#else
using z2_only_row_access_columns = columns_list<z2_only_ra_option_list<option_name_list> >;
#endif

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_with_row_access_content_access, Column, z2_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);
column_test_common_z2_content_access(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_with_row_access_content_access, Column, z5_only_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_with_row_access_operators, Column, z2_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);
column_test_common_z5_content_access(matrix);
column_test_common_z2_operators(matrix);

matrix.clear();
rows.clear();
matrix = build_column_matrix<Column>(rows);
column_test_base_z2_operators(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_with_row_access_content_access, Column, z2_only_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_row_access_constructors, Column, z2_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);
column_test_common_z2_content_access(matrix);

column_test_row_access_constructors(matrix, rows);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_other, Column, z2_only_row_access_columns) {
column_test_base_boundary_z2_methods<Column>();
}

#endif
#endif

#ifdef PM_TEST_Z5
#ifdef PM_TEST_NO_ROW

using z5_no_row_access_columns = columns_list<z5_no_ra_option_list<option_name_list> >;

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_constructors, Column, z5_no_row_access_columns) {
column_test_common_constructors<Column>();
column_test_base_boundary_constructors<Column>();
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_content_access, Column, z5_no_row_access_columns) {
std::vector<Column> matrix = build_column_matrix<Column>();
column_test_common_z5_content_access(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_operators, Column, z5_no_row_access_columns) {
Expand All @@ -67,47 +105,45 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_operators, Column, z5_no_row_access
column_test_base_z5_operators(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_operators, Column, z2_no_row_access_columns) {
std::vector<Column> matrix = build_column_matrix<Column>();
column_test_common_z2_operators(matrix);

matrix = build_column_matrix<Column>();
column_test_base_z2_operators(matrix);
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_other, Column, z5_no_row_access_columns) {
column_test_base_boundary_z5_methods<Column>();
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_with_row_access_operators, Column, z5_only_row_access_columns) {
#else

#ifdef PM_TEST_REM_ROW
using z5_only_row_access_columns = columns_list<z5_only_ra_r_option_list<option_name_list> >;
#else
using z5_only_row_access_columns = columns_list<z5_only_ra_option_list<option_name_list> >;
#endif

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_with_row_access_content_access, Column, z5_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);
column_test_common_z5_operators(matrix);

matrix.clear();
rows.clear();
matrix = build_column_matrix<Column>(rows);
column_test_base_z5_operators(matrix);
column_test_common_z5_content_access(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_with_row_access_operators, Column, z2_only_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_with_row_access_operators, Column, z5_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);
column_test_common_z2_operators(matrix);
column_test_common_z5_operators(matrix);

matrix.clear();
rows.clear();
matrix = build_column_matrix<Column>(rows);
column_test_base_z2_operators(matrix);
column_test_base_z5_operators(matrix);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_row_access_constructors, Column, only_row_access_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_column_row_access_constructors, Column, z5_only_row_access_columns) {
typename Column::Master::row_container_type rows; //do not destroy before matrix
std::vector<Column> matrix = build_column_matrix<Column>(rows);

column_test_row_access_constructors(matrix, rows);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_other, Column, z5_columns) {
BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z5_column_other, Column, z5_only_row_access_columns) {
column_test_base_boundary_z5_methods<Column>();
}

BOOST_AUTO_TEST_CASE_TEMPLATE(Base_z2_column_other, Column, z2_columns) {
column_test_base_boundary_z2_methods<Column>();
}
#endif
#endif
Loading

0 comments on commit 8817950

Please sign in to comment.