Complete CPP tests

This commit is contained in:
2022-12-05 00:50:44 +01:00
parent 80c1802e10
commit cabfdd57ea
4 changed files with 26 additions and 4 deletions

View File

@@ -6,6 +6,8 @@ clean: ## Clean up
rm -rf build dist *.egg-info
if [ -f fimdlp/cfimdlp.cpp ]; then rm fimdlp/cfimdlp.cpp; fi;
if [ -f fimdlp/cppfimdlp.cpython-310-darwin.so ]; then rm fimdlp/cppfimdlp.cpython-310-darwin.so; fi;
if [ -d fimdlp/testcpp/build ]; then rm -fr fimdlp/testcpp/build/* ; fi;
if [ -d fimdlp/testcpp/lcoverage ]; then rm -fr fimdlp/testcpp/lcoverage/* ; fi;
test:
cd fimdlp/testcpp && ./test

View File

@@ -267,8 +267,4 @@ namespace mdlp {
{
cutPoints = cutPoints_;
}
indices_t CPPFImdlp::getIndices()
{
return indices;
}
}

View File

@@ -13,6 +13,10 @@ namespace mdlp {
y = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
fit(X, y);
}
void setProposal(bool value)
{
proposal = value;
}
void initCutPoints()
{
setCutPoints(cutPoints_t());
@@ -150,4 +154,24 @@ namespace mdlp {
computed = getCutPoints();
checkVectors(expected, computed);
}
TEST_F(TestFImdlp, Constructor)
{
samples X = { 5.7, 5.3, 5.2, 5.1, 5.0, 5.6, 5.1, 6.0, 5.1, 5.9 };
labels y = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
setProposal(false);
fit(X, y);
computeCutPointsOriginal();
cutPoints_t expected;
vector<float> computed = getCutPoints();
expected = {
{ 0, 4, -1, -3.4028234663852886e+38, 5.15 }, { 4, 6, -1, 5.15, 5.45 },
{ 6, 10, -1, 5.45, 3.4028234663852886e+38 }
};
computed = getCutPoints();
int expectedSize = expected.size();
EXPECT_EQ(computed.size(), expected.size());
for (auto i = 0; i < expectedSize; i++) {
EXPECT_NEAR(computed[i], expected[i].toValue, .00000001);
}
}
}