Refactoring casing and naming
This commit is contained in:
@@ -10,16 +10,16 @@
|
||||
EclipseDeck::EclipseDeck() {
|
||||
}
|
||||
|
||||
int EclipseDeck::GetNumberOfKeywords() {
|
||||
return keywords.size();
|
||||
int EclipseDeck::getNumberOfKeywords() {
|
||||
return m_keywords.size();
|
||||
}
|
||||
|
||||
const std::vector<std::string> EclipseDeck::GetKeywords() {
|
||||
return keywords;
|
||||
const std::vector<std::string> EclipseDeck::getKeywords() {
|
||||
return m_keywords;
|
||||
}
|
||||
|
||||
void EclipseDeck::AddKeyword(const std::string &keyword) {
|
||||
keywords.push_back(keyword);
|
||||
void EclipseDeck::addKeyword(const std::string &keyword) {
|
||||
m_keywords.push_back(keyword);
|
||||
}
|
||||
|
||||
EclipseDeck::~EclipseDeck() {
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
class EclipseDeck {
|
||||
public:
|
||||
EclipseDeck();
|
||||
int GetNumberOfKeywords();
|
||||
const std::vector<std::string> GetKeywords();
|
||||
void AddKeyword(const std::string &keyword);
|
||||
int getNumberOfKeywords();
|
||||
const std::vector<std::string> getKeywords();
|
||||
void addKeyword(const std::string &keyword);
|
||||
virtual ~EclipseDeck();
|
||||
private:
|
||||
int numberOfKeywords;
|
||||
std::vector<std::string> keywords;
|
||||
int m_numberOfKeywords;
|
||||
std::vector<std::string> m_keywords;
|
||||
};
|
||||
|
||||
#endif /* ECLIPSEDECK_H */
|
||||
|
||||
@@ -15,39 +15,39 @@ Parser::Parser() {
|
||||
}
|
||||
|
||||
Parser::Parser(const std::string &path) {
|
||||
dataFilePath = path;
|
||||
m_dataFilePath = path;
|
||||
}
|
||||
|
||||
EclipseDeck Parser::Parse() {
|
||||
EclipseDeck Parser::parse() {
|
||||
EclipseDeck deck;
|
||||
|
||||
log.append("Initializing inputstream from file: " + dataFilePath + "\n");
|
||||
m_log.append("Initializing inputstream from file: " + m_dataFilePath + "\n");
|
||||
|
||||
ifstream inputstream;
|
||||
inputstream.open(dataFilePath.c_str());
|
||||
inputstream.open(m_dataFilePath.c_str());
|
||||
|
||||
if (!inputstream.is_open()) {
|
||||
log.append("ERROR: unable to open file");
|
||||
m_log.append("ERROR: unable to open file");
|
||||
return deck;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
|
||||
while (!inputstream.eof()) {
|
||||
std::getline(inputstream, line);
|
||||
if (line.substr(0, 2) != "--") {
|
||||
deck.AddKeyword(line);
|
||||
deck.addKeyword(line);
|
||||
}
|
||||
log.append("Linje: " + line + "\n");
|
||||
m_log.append("Line: " + line + "\n");
|
||||
}
|
||||
|
||||
inputstream.close();
|
||||
return deck;
|
||||
}
|
||||
|
||||
void Parser::writeLogToFile() {
|
||||
std::ofstream logfile;
|
||||
logfile.open("log.txt");
|
||||
logfile << log;
|
||||
logfile << m_log;
|
||||
logfile.close();
|
||||
|
||||
return deck;
|
||||
}
|
||||
|
||||
Parser::~Parser() {
|
||||
|
||||
@@ -14,13 +14,14 @@ class Parser {
|
||||
public:
|
||||
Parser();
|
||||
Parser(const std::string &path);
|
||||
EclipseDeck Parse();
|
||||
std::string GetLog();
|
||||
EclipseDeck parse();
|
||||
std::string getLog();
|
||||
virtual ~Parser();
|
||||
private:
|
||||
//EclipseDeck deck;
|
||||
std::string dataFilePath;
|
||||
std::string log;
|
||||
std::string m_dataFilePath;
|
||||
std::string m_log;
|
||||
void writeLogToFile();
|
||||
};
|
||||
|
||||
#endif /* PARSER_H */
|
||||
|
||||
@@ -16,9 +16,9 @@ TEST(ParserTest, Initializing) {
|
||||
|
||||
TEST(ParserTest, ParseEmptyFileKeywordVectorEmpty) {
|
||||
Parser * parser = new Parser();
|
||||
EclipseDeck deck = parser->Parse();
|
||||
ASSERT_EQ(0, deck.GetNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)0, deck.GetKeywords().size());
|
||||
EclipseDeck deck = parser->parse();
|
||||
ASSERT_EQ(0, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)0, deck.getKeywords().size());
|
||||
delete parser;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ TEST(ParserTest, ParseFileWithOneKeyword) {
|
||||
boost::filesystem::path singleKeywordFile("testdata/single.data");
|
||||
|
||||
Parser * parser = new Parser(singleKeywordFile.string());
|
||||
EclipseDeck deck = parser->Parse();
|
||||
EclipseDeck deck = parser->parse();
|
||||
|
||||
ASSERT_EQ(1, deck.GetNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)1, deck.GetKeywords().size());
|
||||
ASSERT_EQ(1, deck.getNumberOfKeywords());
|
||||
ASSERT_EQ((unsigned int)1, deck.getKeywords().size());
|
||||
|
||||
delete parser;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user