/*
	This file is part of solidity.
	solidity is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	solidity is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	You should have received a copy of the GNU General Public License
	along with solidity.  If not, see .
*/
// SPDX-License-Identifier: GPL-3.0
/**
 * Unit tests for the mini moustache class.
 */
#include 
#include 
#include 
using namespace std;
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(WhiskersTest, *boost::unit_test::label("nooptions"))
BOOST_AUTO_TEST_CASE(no_templates)
{
	string templ = "this text does not contain templates";
	BOOST_CHECK_EQUAL(Whiskers(templ).render(), templ);
}
BOOST_AUTO_TEST_CASE(basic_replacement)
{
	string templ = "a  x  -> .";
	string result = Whiskers(templ)
		("b", "BE")
		("c", "CE")
		("d", "DE")
		.render();
	BOOST_CHECK_EQUAL(result, "a BE x CE -> DE.");
}
BOOST_AUTO_TEST_CASE(tag_unavailable)
{
	string templ = "";
	Whiskers m(templ);
	BOOST_CHECK_THROW(m.render(), WhiskersError);
}
BOOST_AUTO_TEST_CASE(list_unavailable)
{
	string templ = "<#b>";
	Whiskers m(templ);
	BOOST_CHECK_THROW(m.render(), WhiskersError);
}
BOOST_AUTO_TEST_CASE(name_type_collision)
{
	string templ = "<#b>";
	Whiskers m(templ);
	m("b", "x");
	BOOST_CHECK_THROW(m("b", vector";
	BOOST_CHECK_EQUAL(Whiskers(templ)("b", true).render(), "X");
	BOOST_CHECK_EQUAL(Whiskers(templ)("b", false).render(), "");
}
BOOST_AUTO_TEST_CASE(conditional_with_else)
{
	string templ = "XY";
	BOOST_CHECK_EQUAL(Whiskers(templ)("b", true).render(), "X");
	BOOST_CHECK_EQUAL(Whiskers(templ)("b", false).render(), "Y");
}
BOOST_AUTO_TEST_CASE(conditional_plus_params)
{
	string templ = " - _^ - ";
	Whiskers m1(templ);
	m1("b", true);
	m1("r", "R");
	m1("t", "T");
	BOOST_CHECK_EQUAL(m1.render(), " - _R - ");
	Whiskers m2(templ);
	m2("b", false);
	m2("r", "R");
	m2("t", "T");
	BOOST_CHECK_EQUAL(m2.render(), " - ^T - ");
}
BOOST_AUTO_TEST_CASE(conditional_plus_list)
{
	string templ = " - _<#l><#l> - ";
	Whiskers m(templ);
	m("b", false);
	vector