diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-10-29 14:56:55 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-10-29 14:56:55 -0700 |
commit | 1a00fe4ea75924bfe594c4d92073cc95eaa2f32d (patch) | |
tree | a6e8992e0821a998236a4dfb5d6f6194a0b7ce97 /src/io/line_test.cpp | |
parent | 469991120bcf550b6e2124203103876b6b7be918 (diff) | |
download | tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.gz tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.bz2 tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.tar.xz tmwa-1a00fe4ea75924bfe594c4d92073cc95eaa2f32d.zip |
Item AST
Diffstat (limited to 'src/io/line_test.cpp')
-rw-r--r-- | src/io/line_test.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/io/line_test.cpp b/src/io/line_test.cpp index 46e7b57..582ee81 100644 --- a/src/io/line_test.cpp +++ b/src/io/line_test.cpp @@ -130,6 +130,20 @@ TEST(io, line5) EXPECT_EQ(hi.column, 0); EXPECT_FALSE(lr.read_line(hi)); } +TEST(io, line1text) +{ + io::LineReader lr(io::from_string, "<string1text>"_s, "Hello\nWorld"_s, 2); + io::Line hi; + EXPECT_TRUE(lr.read_line(hi)); + EXPECT_EQ(hi.text, "Hello"_s); + EXPECT_EQ(hi.line, 2); + EXPECT_EQ(hi.column, 0); + EXPECT_TRUE(lr.read_line(hi)); + EXPECT_EQ(hi.text, "World"_s); + EXPECT_EQ(hi.line, 3); + EXPECT_EQ(hi.column, 0); + EXPECT_FALSE(lr.read_line(hi)); +} TEST(io, linechar1) { @@ -382,6 +396,42 @@ TEST(io, linechar5) lr.adv(); EXPECT_FALSE(lr.get(c)); } +TEST(io, linechar1text) +{ + io::LineCharReader lr(io::from_string, "<stringchar1text>"_s, "Hi\nWu\n"_s, 2, 3); + io::LineChar c; + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), 'H'); + EXPECT_EQ(c.line, 2); + EXPECT_EQ(c.column, 3); + lr.adv(); + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), 'i'); + EXPECT_EQ(c.line, 2); + EXPECT_EQ(c.column, 4); + lr.adv(); + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), '\n'); + EXPECT_EQ(c.line, 2); + EXPECT_EQ(c.column, 5); + lr.adv(); + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), 'W'); + EXPECT_EQ(c.line, 3); + EXPECT_EQ(c.column, 1); + lr.adv(); + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), 'u'); + EXPECT_EQ(c.line, 3); + EXPECT_EQ(c.column, 2); + lr.adv(); + EXPECT_TRUE(lr.get(c)); + EXPECT_EQ(c.ch(), '\n'); + EXPECT_EQ(c.line, 3); + EXPECT_EQ(c.column, 3); + lr.adv(); + EXPECT_FALSE(lr.get(c)); +} TEST(io, linespan) { |