mirror of
https://github.com/Doctorado-ML/FImdlp.git
synced 2025-08-16 16:05:52 +00:00
Add some tests
This commit is contained in:
1
Makefile
1
Makefile
@@ -11,6 +11,7 @@ test:
|
||||
cd fimdlp/testcpp && ./test
|
||||
|
||||
coverage:
|
||||
if [ -d fimdlp/testcpp/build/CMakeFiles ]; then rm -fr fimdlp/testcpp/build/CMakeFiles/* ; fi;
|
||||
make test
|
||||
cd fimdlp/testcpp && ./cover
|
||||
|
||||
|
@@ -41,12 +41,10 @@ namespace mdlp {
|
||||
X = X_;
|
||||
y = y_;
|
||||
if (X.size() != y.size()) {
|
||||
cerr << "X and y must have the same size" << endl;
|
||||
return *this;
|
||||
throw invalid_argument("X and y must have the same size");
|
||||
}
|
||||
if (X.size() == 0) {
|
||||
cerr << "X and y must have at least one element" << endl;
|
||||
return *this;
|
||||
if (X.size() == 0 || y.size() == 0) {
|
||||
throw invalid_argument("X and y must have at least one element");
|
||||
}
|
||||
this->indices = sortIndices(X_);
|
||||
this->xDiscretized = labels(X.size(), -1);
|
||||
|
Binary file not shown.
@@ -59,6 +59,18 @@ namespace mdlp {
|
||||
}
|
||||
|
||||
};
|
||||
TEST_F(TestFImdlp, FitErrorEmptyDataset)
|
||||
{
|
||||
X = samples();
|
||||
y = labels();
|
||||
EXPECT_THROW(fit(X, y), std::invalid_argument);
|
||||
}
|
||||
TEST_F(TestFImdlp, FitErrorDifferentSize)
|
||||
{
|
||||
X = { 1, 2, 3 };
|
||||
y = { 1, 2 };
|
||||
EXPECT_THROW(fit(X, y), std::invalid_argument);
|
||||
}
|
||||
TEST_F(TestFImdlp, SortIndices)
|
||||
{
|
||||
X = { 5.7, 5.3, 5.2, 5.1, 5.0, 5.6, 5.1, 6.0, 5.1, 5.9 };
|
||||
|
Reference in New Issue
Block a user