Hello all, i've been busy with this excersize for quiete some time now, i'm using the google test framework and i'm trying to write code for the test below
1 2 3 4 5
TEST(Line, canFindTheOnlyWordInLineWithOneWord) {
Line testline("Stop");
Word searchword("Stop");
EXPECT_TRUE(testline.contains(searchword));
}
I have the following classes that have been predefined and their publice members are to not be changed
1 2 3 4 5 6 7 8 9 10 11 12 13
class Line
{
public:
// DO NOT MODIFY THE PUBLIC INTERFACE OF THIS CLASS
// accepts a line of text (which FileReader will provide in production code)
Line(const string& line);
// returns true if the search word is found in the line; false otherwise
bool contains(const Word& search_word) const;
private:
vector<Word> _line;
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
class Word
{
public:
// DO NOT MODIFY THE PUBLIC INTERFACE OF THIS CLASS
// constructor
Word(const string& word);
// overloads is-equal-to (or equivalence) operator - this is very useful for testing,
// as we can compare words directly
booloperator==(const Word& rhs) const;
// returns true if queryable, false otherwise
// (according to the brief, words less than 3 characters are not queryable)
bool isQueryable() const;
private:
string _word;
};
What i understance from the test is that the following function should somehow compare searchWord and testline
given all this, i really cant think of anyway to do it!, any help / suggestion will be greatly appreciated, i am willing to provide more information if required!
Thanks.
Note that the private interface of each class may be changed and or edited!
First of all, stop commenting every single line of code. Comments like //constructor are useless unless the person who you are giving the code to has no knowledge in C++, which wouldn't be useful at all. Only document when needed :)