1
0
forked from Alepha/Alepha

Add line-comment filter for streambuf.

This commit is contained in:
2024-08-08 17:12:33 -04:00
parent a8c6780cb9
commit 0737afc002
4 changed files with 211 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#include "../LineComments.h"
#include <sstream>
#include <Alepha/Testing/test.h>
#include <Alepha/Testing/TableTest.h>
#include <Alepha/Utility/evaluation_helpers.h>
static auto
stream( const std::string &text )
{
std::istringstream iss{ text };
iss >> Alepha::IOStreams::DropComments{};
std::string s;
getline( iss, s, {} );
return s;
}
static auto init= Alepha::Utility::enroll <=[]
{
using namespace Alepha::Testing::exports;
"Do we strip comments correctly"_test <=TableTest< stream >
::Cases
{
{ "Simple (no comment)", { "Hello World!" }, "Hello World!" },
{ "Simple (One comment)", { "Hello World!# Comment" }, "Hello World!" },
{ "Two lines (One comment at end)", { "Hello World!\nGoodbye World! # Comment" }, "Hello World!\nGoodbye World! " },
{ "Two lines (One comment after first)", { "Hello World! #Comment\nGoodbye World!" }, "Hello World! \nGoodbye World!" },
{ "Two lines (Two comments)", { "Hello World! #Comment\nGoodbye World! #Comment" }, "Hello World! \nGoodbye World! " },
{ "Two lines (Two comments, extra newline)", { "Hello World! #Comment\nGoodbye World! #Comment\n" }, "Hello World! \nGoodbye World! \n" },
};
};