Updated Hungarian translation
[dasher.git] / Testing / dasher_tests / WordGenTest.cpp
blobeaa8c5f8ea00efb9a12f17cc94a6472434618d99
1 #include "gtest/gtest.h"
2 #include "../../Src/TestPlatform/MockFileWordGenerator.h"
3 using namespace Dasher;
5 /*
6 * Test fixture
7 */
8 class WordGenTest : public ::testing::Test {
9 public:
10 WordGenTest() {
11 fullGen = new MockFileWordGenerator("test_data/word_gen_full_data.txt");
12 singleLineGen = new MockFileWordGenerator("test_data/word_gen_single_line.txt");
15 protected:
16 MockFileWordGenerator* fullGen;
17 MockFileWordGenerator* singleLineGen;
21 * Tests whether the word fullGenerator opens a file
22 * correctly.
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
48 * from the stream
50 TEST_F(WordGenTest, GetBuffer) {
51 std::ifstream fin;
52 std::string buffer;
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());