1 #include "gtest/gtest.h"
2 #include "../../Src/TestPlatform/MockFileWordGenerator.h"
3 using namespace Dasher
;
8 class WordGenTest
: public ::testing::Test
{
11 fullGen
= new MockFileWordGenerator("test_data/word_gen_full_data.txt");
12 singleLineGen
= new MockFileWordGenerator("test_data/word_gen_single_line.txt");
16 MockFileWordGenerator
* fullGen
;
17 MockFileWordGenerator
* singleLineGen
;
21 * Tests whether the word fullGenerator opens a file
24 TEST_F(WordGenTest
, FileOpensCorrectly
) {
25 bool opened
= fullGen
->GetFileHandle().is_open();
26 bool good
= fullGen
->GetFileHandle().good();
27 ASSERT_EQ(opened
, true);
28 ASSERT_EQ(good
, true);
32 * Tests whether the file name getter returns expected results.
34 TEST_F(WordGenTest
, FilenameExtraction
) {
35 ASSERT_EQ("word_gen_full_data.txt", fullGen
->GetFilename());
39 * Tests if retrieving the next word returns expected results.
41 TEST_F(WordGenTest
, WordIteration
) {
42 ASSERT_EQ("I'm", fullGen
->GetNextWord());
43 ASSERT_EQ("a", fullGen
->GetNextWord());
47 * Tests if the word generator actually grabs the right amount of data
50 TEST_F(WordGenTest
, GetBuffer
) {
53 fin
.open("test_data/word_gen_single_line.txt");
54 std::getline(fin
, buffer
);
56 ASSERT_EQ(buffer
, singleLineGen
->GetWholeBuffer());
59 /* This test /should/ determine whether we return the right value when
60 * we reach the end of a file...Not sure what's causing this to fail now
62 TEST_F(WordGenTest
, EndsAtEOF
) {
63 for(int i
= 0; i
< 1000; i
++)
64 singleLineGen
->GetNextWord();
66 ASSERT_EQ("", singleLineGen
->GetNextWord());