diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-24 03:08:16 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-24 03:08:16 +0100 |
commit | 67d36e699a2852ce471c4d1b8dab5992d6c01a98 (patch) | |
tree | 0ef23befe3fa5af9c5d83b3b8934e444366a8575 /test/core/common/LoggerTest.cpp | |
parent | f819b42057b2baea205569dd808c4fcf2bc4d630 (diff) |
Implemented SourceContextReader, added unit tests, implemented SourceContextReader interface in ResourceManager, added LoggerTest
Diffstat (limited to 'test/core/common/LoggerTest.cpp')
-rw-r--r-- | test/core/common/LoggerTest.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/test/core/common/LoggerTest.cpp b/test/core/common/LoggerTest.cpp index 9b20cc6..7b0e6d0 100644 --- a/test/core/common/LoggerTest.cpp +++ b/test/core/common/LoggerTest.cpp @@ -20,28 +20,51 @@ #include <gtest/gtest.h> +#include <core/common/CharReader.hpp> #include <core/common/Logger.hpp> +#include <core/common/SourceContextReader.hpp> namespace ousia { struct Pos { SourceLocation pos; - Pos(SourceLocation pos = SourceLocation{}) - : pos(pos) {}; + Pos(SourceLocation pos = SourceLocation{}) : pos(pos){}; SourceLocation getLocation() { return pos; } }; +static const std::string testStr = + "\\link[domain]{book}\n" // 1 + "\\link[domain]{meta}\n" // 2 + "\n" // 3 + "\\meta{\n" // 4 + "\t\\title{The Adventures Of Tom Sawyer}\n" // 5 + "\t\\author{Mark Twain}\n" // 6 + "}\n" // 7 + "\n" // 8 + "\\book{\n" // 9 + "\n" // 10 + "\n" // 11 + "\\chapter\n" // 12 + "<<TOM!>>\n" // 13 + "\n" // 14 + "No answer.\n" // 15 + "\n" // 16 + "<<TOM!>>\n" // 17 + "\n" // 18 + "No answer.\n" // 19 + "\n" // 20 + "<<What's gone with that boy, I wonder? You TOM!>>\n" // 21 + "}\n"; // 22 + +static SourceContextReader contextReader{}; + static SourceContext contextCallback(const SourceLocation &location) { - SourceContext ctx; - ctx.filename = "testfile.test"; - ctx.startLine = 10; - ctx.endLine = 10; - ctx.startColumn = 20; - ctx.endColumn = 20; - return ctx; + CharReader reader{testStr, 0}; + return contextReader.readContext(reader, location, 60, + "the_adventures_of_tom_sawyer.opd"); } TEST(TerminalLogger, log) @@ -52,6 +75,9 @@ TEST(TerminalLogger, log) logger.debug("This is a test debug message"); logger.note("This is a test note"); + logger.note("This is a test note with point context", SourceLocation{0, 49}); + logger.note("This is a test note with range context", SourceLocation{0, 49, 55}); + logger.note("This is a test note with multiline context", SourceLocation{0, 49, 150}); logger.warning("This is a test warning"); logger.error("This is a test error"); logger.fatalError("This is a test fatal error!"); |