add TextLoader::get_eol_at_eof()

This commit is contained in:
Josh Holtrop 2016-07-24 12:06:50 -04:00
parent 500a6891d4
commit 89e8dc5de3
3 changed files with 7 additions and 0 deletions

View File

@ -6,6 +6,7 @@ TextLoader::TextLoader()
{
m_line_endings = LINE_ENDING_LF;
m_lines = NULL;
m_eol_at_eof = true;
}
/**

View File

@ -32,6 +32,7 @@ public:
int get_line_endings() { return m_line_endings; }
auto begin() { return m_lines->begin(); }
auto end() { return m_lines->end(); }
bool get_eol_at_eof() { return m_eol_at_eof; }
typedef std::pair<uint8_t *, uint32_t> LineIndexPair;
typedef std::list<LineIndexPair> LineIndexPairList;
@ -39,6 +40,7 @@ public:
protected:
int m_line_endings;
bool m_eol_at_eof;
LineIndexPairListRef m_lines;
};

View File

@ -23,6 +23,7 @@ TEST(TextLoaderTest, loading_empty_file)
auto file = TestSupport::read_file("test/files/empty.txt");
tl.load_buffer(&(*file)[0], file->size());
EXPECT_EQ(0u, tl.num_lines());
EXPECT_EQ(true, tl.get_eol_at_eof());
}
TEST(TextLoaderTest, detects_lf_line_endings)
@ -36,6 +37,7 @@ TEST(TextLoaderTest, detects_lf_line_endings)
EXPECT_EQ("Hello.", line_to_string(it));
it++;
EXPECT_EQ("This file is in LF line ending format.", line_to_string(it));
EXPECT_EQ(true, tl.get_eol_at_eof());
}
TEST(TextLoaderTest, detects_cr_line_endings)
@ -49,6 +51,7 @@ TEST(TextLoaderTest, detects_cr_line_endings)
EXPECT_EQ("Hello.", line_to_string(it));
it++;
EXPECT_EQ("This file is in CR line ending format.", line_to_string(it));
EXPECT_EQ(true, tl.get_eol_at_eof());
}
TEST(TextLoaderTest, detects_crlf_line_endings)
@ -62,4 +65,5 @@ TEST(TextLoaderTest, detects_crlf_line_endings)
EXPECT_EQ("Hello.", line_to_string(it));
it++;
EXPECT_EQ("This file is in CRLF line ending format.", line_to_string(it));
EXPECT_EQ(true, tl.get_eol_at_eof());
}