Skip to content
Snippets Groups Projects
Commit b55e3e80 authored by anikhalder's avatar anikhalder
Browse files

Add ParameterPattern Unit Test

parent 555d9ee6
No related branches found
No related tags found
No related merge requests found
#ifndef PARAMETERPATTERNTEST_H
#define PARAMETERPATTERNTEST_H
#include "ParameterPattern.h"
#include <string>
class ParameterPatternTest : public ::testing::Test
{
protected:
ParameterPatternTest(){}
virtual ~ParameterPatternTest(){}
};
TEST_F(ParameterPatternTest, declarationTest)
{
ParameterPattern p1;
EXPECT_EQ("", p1.toStdString());
ParameterPattern p2("home");
EXPECT_EQ("/home", p2.toStdString());
}
TEST_F(ParameterPatternTest, beginsWithTest)
{
ParameterPattern p1("Downloads");
EXPECT_EQ("/Downloads", p1.toStdString());
p1.beginsWith("Desktop");
EXPECT_EQ("Desktop", p1.toStdString());
}
TEST_F(ParameterPatternTest, addTest)
{
ParameterPattern p1("Desktop");
EXPECT_EQ("/Desktop", p1.toStdString());
p1.add("BornAgain");
EXPECT_EQ("/Desktop/BornAgain", p1.toStdString());
p1.add("Core").add("Tests");
EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p1.toStdString());
p1.add("UnitTests").beginsWith("user");
EXPECT_EQ("user", p1.toStdString());
}
TEST_F(ParameterPatternTest, copyTest)
{
ParameterPattern p1("Desktop");
p1.add("BornAgain").add("Core").add("Tests");
EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p1.toStdString());
ParameterPattern p2("user");
EXPECT_EQ("/user", p2.toStdString());
// calls assignment operator
p2 = p1;
EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p2.toStdString());
// calls copy constructor
ParameterPattern p3(p2);
EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p3.toStdString());
// calls copy constructor
ParameterPattern p4 = ParameterPattern(p2);
EXPECT_EQ("/Desktop/BornAgain/Core/Tests", p4.toStdString());
}
#endif // PARAMETERPATTERNTEST_H
...@@ -7,3 +7,5 @@ ...@@ -7,3 +7,5 @@
#include "FTDistributionsTest.h" #include "FTDistributionsTest.h"
#include "ParameterPoolTest.h" #include "ParameterPoolTest.h"
#include "RealParameterTest.h" #include "RealParameterTest.h"
#include "ParameterPatternTest.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment