From 67d36e699a2852ce471c4d1b8dab5992d6c01a98 Mon Sep 17 00:00:00 2001 From: Andreas Stöckel Date: Sat, 24 Jan 2015 03:08:16 +0100 Subject: Implemented SourceContextReader, added unit tests, implemented SourceContextReader interface in ResourceManager, added LoggerTest --- test/core/common/CharReaderTest.cpp | 167 ------------------------------------ 1 file changed, 167 deletions(-) (limited to 'test/core/common/CharReaderTest.cpp') diff --git a/test/core/common/CharReaderTest.cpp b/test/core/common/CharReaderTest.cpp index fba60f9..a1ea18f 100644 --- a/test/core/common/CharReaderTest.cpp +++ b/test/core/common/CharReaderTest.cpp @@ -565,172 +565,5 @@ TEST(CharReader, fork) ASSERT_EQ(5, reader.getOffset()); } -/*TEST(CharReader, context) -{ - std::string testStr{"first line\n\n\rsecond line\n\rlast line"}; - // 0123456789 0 123456789012 3456789012 - // 0 1 2 3 - - // Retrieval at beginning of stream - { - CharReader reader{testStr}; - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("first line", ctx.text); - ASSERT_EQ(0, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Retrieval in middle of line - { - CharReader reader{testStr}; - SourceContext ctx = reader.getContext(80); - - char c; - for (int i = 0; i < 5; i++) - reader.read(c); - - ASSERT_EQ("first line", ctx.text); - ASSERT_EQ(0, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Retrieval in whitespace sequence - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 11; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("first line", ctx.text); - ASSERT_EQ(10, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Truncation of text - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 5; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(3); - ASSERT_EQ("t l", ctx.text); - ASSERT_EQ(1, ctx.relPos); - ASSERT_TRUE(ctx.truncatedStart); - ASSERT_TRUE(ctx.truncatedEnd); - } - - // Second line - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 12; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("second line", ctx.text); - ASSERT_EQ(0, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // End of second line - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 23; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("second line", ctx.text); - ASSERT_EQ(11, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Last line - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 24; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("last line", ctx.text); - ASSERT_EQ(0, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Middle of last line - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 28; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("last line", ctx.text); - ASSERT_EQ(4, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // Middle of last line truncated - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 28; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(3); - ASSERT_EQ("t l", ctx.text); - ASSERT_EQ(1, ctx.relPos); - ASSERT_TRUE(ctx.truncatedStart); - ASSERT_TRUE(ctx.truncatedEnd); - } - - // End of stream - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 100; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(80); - ASSERT_EQ("last line", ctx.text); - ASSERT_EQ(9, ctx.relPos); - ASSERT_FALSE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } - - // End of stream truncated - { - CharReader reader{testStr}; - - char c; - for (int i = 0; i < 100; i++) - reader.read(c); - - SourceContext ctx = reader.getContext(4); - ASSERT_EQ("line", ctx.text); - ASSERT_EQ(4, ctx.relPos); - ASSERT_TRUE(ctx.truncatedStart); - ASSERT_FALSE(ctx.truncatedEnd); - } -}*/ - } -- cgit v1.2.3