1
0
forked from Alepha/Alepha
Files

40 lines
1.1 KiB
C++

#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" },
};
};