-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ivan Volgushev <[email protected]> Co-authored-by: Artem Demchenko <[email protected]>
- Loading branch information
1 parent
bac551d
commit 3d03c50
Showing
1 changed file
with
76 additions
and
0 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,76 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "algorithms/algo_factory.h" | ||
#include "algorithms/ucc/ucc_verifier/ucc_verifier.h" | ||
#include "config/indices/type.h" | ||
#include "datasets.h" | ||
|
||
namespace tests { | ||
namespace onam = config::names; | ||
|
||
struct UCCVerifyingParams { | ||
private: | ||
algos::StdParamsMap params; | ||
size_t num_clusters_not_ucc_ = 0; | ||
size_t num_rows_not_ucc_ = 0; | ||
std::vector<model::PLI::Cluster> clusters_not_ucc_; | ||
|
||
public: | ||
UCCVerifyingParams(config::IndicesType column_indices, size_t const num_clusters_not_ucc, | ||
size_t const num_rows_not_ucc, | ||
std::vector<model::PLI::Cluster> clusters_not_ucc, char const* dataset, | ||
char const separator = ',', bool const has_header = true) | ||
: params({{onam::kIndices, std::move(column_indices)}, | ||
{onam::kCsvPath, test_data_dir / dataset}, | ||
{onam::kSeparator, separator}, | ||
{onam::kHasHeader, has_header}, | ||
{onam::kEqualNulls, true}}), | ||
num_clusters_not_ucc_(num_clusters_not_ucc), | ||
num_rows_not_ucc_(num_rows_not_ucc), | ||
clusters_not_ucc_(std::move(clusters_not_ucc)) {} | ||
|
||
const algos::StdParamsMap& GetParams() const { | ||
return params; | ||
} | ||
|
||
size_t GetExpectedNumClustersNotUCC() const { | ||
return num_clusters_not_ucc_; | ||
} | ||
|
||
size_t GetExpectedNumRowsNotUCC() const { | ||
return num_rows_not_ucc_; | ||
} | ||
|
||
const std::vector<model::PLI::Cluster>& GetExpectedClustersNotUCC() const { | ||
return clusters_not_ucc_; | ||
} | ||
}; | ||
|
||
class TestUCCVerifying : public ::testing::TestWithParam<UCCVerifyingParams> {}; | ||
|
||
TEST_P(TestUCCVerifying, DefaultTest) { | ||
auto const& p(GetParam()); | ||
auto mp = algos::StdParamsMap(p.GetParams()); | ||
auto verifier = algos::CreateAndLoadAlgorithm<algos::UCCVerifier>(mp); | ||
verifier->Execute(); | ||
EXPECT_EQ(verifier->UCCHolds(), p.GetExpectedNumClustersNotUCC() == 0); | ||
EXPECT_EQ(verifier->GetNumRowsNotUCC(), p.GetExpectedNumRowsNotUCC()); | ||
EXPECT_EQ(verifier->GetNumClustersNotUCC(), p.GetExpectedNumClustersNotUCC()); | ||
EXPECT_EQ(verifier->GetClustersNotUCC(), p.GetExpectedClustersNotUCC()); | ||
} | ||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
UCCVerifierTestSuite, TestUCCVerifying, | ||
::testing::Values(UCCVerifyingParams({0}, 1, 12, {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}, | ||
"TestFD.csv"), | ||
UCCVerifyingParams({0, 1}, 4, 12, | ||
{{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {9, 10, 11}}, | ||
"TestFD.csv"), | ||
UCCVerifyingParams({0, 1, 2}, 4, 8, {{0, 1}, {3, 4}, {6, 7}, {9, 10}}, | ||
"TestFD.csv"), | ||
UCCVerifyingParams({0, 1, 2, 3, 4, 5}, 3, 6, {{3, 4}, {6, 7}, {9, 10}}, | ||
"TestFD.csv"), | ||
UCCVerifyingParams({0}, 0, 0, {}, "TestWide.csv"), | ||
UCCVerifyingParams({0, 1, 2, 3, 4}, 0, 0, {}, "TestWide.csv"))); | ||
|
||
} // namespace tests |