Commit a0556391 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

added TestLevel

parent dbdaee80
......@@ -39,6 +39,14 @@ bool Level::operator==(int level) const {
return true;
}
bool Level::operator!=(const Level &level) const {
return !(*this == level);
}
bool Level::operator!=(int level) const {
return !(*this == level);
}
bool Level::operator<=(const Level &level) const {
if (this->fine < level.fine) return true;
else return false;
......
......@@ -30,6 +30,10 @@ struct Level {
bool operator==(int level) const;
bool operator!=(const Level &level) const;
bool operator!=(int level) const;
bool operator<=(const Level &level) const;
bool operator>=(const Level &level) const;
......
#include "basics/Level.hpp"
#include "TestEnvironment.hpp"
#include <vector>
class TestLevel : public Test {
protected:
typedef std::vector<Level> TestLevels;
typedef std::vector<int> TestIntegers;
TestLevels testLevels;
TestIntegers testIntegers;
void SetUp() override {
testLevels = {
Level(), // 0
Level(1), // 1
Level(1, 0), // 2
Level(1, 1), // 3
Level(2), // 4
Level(2, 0), // 5
Level(2, 2), // 6
};
testIntegers = {
int(), // 0
1, // 1
2 // 2
};
}
};
TEST_F(TestLevel, TestEqualsAndNotEqualsLevelOperators) {
//0
ASSERT_TRUE(testLevels[0] == testLevels[0]);
for (int index = 1; index <=6; index++)
ASSERT_TRUE(testLevels[0] != testLevels[index]);
//1
ASSERT_TRUE(testLevels[1] == testLevels[1]);
ASSERT_TRUE(testLevels[1] == testLevels[2]);
for (int index = 3; index <=6; index++)
ASSERT_TRUE(testLevels[1] != testLevels[index]);
//2
ASSERT_TRUE(testLevels[2] == testLevels[2]);
for (int index = 3; index <=6; index++)
ASSERT_TRUE(testLevels[2] != testLevels[index]);
//3
ASSERT_TRUE(testLevels[3] == testLevels[3]);
for (int index = 4; index <=6; index++)
ASSERT_TRUE(testLevels[3] != testLevels[index]);
//4
ASSERT_TRUE(testLevels[4] == testLevels[4]);
ASSERT_TRUE(testLevels[4] == testLevels[5]);
ASSERT_TRUE(testLevels[4] != testLevels[6]);
//5
ASSERT_TRUE(testLevels[5] == testLevels[5]);
ASSERT_TRUE(testLevels[5] != testLevels[6]);
}
TEST_F(TestLevel, TestEqualsAndNotEqualsIntegerOperators) {
//0
ASSERT_TRUE(testLevels[0] != testIntegers[0]);
ASSERT_TRUE(testLevels[0] != testIntegers[1]);
ASSERT_TRUE(testLevels[0] != testIntegers[2]);
//1
ASSERT_TRUE(testLevels[1] != testIntegers[0]);
ASSERT_TRUE(testLevels[1] == testIntegers[1]);
ASSERT_TRUE(testLevels[1] != testIntegers[2]);
//2
ASSERT_TRUE(testLevels[2] != testIntegers[0]);
ASSERT_TRUE(testLevels[2] == testIntegers[1]);
ASSERT_TRUE(testLevels[2] != testIntegers[2]);
//3
ASSERT_TRUE(testLevels[3] != testIntegers[0]);
ASSERT_TRUE(testLevels[3] == testIntegers[1]);
ASSERT_TRUE(testLevels[3] != testIntegers[2]);
//4
ASSERT_TRUE(testLevels[4] != testIntegers[0]);
ASSERT_TRUE(testLevels[4] != testIntegers[1]);
ASSERT_TRUE(testLevels[4] == testIntegers[2]);
//5
ASSERT_TRUE(testLevels[5] != testIntegers[0]);
ASSERT_TRUE(testLevels[5] != testIntegers[1]);
ASSERT_TRUE(testLevels[5] == testIntegers[2]);
//5
ASSERT_TRUE(testLevels[6] != testIntegers[0]);
ASSERT_TRUE(testLevels[6] != testIntegers[1]);
ASSERT_TRUE(testLevels[6] == testIntegers[2]);
}
// Todo finish
int main(int argc, char **argv) {
MppTest mppTest = MppTestBuilder(argc, argv).WithPPM().WithScreenLogging();
return mppTest.RUN_ALL_MPP_TESTS();
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment