From d6b80d1b95ac566e7eb9b75389fb10ae8610dd6f Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 5 Apr 2014 13:26:39 -0700 Subject: Fix assert in multiline spans --- src/io/line.cpp | 2 +- src/io/line_test.cpp | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/io/line.cpp b/src/io/line.cpp index 8173398..f7470a6 100644 --- a/src/io/line.cpp +++ b/src/io/line.cpp @@ -62,7 +62,7 @@ namespace io { assert (begin.column); assert (end.column); - assert (begin.column <= end.column); + assert (begin.line < end.line || begin.column <= end.column); MString out; if (begin.line == end.line) diff --git a/src/io/line_test.cpp b/src/io/line_test.cpp index 6f0706f..df8a0d3 100644 --- a/src/io/line_test.cpp +++ b/src/io/line_test.cpp @@ -351,7 +351,7 @@ TEST(io, linechar5) TEST(io, linespan) { - io::LineCharReader lr("", string_pipe("Hello\nWorld\n")); + io::LineCharReader lr("", string_pipe("Hello,\nWorld!\n")); io::LineSpan span; do { @@ -367,9 +367,10 @@ TEST(io, linespan) while (span.end.ch() != 'o'); EXPECT_EQ(span.message_str("info", "meh"), ":1:2: info: meh\n" - "Hello\n" + "Hello,\n" " ^~~~\n" ); + span.begin = span.end; do { lr.get(span.end); @@ -378,20 +379,20 @@ TEST(io, linespan) while (span.end.ch() != 'r'); EXPECT_EQ(span.begin.message_str("note", "foo"), - ":1:2: note: foo\n" - "Hello\n" - " ^\n" + ":1:5: note: foo\n" + "Hello,\n" + " ^\n" ); EXPECT_EQ(span.end.message_str("warning", "bar"), ":2:3: warning: bar\n" - "World\n" + "World!\n" " ^\n" ); EXPECT_EQ(span.message_str("error", "qux"), - ":1:2: error: qux\n" - "Hello\n" - " ^~~~ ...\n" - "World\n" + ":1:5: error: qux\n" + "Hello,\n" + " ^~ ...\n" + "World!\n" "~~~\n" ); } -- cgit v1.2.3-70-g09d2