add TextLoader::get_eol_at_eof()
This commit is contained in:
parent
500a6891d4
commit
89e8dc5de3
@ -6,6 +6,7 @@ TextLoader::TextLoader()
|
||||
{
|
||||
m_line_endings = LINE_ENDING_LF;
|
||||
m_lines = NULL;
|
||||
m_eol_at_eof = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user