mirror of
https://github.com/pantor/inja.git
synced 2026-08-11 01:43:21 +00:00
add clang-format
This commit is contained in:
+246
-216
@@ -3,231 +3,261 @@
|
||||
#include "hayai/hayai.hpp"
|
||||
#include <inja/inja.hpp>
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
inja::Environment env;
|
||||
|
||||
json smallData = {{"name","Peter"},
|
||||
{"list001",{"lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","aliquam","accumsan"}},
|
||||
{"list002",{"donec","in","egestas","diam","aenean","suscipit","scelerisque","efficitur","integer","a"}},
|
||||
{"list003",{"maecenas","metus","erat","vestibulum","quis","porta","in","consequat","sed","justo"}},
|
||||
json smallData = {
|
||||
{"name", "Peter"},
|
||||
{"list001", {"lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "aliquam", "accumsan"}},
|
||||
{"list002", {"donec", "in", "egestas", "diam", "aenean", "suscipit", "scelerisque", "efficitur", "integer", "a"}},
|
||||
{"list003", {"maecenas", "metus", "erat", "vestibulum", "quis", "porta", "in", "consequat", "sed", "justo"}},
|
||||
};
|
||||
|
||||
json largeData = {{"name","Peter"},
|
||||
{"list001",{"lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","aliquam","accumsan"}},
|
||||
{"list002",{"donec","in","egestas","diam","aenean","suscipit","scelerisque","efficitur","integer","a"}},
|
||||
{"list003",{"maecenas","metus","erat","vestibulum","quis","porta","in","consequat","sed","justo"}},
|
||||
{"list004",{"aliquam","erat","volutpat","integer","laoreet","tellus","ut","nibh","viverra","in"}},
|
||||
{"list005",{"integer","eu","velit","ac","erat","fringilla","ullamcorper","id","in","tortor"}},
|
||||
{"list006",{"quisque","at","dapibus","ante","donec","et","lectus","sit","amet","lorem"}},
|
||||
{"list007",{"curabitur","imperdiet","nibh","sit","amet","pellentesque","tincidunt","quisque","ornare","enim"}},
|
||||
{"list008",{"aliquam","vitae","condimentum","libero","non","sodales","metus","vestibulum","aliquet","ullamcorper"}},
|
||||
{"list009",{"pellentesque","sed","diam","tellus","donec","sed","nulla","lorem","sed","imperdiet"}},
|
||||
{"list010",{"nam","sagittis","maximus","congue","class","aptent","taciti","sociosqu","ad","litora"}},
|
||||
{"list011",{"praesent","semper","elit","ut","consequat","fringilla","mauris","turpis","volutpat","risus"}},
|
||||
{"list012",{"nullam","risus","urna","facilisis","sit","amet","nibh","id","blandit","mollis"}},
|
||||
{"list013",{"donec","non","ante","nisi","praesent","suscipit","erat","quis","lorem","convallis"}},
|
||||
{"list014",{"maecenas","tincidunt","suscipit","ipsum","non","tristique","proin","accumsan","cursus","justo"}},
|
||||
{"list015",{"nulla","facilisi","nullam","et","enim","finibus","aliquet","mi","ut","mattis"}},
|
||||
{"list016",{"fusce","rutrum","lobortis","ligula","vitae","condimentum","risus","ultrices","sed","sed"}},
|
||||
{"list017",{"nullam","quis","tristique","ante","proin","neque","ante","sollicitudin","non","bibendum"}},
|
||||
{"list018",{"nam","bibendum","quam","et","semper","eleifend","donec","placerat","scelerisque","mi"}},
|
||||
{"list019",{"donec","vel","suscipit","turpis","cras","semper","arcu","in","velit","hendrerit"}},
|
||||
{"list020",{"praesent","congue","gravida","mauris","integer","ornare","dictum","lorem","non","consequat"}},
|
||||
{"list021",{"nam","tincidunt","tortor","sit","amet","gravida","dapibus","fusce","laoreet","nulla"}},
|
||||
{"list022",{"in","id","enim","pellentesque","suscipit","velit","id","posuere","metus","quisque"}},
|
||||
{"list023",{"curabitur","elit","ex","aliquam","eget","mi","sed","tristique","scelerisque","ligula"}},
|
||||
{"list024",{"vivamus","dui","lacus","hendrerit","eu","sagittis","non","finibus","consequat","turpis"}},
|
||||
{"list025",{"etiam","ultrices","vel","massa","non","vehicula","duis","aliquet","massa","id"}},
|
||||
{"list026",{"duis","ultrices","sem","a","sapien","dignissim","hendrerit","eu","vel","sem"}},
|
||||
{"list027",{"vivamus","eu","elit","ac","metus","pharetra","pretium","etiam","mattis","velit"}},
|
||||
{"list028",{"ut","ac","commodo","risus","nam","eget","hendrerit","magna","vestibulum","elementum"}},
|
||||
{"list029",{"mauris","in","ultricies","tellus","ut","in","velit","porttitor","vulputate","enim"}},
|
||||
{"list030",{"donec","dapibus","urna","ac","scelerisque","mollis","urna","orci","congue","nulla"}},
|
||||
{"list031",{"vivamus","eleifend","dapibus","maximus","donec","eu","accumsan","nulla","eu","iaculis"}},
|
||||
{"list032",{"aliquam","erat","volutpat","orci","varius","natoque","penatibus","et","magnis","dis"}},
|
||||
{"list033",{"maecenas","laoreet","sed","quam","eget","bibendum","etiam","et","sollicitudin","mi"}},
|
||||
{"list034",{"aliquam","rhoncus","purus","vel","nibh","laoreet","pharetra","vestibulum","ante","ipsum"}},
|
||||
{"list035",{"quisque","semper","urna","vel","mollis","gravida","fusce","nibh","mauris","porttitor"}},
|
||||
{"list036",{"sed","luctus","risus","et","sodales","mollis","maecenas","a","tincidunt","risus"}},
|
||||
{"list037",{"in","hac","habitasse","platea","dictumst","nullam","fermentum","commodo","tempor","aenean"}},
|
||||
{"list038",{"nunc","rhoncus","diam","magna","ac","lacinia","felis","consequat","non","maecenas"}},
|
||||
{"list039",{"sed","scelerisque","velit","est","sed","mollis","ligula","cursus","sed","aliquam"}},
|
||||
{"list040",{"nulla","dictum","arcu","eu","mauris","malesuada","quis","cursus","nisi","faucibus"}},
|
||||
{"list041",{"phasellus","posuere","lacus","nec","molestie","accumsan","metus","tortor","facilisis","nunc"}},
|
||||
{"list042",{"curabitur","ex","neque","pretium","sit","amet","leo","in","tempus","vestibulum"}},
|
||||
{"list043",{"curabitur","tortor","tortor","fermentum","eget","velit","ac","cursus","faucibus","odio"}},
|
||||
{"list044",{"aenean","varius","malesuada","sapien","sed","hendrerit","purus","molestie","sed","sed"}},
|
||||
{"list045",{"nam","hendrerit","pretium","purus","id","fermentum","nunc","in","lacus","metus"}},
|
||||
{"list046",{"fusce","euismod","libero","sed","diam","pharetra","non","semper","elit","accumsan"}},
|
||||
{"list047",{"phasellus","sed","ligula","sit","amet","justo","vestibulum","fermentum","congue","sed"}},
|
||||
{"list048",{"sed","dignissim","felis","eget","elit","dictum","malesuada","vivamus","maximus","mi"}},
|
||||
{"list049",{"proin","lobortis","tempus","molestie","sed","tortor","ipsum","finibus","non","aliquet"}},
|
||||
{"list050",{"integer","ut","leo","dui","proin","condimentum","dolor","a","suscipit","maximus"}},
|
||||
{"list051",{"vivamus","sapien","neque","dapibus","sed","volutpat","at","vestibulum","sit","amet"}},
|
||||
{"list052",{"curabitur","enim","enim","faucibus","sit","amet","luctus","aliquam","placerat","nec"}},
|
||||
{"list053",{"suspendisse","ligula","dolor","ultricies","sit","amet","iaculis","vel","luctus","sit"}},
|
||||
{"list054",{"aenean","aliquam","elit","sit","amet","ultricies","lobortis","nullam","porttitor","libero"}},
|
||||
{"list055",{"ut","tincidunt","convallis","placerat","suspendisse","potenti","cras","commodo","fringilla","lacus"}},
|
||||
{"list056",{"nulla","quis","elit","est","etiam","sagittis","molestie","porta","lorem","ipsum"}},
|
||||
{"list057",{"in","turpis","nibh","gravida","vitae","ex","eu","eleifend","tincidunt","neque"}},
|
||||
{"list058",{"suspendisse","in","fermentum","orci","etiam","viverra","metus","a","condimentum","blandit"}},
|
||||
{"list059",{"fusce","dapibus","velit","id","est","maximus","rhoncus","quisque","lobortis","tortor"}},
|
||||
{"list060",{"ut","molestie","ornare","velit","id","consectetur","nunc","varius","eu","vivamus"}},
|
||||
{"list061",{"aenean","egestas","nibh","at","tincidunt","varius","felis","metus","ullamcorper","purus"}},
|
||||
{"list062",{"donec","a","eleifend","libero","sed","fermentum","sem","fusce","eget","lacinia"}},
|
||||
{"list063",{"nullam","metus","mauris","ornare","in","sem","at","posuere","placerat","nisl"}},
|
||||
{"list064",{"maecenas","vitae","enim","ipsum","sed","mattis","porta","mi","congue","suscipit"}},
|
||||
{"list065",{"nulla","placerat","porttitor","metus","non","suscipit","turpis","rhoncus","non","etiam"}},
|
||||
{"list066",{"morbi","id","fringilla","quam","eget","sollicitudin","felis","aliquam","quis","risus"}},
|
||||
{"list067",{"pellentesque","maximus","leo","ut","quam","consequat","lacinia","suspendisse","facilisis","leo"}},
|
||||
{"list068",{"phasellus","rhoncus","urna","felis","nullam","pharetra","porttitor","neque","sit","amet"}},
|
||||
{"list069",{"in","posuere","mauris","sit","amet","nisl","tempor","eget","euismod","neque"}},
|
||||
{"list070",{"mauris","id","lobortis","magna","suspendisse","nisl","orci","auctor","suscipit","malesuada"}},
|
||||
{"list071",{"ut","facilisis","magna","vitae","ligula","laoreet","tempor","class","aptent","taciti"}},
|
||||
{"list072",{"aenean","sagittis","lacus","vel","nulla","porta","quis","egestas","sem","ullamcorper"}},
|
||||
{"list073",{"donec","eget","purus","scelerisque","rutrum","dolor","eget","maximus","dui","aliquam"}},
|
||||
{"list074",{"donec","congue","a","massa","vel","posuere","donec","ullamcorper","elit","id"}},
|
||||
{"list075",{"praesent","consectetur","est","eu","tellus","dictum","tempor","nullam","id","risus"}},
|
||||
{"list076",{"etiam","gravida","gravida","tempus","fusce","lobortis","orci","ac","volutpat","mollis"}},
|
||||
{"list077",{"quisque","quis","turpis","et","augue","dignissim","maximus","donec","vel","justo"}},
|
||||
{"list078",{"aenean","consectetur","mi","non","nibh","bibendum","ac","tincidunt","dui","tristique"}},
|
||||
{"list079",{"aliquam","tempus","elit","non","ipsum","finibus","ut","luctus","dolor","tincidunt"}},
|
||||
{"list080",{"donec","eget","ultricies","tellus","et","imperdiet","tellus","vivamus","maximus","massa"}},
|
||||
{"list081",{"pellentesque","eget","volutpat","velit","eu","venenatis","mi","suspendisse","fringilla","dignissim"}},
|
||||
{"list082",{"maecenas","auctor","leo","sed","sapien","vehicula","nec","porttitor","ante","porta"}},
|
||||
{"list083",{"nulla","risus","lectus","interdum","rutrum","aliquam","sed","consectetur","id","risus"}},
|
||||
{"list084",{"vestibulum","ante","ipsum","primis","in","faucibus","orci","luctus","et","ultrices"}},
|
||||
{"list085",{"vivamus","vestibulum","leo","vitae","lorem","tincidunt","nec","gravida","neque","vehicula"}},
|
||||
{"list086",{"donec","mollis","urna","lectus","praesent","ornare","arcu","convallis","lacus","tempus"}},
|
||||
{"list087",{"nam","laoreet","nibh","vel","pretium","vestibulum","cras","finibus","eget","eros"}},
|
||||
{"list088",{"integer","pulvinar","nunc","nec","orci","accumsan","venenatis","maecenas","quam","est"}},
|
||||
{"list089",{"ut","aliquet","risus","vel","dapibus","tristique","fusce","rutrum","risus","cursus"}},
|
||||
{"list090",{"suspendisse","ac","ullamcorper","justo","morbi","vel","dolor","condimentum","viverra","ligula"}},
|
||||
{"list091",{"phasellus","vestibulum","elit","et","dictum","rutrum","velit","odio","mattis","odio"}},
|
||||
{"list092",{"curabitur","nunc","diam","pellentesque","sed","ultrices","et","varius","non","lacus"}},
|
||||
{"list093",{"aliquam","consectetur","elementum","felis","sed","hendrerit","massa","consectetur","sagittis","nunc"}},
|
||||
{"list094",{"in","hac","habitasse","platea","dictumst","integer","hendrerit","lorem","nec","auctor"}},
|
||||
{"list095",{"pellentesque","dictum","mattis","mattis","donec","nec","commodo","nibh","in","imperdiet"}},
|
||||
{"list096",{"mauris","eget","urna","vulputate","iaculis","tellus","pharetra","laoreet","justo","proin"}},
|
||||
{"list097",{"nam","tincidunt","tortor","eu","scelerisque","convallis","erat","magna","consectetur","enim"}},
|
||||
{"list098",{"aenean","posuere","ante","vitae","lobortis","fringilla","magna","lorem","volutpat","dui"}},
|
||||
{"list099",{"suspendisse","mattis","arcu","ut","ipsum","cursus","vestibulum","interdum","et","malesuada"}},
|
||||
{"list100",{"aenean","pharetra","leo","sem","non","pretium","nibh","faucibus","id","duis"}},
|
||||
{"list101",{"lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","aliquam","accumsan"}},
|
||||
{"list102",{"donec","in","egestas","diam","aenean","suscipit","scelerisque","efficitur","integer","a"}},
|
||||
{"list103",{"maecenas","metus","erat","vestibulum","quis","porta","in","consequat","sed","justo"}},
|
||||
{"list104",{"aliquam","erat","volutpat","integer","laoreet","tellus","ut","nibh","viverra","in"}},
|
||||
{"list105",{"integer","eu","velit","ac","erat","fringilla","ullamcorper","id","in","tortor"}},
|
||||
{"list106",{"quisque","at","dapibus","ante","donec","et","lectus","sit","amet","lorem"}},
|
||||
{"list107",{"curabitur","imperdiet","nibh","sit","amet","pellentesque","tincidunt","quisque","ornare","enim"}},
|
||||
{"list108",{"aliquam","vitae","condimentum","libero","non","sodales","metus","vestibulum","aliquet","ullamcorper"}},
|
||||
{"list109",{"pellentesque","sed","diam","tellus","donec","sed","nulla","lorem","sed","imperdiet"}},
|
||||
{"list110",{"nam","sagittis","maximus","congue","class","aptent","taciti","sociosqu","ad","litora"}},
|
||||
{"list111",{"praesent","semper","elit","ut","consequat","fringilla","mauris","turpis","volutpat","risus"}},
|
||||
{"list112",{"nullam","risus","urna","facilisis","sit","amet","nibh","id","blandit","mollis"}},
|
||||
{"list113",{"donec","non","ante","nisi","praesent","suscipit","erat","quis","lorem","convallis"}},
|
||||
{"list114",{"maecenas","tincidunt","suscipit","ipsum","non","tristique","proin","accumsan","cursus","justo"}},
|
||||
{"list115",{"nulla","facilisi","nullam","et","enim","finibus","aliquet","mi","ut","mattis"}},
|
||||
{"list116",{"fusce","rutrum","lobortis","ligula","vitae","condimentum","risus","ultrices","sed","sed"}},
|
||||
{"list117",{"nullam","quis","tristique","ante","proin","neque","ante","sollicitudin","non","bibendum"}},
|
||||
{"list118",{"nam","bibendum","quam","et","semper","eleifend","donec","placerat","scelerisque","mi"}},
|
||||
{"list119",{"donec","vel","suscipit","turpis","cras","semper","arcu","in","velit","hendrerit"}},
|
||||
{"list120",{"praesent","congue","gravida","mauris","integer","ornare","dictum","lorem","non","consequat"}},
|
||||
{"list121",{"nam","tincidunt","tortor","sit","amet","gravida","dapibus","fusce","laoreet","nulla"}},
|
||||
{"list122",{"in","id","enim","pellentesque","suscipit","velit","id","posuere","metus","quisque"}},
|
||||
{"list123",{"curabitur","elit","ex","aliquam","eget","mi","sed","tristique","scelerisque","ligula"}},
|
||||
{"list124",{"vivamus","dui","lacus","hendrerit","eu","sagittis","non","finibus","consequat","turpis"}},
|
||||
{"list125",{"etiam","ultrices","vel","massa","non","vehicula","duis","aliquet","massa","id"}},
|
||||
{"list126",{"duis","ultrices","sem","a","sapien","dignissim","hendrerit","eu","vel","sem"}},
|
||||
{"list127",{"vivamus","eu","elit","ac","metus","pharetra","pretium","etiam","mattis","velit"}},
|
||||
{"list128",{"ut","ac","commodo","risus","nam","eget","hendrerit","magna","vestibulum","elementum"}},
|
||||
{"list129",{"mauris","in","ultricies","tellus","ut","in","velit","porttitor","vulputate","enim"}},
|
||||
{"list130",{"donec","dapibus","urna","ac","scelerisque","mollis","urna","orci","congue","nulla"}},
|
||||
{"list131",{"vivamus","eleifend","dapibus","maximus","donec","eu","accumsan","nulla","eu","iaculis"}},
|
||||
{"list132",{"aliquam","erat","volutpat","orci","varius","natoque","penatibus","et","magnis","dis"}},
|
||||
{"list133",{"maecenas","laoreet","sed","quam","eget","bibendum","etiam","et","sollicitudin","mi"}},
|
||||
{"list134",{"aliquam","rhoncus","purus","vel","nibh","laoreet","pharetra","vestibulum","ante","ipsum"}},
|
||||
{"list135",{"quisque","semper","urna","vel","mollis","gravida","fusce","nibh","mauris","porttitor"}},
|
||||
{"list136",{"sed","luctus","risus","et","sodales","mollis","maecenas","a","tincidunt","risus"}},
|
||||
{"list137",{"in","hac","habitasse","platea","dictumst","nullam","fermentum","commodo","tempor","aenean"}},
|
||||
{"list138",{"nunc","rhoncus","diam","magna","ac","lacinia","felis","consequat","non","maecenas"}},
|
||||
{"list139",{"sed","scelerisque","velit","est","sed","mollis","ligula","cursus","sed","aliquam"}},
|
||||
{"list140",{"nulla","dictum","arcu","eu","mauris","malesuada","quis","cursus","nisi","faucibus"}},
|
||||
{"list141",{"phasellus","posuere","lacus","nec","molestie","accumsan","metus","tortor","facilisis","nunc"}},
|
||||
{"list142",{"curabitur","ex","neque","pretium","sit","amet","leo","in","tempus","vestibulum"}},
|
||||
{"list143",{"curabitur","tortor","tortor","fermentum","eget","velit","ac","cursus","faucibus","odio"}},
|
||||
{"list144",{"aenean","varius","malesuada","sapien","sed","hendrerit","purus","molestie","sed","sed"}},
|
||||
{"list145",{"nam","hendrerit","pretium","purus","id","fermentum","nunc","in","lacus","metus"}},
|
||||
{"list146",{"fusce","euismod","libero","sed","diam","pharetra","non","semper","elit","accumsan"}},
|
||||
{"list147",{"phasellus","sed","ligula","sit","amet","justo","vestibulum","fermentum","congue","sed"}},
|
||||
{"list148",{"sed","dignissim","felis","eget","elit","dictum","malesuada","vivamus","maximus","mi"}},
|
||||
{"list149",{"proin","lobortis","tempus","molestie","sed","tortor","ipsum","finibus","non","aliquet"}},
|
||||
{"list150",{"integer","ut","leo","dui","proin","condimentum","dolor","a","suscipit","maximus"}},
|
||||
{"list151",{"vivamus","sapien","neque","dapibus","sed","volutpat","at","vestibulum","sit","amet"}},
|
||||
{"list152",{"curabitur","enim","enim","faucibus","sit","amet","luctus","aliquam","placerat","nec"}},
|
||||
{"list153",{"suspendisse","ligula","dolor","ultricies","sit","amet","iaculis","vel","luctus","sit"}},
|
||||
{"list154",{"aenean","aliquam","elit","sit","amet","ultricies","lobortis","nullam","porttitor","libero"}},
|
||||
{"list155",{"ut","tincidunt","convallis","placerat","suspendisse","potenti","cras","commodo","fringilla","lacus"}},
|
||||
{"list156",{"nulla","quis","elit","est","etiam","sagittis","molestie","porta","lorem","ipsum"}},
|
||||
{"list157",{"in","turpis","nibh","gravida","vitae","ex","eu","eleifend","tincidunt","neque"}},
|
||||
{"list158",{"suspendisse","in","fermentum","orci","etiam","viverra","metus","a","condimentum","blandit"}},
|
||||
{"list159",{"fusce","dapibus","velit","id","est","maximus","rhoncus","quisque","lobortis","tortor"}},
|
||||
{"list160",{"ut","molestie","ornare","velit","id","consectetur","nunc","varius","eu","vivamus"}},
|
||||
{"list161",{"aenean","egestas","nibh","at","tincidunt","varius","felis","metus","ullamcorper","purus"}},
|
||||
{"list162",{"donec","a","eleifend","libero","sed","fermentum","sem","fusce","eget","lacinia"}},
|
||||
{"list163",{"nullam","metus","mauris","ornare","in","sem","at","posuere","placerat","nisl"}},
|
||||
{"list164",{"maecenas","vitae","enim","ipsum","sed","mattis","porta","mi","congue","suscipit"}},
|
||||
{"list165",{"nulla","placerat","porttitor","metus","non","suscipit","turpis","rhoncus","non","etiam"}},
|
||||
{"list166",{"morbi","id","fringilla","quam","eget","sollicitudin","felis","aliquam","quis","risus"}},
|
||||
{"list167",{"pellentesque","maximus","leo","ut","quam","consequat","lacinia","suspendisse","facilisis","leo"}},
|
||||
{"list168",{"phasellus","rhoncus","urna","felis","nullam","pharetra","porttitor","neque","sit","amet"}},
|
||||
{"list169",{"in","posuere","mauris","sit","amet","nisl","tempor","eget","euismod","neque"}},
|
||||
{"list170",{"mauris","id","lobortis","magna","suspendisse","nisl","orci","auctor","suscipit","malesuada"}},
|
||||
{"list171",{"ut","facilisis","magna","vitae","ligula","laoreet","tempor","class","aptent","taciti"}},
|
||||
{"list172",{"aenean","sagittis","lacus","vel","nulla","porta","quis","egestas","sem","ullamcorper"}},
|
||||
{"list173",{"donec","eget","purus","scelerisque","rutrum","dolor","eget","maximus","dui","aliquam"}},
|
||||
{"list174",{"donec","congue","a","massa","vel","posuere","donec","ullamcorper","elit","id"}},
|
||||
{"list175",{"praesent","consectetur","est","eu","tellus","dictum","tempor","nullam","id","risus"}},
|
||||
{"list176",{"etiam","gravida","gravida","tempus","fusce","lobortis","orci","ac","volutpat","mollis"}},
|
||||
{"list177",{"quisque","quis","turpis","et","augue","dignissim","maximus","donec","vel","justo"}},
|
||||
{"list178",{"aenean","consectetur","mi","non","nibh","bibendum","ac","tincidunt","dui","tristique"}},
|
||||
{"list179",{"aliquam","tempus","elit","non","ipsum","finibus","ut","luctus","dolor","tincidunt"}},
|
||||
{"list180",{"donec","eget","ultricies","tellus","et","imperdiet","tellus","vivamus","maximus","massa"}},
|
||||
{"list181",{"pellentesque","eget","volutpat","velit","eu","venenatis","mi","suspendisse","fringilla","dignissim"}},
|
||||
{"list182",{"maecenas","auctor","leo","sed","sapien","vehicula","nec","porttitor","ante","porta"}},
|
||||
{"list183",{"nulla","risus","lectus","interdum","rutrum","aliquam","sed","consectetur","id","risus"}},
|
||||
{"list184",{"vestibulum","ante","ipsum","primis","in","faucibus","orci","luctus","et","ultrices"}},
|
||||
{"list185",{"vivamus","vestibulum","leo","vitae","lorem","tincidunt","nec","gravida","neque","vehicula"}},
|
||||
{"list186",{"donec","mollis","urna","lectus","praesent","ornare","arcu","convallis","lacus","tempus"}},
|
||||
{"list187",{"nam","laoreet","nibh","vel","pretium","vestibulum","cras","finibus","eget","eros"}},
|
||||
{"list188",{"integer","pulvinar","nunc","nec","orci","accumsan","venenatis","maecenas","quam","est"}},
|
||||
{"list189",{"ut","aliquet","risus","vel","dapibus","tristique","fusce","rutrum","risus","cursus"}},
|
||||
{"list190",{"suspendisse","ac","ullamcorper","justo","morbi","vel","dolor","condimentum","viverra","ligula"}},
|
||||
{"list191",{"phasellus","vestibulum","elit","et","dictum","rutrum","velit","odio","mattis","odio"}},
|
||||
{"list192",{"curabitur","nunc","diam","pellentesque","sed","ultrices","et","varius","non","lacus"}},
|
||||
{"list193",{"aliquam","consectetur","elementum","felis","sed","hendrerit","massa","consectetur","sagittis","nunc"}},
|
||||
{"list194",{"in","hac","habitasse","platea","dictumst","integer","hendrerit","lorem","nec","auctor"}},
|
||||
{"list195",{"pellentesque","dictum","mattis","mattis","donec","nec","commodo","nibh","in","imperdiet"}},
|
||||
{"list196",{"mauris","eget","urna","vulputate","iaculis","tellus","pharetra","laoreet","justo","proin"}},
|
||||
{"list197",{"nam","tincidunt","tortor","eu","scelerisque","convallis","erat","magna","consectetur","enim"}},
|
||||
{"list198",{"aenean","posuere","ante","vitae","lobortis","fringilla","magna","lorem","volutpat","dui"}},
|
||||
{"list199",{"suspendisse","mattis","arcu","ut","ipsum","cursus","vestibulum","interdum","et","malesuada"}},
|
||||
{"list200",{"aenean","pharetra","leo","sem","non","pretium","nibh","faucibus","id","duis"}}
|
||||
};
|
||||
json largeData = {
|
||||
{"name", "Peter"},
|
||||
{"list001", {"lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "aliquam", "accumsan"}},
|
||||
{"list002", {"donec", "in", "egestas", "diam", "aenean", "suscipit", "scelerisque", "efficitur", "integer", "a"}},
|
||||
{"list003", {"maecenas", "metus", "erat", "vestibulum", "quis", "porta", "in", "consequat", "sed", "justo"}},
|
||||
{"list004", {"aliquam", "erat", "volutpat", "integer", "laoreet", "tellus", "ut", "nibh", "viverra", "in"}},
|
||||
{"list005", {"integer", "eu", "velit", "ac", "erat", "fringilla", "ullamcorper", "id", "in", "tortor"}},
|
||||
{"list006", {"quisque", "at", "dapibus", "ante", "donec", "et", "lectus", "sit", "amet", "lorem"}},
|
||||
{"list007",
|
||||
{"curabitur", "imperdiet", "nibh", "sit", "amet", "pellentesque", "tincidunt", "quisque", "ornare", "enim"}},
|
||||
{"list008",
|
||||
{"aliquam", "vitae", "condimentum", "libero", "non", "sodales", "metus", "vestibulum", "aliquet", "ullamcorper"}},
|
||||
{"list009", {"pellentesque", "sed", "diam", "tellus", "donec", "sed", "nulla", "lorem", "sed", "imperdiet"}},
|
||||
{"list010", {"nam", "sagittis", "maximus", "congue", "class", "aptent", "taciti", "sociosqu", "ad", "litora"}},
|
||||
{"list011",
|
||||
{"praesent", "semper", "elit", "ut", "consequat", "fringilla", "mauris", "turpis", "volutpat", "risus"}},
|
||||
{"list012", {"nullam", "risus", "urna", "facilisis", "sit", "amet", "nibh", "id", "blandit", "mollis"}},
|
||||
{"list013", {"donec", "non", "ante", "nisi", "praesent", "suscipit", "erat", "quis", "lorem", "convallis"}},
|
||||
{"list014",
|
||||
{"maecenas", "tincidunt", "suscipit", "ipsum", "non", "tristique", "proin", "accumsan", "cursus", "justo"}},
|
||||
{"list015", {"nulla", "facilisi", "nullam", "et", "enim", "finibus", "aliquet", "mi", "ut", "mattis"}},
|
||||
{"list016", {"fusce", "rutrum", "lobortis", "ligula", "vitae", "condimentum", "risus", "ultrices", "sed", "sed"}},
|
||||
{"list017", {"nullam", "quis", "tristique", "ante", "proin", "neque", "ante", "sollicitudin", "non", "bibendum"}},
|
||||
{"list018", {"nam", "bibendum", "quam", "et", "semper", "eleifend", "donec", "placerat", "scelerisque", "mi"}},
|
||||
{"list019", {"donec", "vel", "suscipit", "turpis", "cras", "semper", "arcu", "in", "velit", "hendrerit"}},
|
||||
{"list020",
|
||||
{"praesent", "congue", "gravida", "mauris", "integer", "ornare", "dictum", "lorem", "non", "consequat"}},
|
||||
{"list021", {"nam", "tincidunt", "tortor", "sit", "amet", "gravida", "dapibus", "fusce", "laoreet", "nulla"}},
|
||||
{"list022", {"in", "id", "enim", "pellentesque", "suscipit", "velit", "id", "posuere", "metus", "quisque"}},
|
||||
{"list023", {"curabitur", "elit", "ex", "aliquam", "eget", "mi", "sed", "tristique", "scelerisque", "ligula"}},
|
||||
{"list024", {"vivamus", "dui", "lacus", "hendrerit", "eu", "sagittis", "non", "finibus", "consequat", "turpis"}},
|
||||
{"list025", {"etiam", "ultrices", "vel", "massa", "non", "vehicula", "duis", "aliquet", "massa", "id"}},
|
||||
{"list026", {"duis", "ultrices", "sem", "a", "sapien", "dignissim", "hendrerit", "eu", "vel", "sem"}},
|
||||
{"list027", {"vivamus", "eu", "elit", "ac", "metus", "pharetra", "pretium", "etiam", "mattis", "velit"}},
|
||||
{"list028", {"ut", "ac", "commodo", "risus", "nam", "eget", "hendrerit", "magna", "vestibulum", "elementum"}},
|
||||
{"list029", {"mauris", "in", "ultricies", "tellus", "ut", "in", "velit", "porttitor", "vulputate", "enim"}},
|
||||
{"list030", {"donec", "dapibus", "urna", "ac", "scelerisque", "mollis", "urna", "orci", "congue", "nulla"}},
|
||||
{"list031", {"vivamus", "eleifend", "dapibus", "maximus", "donec", "eu", "accumsan", "nulla", "eu", "iaculis"}},
|
||||
{"list032", {"aliquam", "erat", "volutpat", "orci", "varius", "natoque", "penatibus", "et", "magnis", "dis"}},
|
||||
{"list033", {"maecenas", "laoreet", "sed", "quam", "eget", "bibendum", "etiam", "et", "sollicitudin", "mi"}},
|
||||
{"list034", {"aliquam", "rhoncus", "purus", "vel", "nibh", "laoreet", "pharetra", "vestibulum", "ante", "ipsum"}},
|
||||
{"list035", {"quisque", "semper", "urna", "vel", "mollis", "gravida", "fusce", "nibh", "mauris", "porttitor"}},
|
||||
{"list036", {"sed", "luctus", "risus", "et", "sodales", "mollis", "maecenas", "a", "tincidunt", "risus"}},
|
||||
{"list037", {"in", "hac", "habitasse", "platea", "dictumst", "nullam", "fermentum", "commodo", "tempor", "aenean"}},
|
||||
{"list038", {"nunc", "rhoncus", "diam", "magna", "ac", "lacinia", "felis", "consequat", "non", "maecenas"}},
|
||||
{"list039", {"sed", "scelerisque", "velit", "est", "sed", "mollis", "ligula", "cursus", "sed", "aliquam"}},
|
||||
{"list040", {"nulla", "dictum", "arcu", "eu", "mauris", "malesuada", "quis", "cursus", "nisi", "faucibus"}},
|
||||
{"list041",
|
||||
{"phasellus", "posuere", "lacus", "nec", "molestie", "accumsan", "metus", "tortor", "facilisis", "nunc"}},
|
||||
{"list042", {"curabitur", "ex", "neque", "pretium", "sit", "amet", "leo", "in", "tempus", "vestibulum"}},
|
||||
{"list043", {"curabitur", "tortor", "tortor", "fermentum", "eget", "velit", "ac", "cursus", "faucibus", "odio"}},
|
||||
{"list044", {"aenean", "varius", "malesuada", "sapien", "sed", "hendrerit", "purus", "molestie", "sed", "sed"}},
|
||||
{"list045", {"nam", "hendrerit", "pretium", "purus", "id", "fermentum", "nunc", "in", "lacus", "metus"}},
|
||||
{"list046", {"fusce", "euismod", "libero", "sed", "diam", "pharetra", "non", "semper", "elit", "accumsan"}},
|
||||
{"list047", {"phasellus", "sed", "ligula", "sit", "amet", "justo", "vestibulum", "fermentum", "congue", "sed"}},
|
||||
{"list048", {"sed", "dignissim", "felis", "eget", "elit", "dictum", "malesuada", "vivamus", "maximus", "mi"}},
|
||||
{"list049", {"proin", "lobortis", "tempus", "molestie", "sed", "tortor", "ipsum", "finibus", "non", "aliquet"}},
|
||||
{"list050", {"integer", "ut", "leo", "dui", "proin", "condimentum", "dolor", "a", "suscipit", "maximus"}},
|
||||
{"list051", {"vivamus", "sapien", "neque", "dapibus", "sed", "volutpat", "at", "vestibulum", "sit", "amet"}},
|
||||
{"list052", {"curabitur", "enim", "enim", "faucibus", "sit", "amet", "luctus", "aliquam", "placerat", "nec"}},
|
||||
{"list053", {"suspendisse", "ligula", "dolor", "ultricies", "sit", "amet", "iaculis", "vel", "luctus", "sit"}},
|
||||
{"list054", {"aenean", "aliquam", "elit", "sit", "amet", "ultricies", "lobortis", "nullam", "porttitor", "libero"}},
|
||||
{"list055",
|
||||
{"ut", "tincidunt", "convallis", "placerat", "suspendisse", "potenti", "cras", "commodo", "fringilla", "lacus"}},
|
||||
{"list056", {"nulla", "quis", "elit", "est", "etiam", "sagittis", "molestie", "porta", "lorem", "ipsum"}},
|
||||
{"list057", {"in", "turpis", "nibh", "gravida", "vitae", "ex", "eu", "eleifend", "tincidunt", "neque"}},
|
||||
{"list058", {"suspendisse", "in", "fermentum", "orci", "etiam", "viverra", "metus", "a", "condimentum", "blandit"}},
|
||||
{"list059", {"fusce", "dapibus", "velit", "id", "est", "maximus", "rhoncus", "quisque", "lobortis", "tortor"}},
|
||||
{"list060", {"ut", "molestie", "ornare", "velit", "id", "consectetur", "nunc", "varius", "eu", "vivamus"}},
|
||||
{"list061", {"aenean", "egestas", "nibh", "at", "tincidunt", "varius", "felis", "metus", "ullamcorper", "purus"}},
|
||||
{"list062", {"donec", "a", "eleifend", "libero", "sed", "fermentum", "sem", "fusce", "eget", "lacinia"}},
|
||||
{"list063", {"nullam", "metus", "mauris", "ornare", "in", "sem", "at", "posuere", "placerat", "nisl"}},
|
||||
{"list064", {"maecenas", "vitae", "enim", "ipsum", "sed", "mattis", "porta", "mi", "congue", "suscipit"}},
|
||||
{"list065", {"nulla", "placerat", "porttitor", "metus", "non", "suscipit", "turpis", "rhoncus", "non", "etiam"}},
|
||||
{"list066", {"morbi", "id", "fringilla", "quam", "eget", "sollicitudin", "felis", "aliquam", "quis", "risus"}},
|
||||
{"list067",
|
||||
{"pellentesque", "maximus", "leo", "ut", "quam", "consequat", "lacinia", "suspendisse", "facilisis", "leo"}},
|
||||
{"list068", {"phasellus", "rhoncus", "urna", "felis", "nullam", "pharetra", "porttitor", "neque", "sit", "amet"}},
|
||||
{"list069", {"in", "posuere", "mauris", "sit", "amet", "nisl", "tempor", "eget", "euismod", "neque"}},
|
||||
{"list070",
|
||||
{"mauris", "id", "lobortis", "magna", "suspendisse", "nisl", "orci", "auctor", "suscipit", "malesuada"}},
|
||||
{"list071", {"ut", "facilisis", "magna", "vitae", "ligula", "laoreet", "tempor", "class", "aptent", "taciti"}},
|
||||
{"list072", {"aenean", "sagittis", "lacus", "vel", "nulla", "porta", "quis", "egestas", "sem", "ullamcorper"}},
|
||||
{"list073", {"donec", "eget", "purus", "scelerisque", "rutrum", "dolor", "eget", "maximus", "dui", "aliquam"}},
|
||||
{"list074", {"donec", "congue", "a", "massa", "vel", "posuere", "donec", "ullamcorper", "elit", "id"}},
|
||||
{"list075", {"praesent", "consectetur", "est", "eu", "tellus", "dictum", "tempor", "nullam", "id", "risus"}},
|
||||
{"list076", {"etiam", "gravida", "gravida", "tempus", "fusce", "lobortis", "orci", "ac", "volutpat", "mollis"}},
|
||||
{"list077", {"quisque", "quis", "turpis", "et", "augue", "dignissim", "maximus", "donec", "vel", "justo"}},
|
||||
{"list078", {"aenean", "consectetur", "mi", "non", "nibh", "bibendum", "ac", "tincidunt", "dui", "tristique"}},
|
||||
{"list079", {"aliquam", "tempus", "elit", "non", "ipsum", "finibus", "ut", "luctus", "dolor", "tincidunt"}},
|
||||
{"list080", {"donec", "eget", "ultricies", "tellus", "et", "imperdiet", "tellus", "vivamus", "maximus", "massa"}},
|
||||
{"list081",
|
||||
{"pellentesque", "eget", "volutpat", "velit", "eu", "venenatis", "mi", "suspendisse", "fringilla", "dignissim"}},
|
||||
{"list082", {"maecenas", "auctor", "leo", "sed", "sapien", "vehicula", "nec", "porttitor", "ante", "porta"}},
|
||||
{"list083", {"nulla", "risus", "lectus", "interdum", "rutrum", "aliquam", "sed", "consectetur", "id", "risus"}},
|
||||
{"list084", {"vestibulum", "ante", "ipsum", "primis", "in", "faucibus", "orci", "luctus", "et", "ultrices"}},
|
||||
{"list085", {"vivamus", "vestibulum", "leo", "vitae", "lorem", "tincidunt", "nec", "gravida", "neque", "vehicula"}},
|
||||
{"list086", {"donec", "mollis", "urna", "lectus", "praesent", "ornare", "arcu", "convallis", "lacus", "tempus"}},
|
||||
{"list087", {"nam", "laoreet", "nibh", "vel", "pretium", "vestibulum", "cras", "finibus", "eget", "eros"}},
|
||||
{"list088", {"integer", "pulvinar", "nunc", "nec", "orci", "accumsan", "venenatis", "maecenas", "quam", "est"}},
|
||||
{"list089", {"ut", "aliquet", "risus", "vel", "dapibus", "tristique", "fusce", "rutrum", "risus", "cursus"}},
|
||||
{"list090",
|
||||
{"suspendisse", "ac", "ullamcorper", "justo", "morbi", "vel", "dolor", "condimentum", "viverra", "ligula"}},
|
||||
{"list091", {"phasellus", "vestibulum", "elit", "et", "dictum", "rutrum", "velit", "odio", "mattis", "odio"}},
|
||||
{"list092", {"curabitur", "nunc", "diam", "pellentesque", "sed", "ultrices", "et", "varius", "non", "lacus"}},
|
||||
{"list093",
|
||||
{"aliquam", "consectetur", "elementum", "felis", "sed", "hendrerit", "massa", "consectetur", "sagittis", "nunc"}},
|
||||
{"list094", {"in", "hac", "habitasse", "platea", "dictumst", "integer", "hendrerit", "lorem", "nec", "auctor"}},
|
||||
{"list095", {"pellentesque", "dictum", "mattis", "mattis", "donec", "nec", "commodo", "nibh", "in", "imperdiet"}},
|
||||
{"list096", {"mauris", "eget", "urna", "vulputate", "iaculis", "tellus", "pharetra", "laoreet", "justo", "proin"}},
|
||||
{"list097",
|
||||
{"nam", "tincidunt", "tortor", "eu", "scelerisque", "convallis", "erat", "magna", "consectetur", "enim"}},
|
||||
{"list098", {"aenean", "posuere", "ante", "vitae", "lobortis", "fringilla", "magna", "lorem", "volutpat", "dui"}},
|
||||
{"list099",
|
||||
{"suspendisse", "mattis", "arcu", "ut", "ipsum", "cursus", "vestibulum", "interdum", "et", "malesuada"}},
|
||||
{"list100", {"aenean", "pharetra", "leo", "sem", "non", "pretium", "nibh", "faucibus", "id", "duis"}},
|
||||
{"list101", {"lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "aliquam", "accumsan"}},
|
||||
{"list102", {"donec", "in", "egestas", "diam", "aenean", "suscipit", "scelerisque", "efficitur", "integer", "a"}},
|
||||
{"list103", {"maecenas", "metus", "erat", "vestibulum", "quis", "porta", "in", "consequat", "sed", "justo"}},
|
||||
{"list104", {"aliquam", "erat", "volutpat", "integer", "laoreet", "tellus", "ut", "nibh", "viverra", "in"}},
|
||||
{"list105", {"integer", "eu", "velit", "ac", "erat", "fringilla", "ullamcorper", "id", "in", "tortor"}},
|
||||
{"list106", {"quisque", "at", "dapibus", "ante", "donec", "et", "lectus", "sit", "amet", "lorem"}},
|
||||
{"list107",
|
||||
{"curabitur", "imperdiet", "nibh", "sit", "amet", "pellentesque", "tincidunt", "quisque", "ornare", "enim"}},
|
||||
{"list108",
|
||||
{"aliquam", "vitae", "condimentum", "libero", "non", "sodales", "metus", "vestibulum", "aliquet", "ullamcorper"}},
|
||||
{"list109", {"pellentesque", "sed", "diam", "tellus", "donec", "sed", "nulla", "lorem", "sed", "imperdiet"}},
|
||||
{"list110", {"nam", "sagittis", "maximus", "congue", "class", "aptent", "taciti", "sociosqu", "ad", "litora"}},
|
||||
{"list111",
|
||||
{"praesent", "semper", "elit", "ut", "consequat", "fringilla", "mauris", "turpis", "volutpat", "risus"}},
|
||||
{"list112", {"nullam", "risus", "urna", "facilisis", "sit", "amet", "nibh", "id", "blandit", "mollis"}},
|
||||
{"list113", {"donec", "non", "ante", "nisi", "praesent", "suscipit", "erat", "quis", "lorem", "convallis"}},
|
||||
{"list114",
|
||||
{"maecenas", "tincidunt", "suscipit", "ipsum", "non", "tristique", "proin", "accumsan", "cursus", "justo"}},
|
||||
{"list115", {"nulla", "facilisi", "nullam", "et", "enim", "finibus", "aliquet", "mi", "ut", "mattis"}},
|
||||
{"list116", {"fusce", "rutrum", "lobortis", "ligula", "vitae", "condimentum", "risus", "ultrices", "sed", "sed"}},
|
||||
{"list117", {"nullam", "quis", "tristique", "ante", "proin", "neque", "ante", "sollicitudin", "non", "bibendum"}},
|
||||
{"list118", {"nam", "bibendum", "quam", "et", "semper", "eleifend", "donec", "placerat", "scelerisque", "mi"}},
|
||||
{"list119", {"donec", "vel", "suscipit", "turpis", "cras", "semper", "arcu", "in", "velit", "hendrerit"}},
|
||||
{"list120",
|
||||
{"praesent", "congue", "gravida", "mauris", "integer", "ornare", "dictum", "lorem", "non", "consequat"}},
|
||||
{"list121", {"nam", "tincidunt", "tortor", "sit", "amet", "gravida", "dapibus", "fusce", "laoreet", "nulla"}},
|
||||
{"list122", {"in", "id", "enim", "pellentesque", "suscipit", "velit", "id", "posuere", "metus", "quisque"}},
|
||||
{"list123", {"curabitur", "elit", "ex", "aliquam", "eget", "mi", "sed", "tristique", "scelerisque", "ligula"}},
|
||||
{"list124", {"vivamus", "dui", "lacus", "hendrerit", "eu", "sagittis", "non", "finibus", "consequat", "turpis"}},
|
||||
{"list125", {"etiam", "ultrices", "vel", "massa", "non", "vehicula", "duis", "aliquet", "massa", "id"}},
|
||||
{"list126", {"duis", "ultrices", "sem", "a", "sapien", "dignissim", "hendrerit", "eu", "vel", "sem"}},
|
||||
{"list127", {"vivamus", "eu", "elit", "ac", "metus", "pharetra", "pretium", "etiam", "mattis", "velit"}},
|
||||
{"list128", {"ut", "ac", "commodo", "risus", "nam", "eget", "hendrerit", "magna", "vestibulum", "elementum"}},
|
||||
{"list129", {"mauris", "in", "ultricies", "tellus", "ut", "in", "velit", "porttitor", "vulputate", "enim"}},
|
||||
{"list130", {"donec", "dapibus", "urna", "ac", "scelerisque", "mollis", "urna", "orci", "congue", "nulla"}},
|
||||
{"list131", {"vivamus", "eleifend", "dapibus", "maximus", "donec", "eu", "accumsan", "nulla", "eu", "iaculis"}},
|
||||
{"list132", {"aliquam", "erat", "volutpat", "orci", "varius", "natoque", "penatibus", "et", "magnis", "dis"}},
|
||||
{"list133", {"maecenas", "laoreet", "sed", "quam", "eget", "bibendum", "etiam", "et", "sollicitudin", "mi"}},
|
||||
{"list134", {"aliquam", "rhoncus", "purus", "vel", "nibh", "laoreet", "pharetra", "vestibulum", "ante", "ipsum"}},
|
||||
{"list135", {"quisque", "semper", "urna", "vel", "mollis", "gravida", "fusce", "nibh", "mauris", "porttitor"}},
|
||||
{"list136", {"sed", "luctus", "risus", "et", "sodales", "mollis", "maecenas", "a", "tincidunt", "risus"}},
|
||||
{"list137", {"in", "hac", "habitasse", "platea", "dictumst", "nullam", "fermentum", "commodo", "tempor", "aenean"}},
|
||||
{"list138", {"nunc", "rhoncus", "diam", "magna", "ac", "lacinia", "felis", "consequat", "non", "maecenas"}},
|
||||
{"list139", {"sed", "scelerisque", "velit", "est", "sed", "mollis", "ligula", "cursus", "sed", "aliquam"}},
|
||||
{"list140", {"nulla", "dictum", "arcu", "eu", "mauris", "malesuada", "quis", "cursus", "nisi", "faucibus"}},
|
||||
{"list141",
|
||||
{"phasellus", "posuere", "lacus", "nec", "molestie", "accumsan", "metus", "tortor", "facilisis", "nunc"}},
|
||||
{"list142", {"curabitur", "ex", "neque", "pretium", "sit", "amet", "leo", "in", "tempus", "vestibulum"}},
|
||||
{"list143", {"curabitur", "tortor", "tortor", "fermentum", "eget", "velit", "ac", "cursus", "faucibus", "odio"}},
|
||||
{"list144", {"aenean", "varius", "malesuada", "sapien", "sed", "hendrerit", "purus", "molestie", "sed", "sed"}},
|
||||
{"list145", {"nam", "hendrerit", "pretium", "purus", "id", "fermentum", "nunc", "in", "lacus", "metus"}},
|
||||
{"list146", {"fusce", "euismod", "libero", "sed", "diam", "pharetra", "non", "semper", "elit", "accumsan"}},
|
||||
{"list147", {"phasellus", "sed", "ligula", "sit", "amet", "justo", "vestibulum", "fermentum", "congue", "sed"}},
|
||||
{"list148", {"sed", "dignissim", "felis", "eget", "elit", "dictum", "malesuada", "vivamus", "maximus", "mi"}},
|
||||
{"list149", {"proin", "lobortis", "tempus", "molestie", "sed", "tortor", "ipsum", "finibus", "non", "aliquet"}},
|
||||
{"list150", {"integer", "ut", "leo", "dui", "proin", "condimentum", "dolor", "a", "suscipit", "maximus"}},
|
||||
{"list151", {"vivamus", "sapien", "neque", "dapibus", "sed", "volutpat", "at", "vestibulum", "sit", "amet"}},
|
||||
{"list152", {"curabitur", "enim", "enim", "faucibus", "sit", "amet", "luctus", "aliquam", "placerat", "nec"}},
|
||||
{"list153", {"suspendisse", "ligula", "dolor", "ultricies", "sit", "amet", "iaculis", "vel", "luctus", "sit"}},
|
||||
{"list154", {"aenean", "aliquam", "elit", "sit", "amet", "ultricies", "lobortis", "nullam", "porttitor", "libero"}},
|
||||
{"list155",
|
||||
{"ut", "tincidunt", "convallis", "placerat", "suspendisse", "potenti", "cras", "commodo", "fringilla", "lacus"}},
|
||||
{"list156", {"nulla", "quis", "elit", "est", "etiam", "sagittis", "molestie", "porta", "lorem", "ipsum"}},
|
||||
{"list157", {"in", "turpis", "nibh", "gravida", "vitae", "ex", "eu", "eleifend", "tincidunt", "neque"}},
|
||||
{"list158", {"suspendisse", "in", "fermentum", "orci", "etiam", "viverra", "metus", "a", "condimentum", "blandit"}},
|
||||
{"list159", {"fusce", "dapibus", "velit", "id", "est", "maximus", "rhoncus", "quisque", "lobortis", "tortor"}},
|
||||
{"list160", {"ut", "molestie", "ornare", "velit", "id", "consectetur", "nunc", "varius", "eu", "vivamus"}},
|
||||
{"list161", {"aenean", "egestas", "nibh", "at", "tincidunt", "varius", "felis", "metus", "ullamcorper", "purus"}},
|
||||
{"list162", {"donec", "a", "eleifend", "libero", "sed", "fermentum", "sem", "fusce", "eget", "lacinia"}},
|
||||
{"list163", {"nullam", "metus", "mauris", "ornare", "in", "sem", "at", "posuere", "placerat", "nisl"}},
|
||||
{"list164", {"maecenas", "vitae", "enim", "ipsum", "sed", "mattis", "porta", "mi", "congue", "suscipit"}},
|
||||
{"list165", {"nulla", "placerat", "porttitor", "metus", "non", "suscipit", "turpis", "rhoncus", "non", "etiam"}},
|
||||
{"list166", {"morbi", "id", "fringilla", "quam", "eget", "sollicitudin", "felis", "aliquam", "quis", "risus"}},
|
||||
{"list167",
|
||||
{"pellentesque", "maximus", "leo", "ut", "quam", "consequat", "lacinia", "suspendisse", "facilisis", "leo"}},
|
||||
{"list168", {"phasellus", "rhoncus", "urna", "felis", "nullam", "pharetra", "porttitor", "neque", "sit", "amet"}},
|
||||
{"list169", {"in", "posuere", "mauris", "sit", "amet", "nisl", "tempor", "eget", "euismod", "neque"}},
|
||||
{"list170",
|
||||
{"mauris", "id", "lobortis", "magna", "suspendisse", "nisl", "orci", "auctor", "suscipit", "malesuada"}},
|
||||
{"list171", {"ut", "facilisis", "magna", "vitae", "ligula", "laoreet", "tempor", "class", "aptent", "taciti"}},
|
||||
{"list172", {"aenean", "sagittis", "lacus", "vel", "nulla", "porta", "quis", "egestas", "sem", "ullamcorper"}},
|
||||
{"list173", {"donec", "eget", "purus", "scelerisque", "rutrum", "dolor", "eget", "maximus", "dui", "aliquam"}},
|
||||
{"list174", {"donec", "congue", "a", "massa", "vel", "posuere", "donec", "ullamcorper", "elit", "id"}},
|
||||
{"list175", {"praesent", "consectetur", "est", "eu", "tellus", "dictum", "tempor", "nullam", "id", "risus"}},
|
||||
{"list176", {"etiam", "gravida", "gravida", "tempus", "fusce", "lobortis", "orci", "ac", "volutpat", "mollis"}},
|
||||
{"list177", {"quisque", "quis", "turpis", "et", "augue", "dignissim", "maximus", "donec", "vel", "justo"}},
|
||||
{"list178", {"aenean", "consectetur", "mi", "non", "nibh", "bibendum", "ac", "tincidunt", "dui", "tristique"}},
|
||||
{"list179", {"aliquam", "tempus", "elit", "non", "ipsum", "finibus", "ut", "luctus", "dolor", "tincidunt"}},
|
||||
{"list180", {"donec", "eget", "ultricies", "tellus", "et", "imperdiet", "tellus", "vivamus", "maximus", "massa"}},
|
||||
{"list181",
|
||||
{"pellentesque", "eget", "volutpat", "velit", "eu", "venenatis", "mi", "suspendisse", "fringilla", "dignissim"}},
|
||||
{"list182", {"maecenas", "auctor", "leo", "sed", "sapien", "vehicula", "nec", "porttitor", "ante", "porta"}},
|
||||
{"list183", {"nulla", "risus", "lectus", "interdum", "rutrum", "aliquam", "sed", "consectetur", "id", "risus"}},
|
||||
{"list184", {"vestibulum", "ante", "ipsum", "primis", "in", "faucibus", "orci", "luctus", "et", "ultrices"}},
|
||||
{"list185", {"vivamus", "vestibulum", "leo", "vitae", "lorem", "tincidunt", "nec", "gravida", "neque", "vehicula"}},
|
||||
{"list186", {"donec", "mollis", "urna", "lectus", "praesent", "ornare", "arcu", "convallis", "lacus", "tempus"}},
|
||||
{"list187", {"nam", "laoreet", "nibh", "vel", "pretium", "vestibulum", "cras", "finibus", "eget", "eros"}},
|
||||
{"list188", {"integer", "pulvinar", "nunc", "nec", "orci", "accumsan", "venenatis", "maecenas", "quam", "est"}},
|
||||
{"list189", {"ut", "aliquet", "risus", "vel", "dapibus", "tristique", "fusce", "rutrum", "risus", "cursus"}},
|
||||
{"list190",
|
||||
{"suspendisse", "ac", "ullamcorper", "justo", "morbi", "vel", "dolor", "condimentum", "viverra", "ligula"}},
|
||||
{"list191", {"phasellus", "vestibulum", "elit", "et", "dictum", "rutrum", "velit", "odio", "mattis", "odio"}},
|
||||
{"list192", {"curabitur", "nunc", "diam", "pellentesque", "sed", "ultrices", "et", "varius", "non", "lacus"}},
|
||||
{"list193",
|
||||
{"aliquam", "consectetur", "elementum", "felis", "sed", "hendrerit", "massa", "consectetur", "sagittis", "nunc"}},
|
||||
{"list194", {"in", "hac", "habitasse", "platea", "dictumst", "integer", "hendrerit", "lorem", "nec", "auctor"}},
|
||||
{"list195", {"pellentesque", "dictum", "mattis", "mattis", "donec", "nec", "commodo", "nibh", "in", "imperdiet"}},
|
||||
{"list196", {"mauris", "eget", "urna", "vulputate", "iaculis", "tellus", "pharetra", "laoreet", "justo", "proin"}},
|
||||
{"list197",
|
||||
{"nam", "tincidunt", "tortor", "eu", "scelerisque", "convallis", "erat", "magna", "consectetur", "enim"}},
|
||||
{"list198", {"aenean", "posuere", "ante", "vitae", "lobortis", "fringilla", "magna", "lorem", "volutpat", "dui"}},
|
||||
{"list199",
|
||||
{"suspendisse", "mattis", "arcu", "ut", "ipsum", "cursus", "vestibulum", "interdum", "et", "malesuada"}},
|
||||
{"list200", {"aenean", "pharetra", "leo", "sem", "non", "pretium", "nibh", "faucibus", "id", "duis"}}};
|
||||
|
||||
std::string string_template{"Lorem {{ name }}! {% for v1 in list001 %}{{ v1 }} {% for v2 in list002 %}{{ v2 }} {% for v3 in list003 %}{{ v1 }} {{ v3 }} {{name}}\n{% endfor %}{% endfor %}{% endfor %}Omnis in aut nobis libero enim. Porro optio ratione molestiae necessitatibus numquam architecto soluta. Magnam minus unde quas {{ name }} aspernatur occaecati et voluptas cupiditate. Assumenda ut alias quam voluptate aut saepe ullam dignissimos. \n Sequi aut autem nihil voluptatem tenetur incidunt. Autem commodi animi rerum. {{ lower(name) }} Mollitia eligendi aut sed rerum veniam. Eum et fugit velit sint ratione voluptatem aliquam. Minima sint consectetur natus modi quis. Animi est nesciunt cupiditate nostrum iure. Voluptatem accusamus vel corporis. \n Debitis {{ name }} sunt est debitis distinctio ut. Provident corrupti nihil velit aut tempora corporis corrupti exercitationem. Praesentium cumque ex est itaque."};
|
||||
std::string string_template {
|
||||
"Lorem {{ name }}! {% for v1 in list001 %}{{ v1 }} {% for v2 in list002 %}{{ v2 }} {% for v3 in list003 %}{{ v1 }} "
|
||||
"{{ v3 }} {{name}}\n{% endfor %}{% endfor %}{% endfor %}Omnis in aut nobis libero enim. Porro optio ratione "
|
||||
"molestiae necessitatibus numquam architecto soluta. Magnam minus unde quas {{ name }} aspernatur occaecati et "
|
||||
"voluptas cupiditate. Assumenda ut alias quam voluptate aut saepe ullam dignissimos. \n Sequi aut autem nihil "
|
||||
"voluptatem tenetur incidunt. Autem commodi animi rerum. {{ lower(name) }} Mollitia eligendi aut sed rerum veniam. "
|
||||
"Eum et fugit velit sint ratione voluptatem aliquam. Minima sint consectetur natus modi quis. Animi est nesciunt "
|
||||
"cupiditate nostrum iure. Voluptatem accusamus vel corporis. \n Debitis {{ name }} sunt est debitis distinctio ut. "
|
||||
"Provident corrupti nihil velit aut tempora corporis corrupti exercitationem. Praesentium cumque ex est itaque."};
|
||||
|
||||
BENCHMARK(InjaBenchmarkerSmallData, render, 10, 100) { env.render(string_template, smallData); }
|
||||
|
||||
BENCHMARK(InjaBenchmarkerSmallData, render, 10, 100) {
|
||||
env.render(string_template, smallData);
|
||||
}
|
||||
|
||||
BENCHMARK(InjaBenchmarkerLargeData, render, 10, 100) {
|
||||
env.render(string_template, largeData);
|
||||
}
|
||||
BENCHMARK(InjaBenchmarkerLargeData, render, 10, 100) { env.render(string_template, largeData); }
|
||||
|
||||
int main() {
|
||||
hayai::ConsoleOutputter consoleOutputter;
|
||||
|
||||
+44
-45
@@ -3,74 +3,73 @@
|
||||
#include "doctest/doctest.h"
|
||||
#include "inja/inja.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
const std::string test_file_directory {"../test/data/"};
|
||||
|
||||
TEST_CASE("loading") {
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SUBCASE("Files should be loaded") {
|
||||
CHECK(env.load_file(test_file_directory + "simple.txt") == "Hello {{ name }}.");
|
||||
}
|
||||
SUBCASE("Files should be loaded") { CHECK(env.load_file(test_file_directory + "simple.txt") == "Hello {{ name }}."); }
|
||||
|
||||
SUBCASE("Files should be rendered") {
|
||||
CHECK(env.render_file(test_file_directory + "simple.txt", data) == "Hello Jeff.");
|
||||
}
|
||||
SUBCASE("Files should be rendered") {
|
||||
CHECK(env.render_file(test_file_directory + "simple.txt", data) == "Hello Jeff.");
|
||||
}
|
||||
|
||||
SUBCASE("File includes should be rendered") {
|
||||
CHECK(env.render_file(test_file_directory + "include.txt", data) == "Answer: Hello Jeff.");
|
||||
}
|
||||
SUBCASE("File includes should be rendered") {
|
||||
CHECK(env.render_file(test_file_directory + "include.txt", data) == "Answer: Hello Jeff.");
|
||||
}
|
||||
|
||||
SUBCASE("File error should throw") {
|
||||
std::string path(test_file_directory + "does-not-exist");
|
||||
SUBCASE("File error should throw") {
|
||||
std::string path(test_file_directory + "does-not-exist");
|
||||
|
||||
std::string file_error_message = "[inja.exception.file_error] failed accessing file at '" + path + "'";
|
||||
CHECK_THROWS_WITH(env.load_file(path), file_error_message.c_str());
|
||||
CHECK_THROWS_WITH(env.load_json(path), file_error_message.c_str());
|
||||
}
|
||||
std::string file_error_message = "[inja.exception.file_error] failed accessing file at '" + path + "'";
|
||||
CHECK_THROWS_WITH(env.load_file(path), file_error_message.c_str());
|
||||
CHECK_THROWS_WITH(env.load_json(path), file_error_message.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("complete-files") {
|
||||
inja::Environment env {test_file_directory};
|
||||
inja::Environment env {test_file_directory};
|
||||
|
||||
for (std::string test_name : {"simple-file", "nested", "nested-line", "html"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
for (std::string test_name : {"simple-file", "nested", "nested-line", "html"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") ==
|
||||
env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
for (std::string test_name : {"error-unknown"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK_THROWS_WITH(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json"), "[inja.exception.parser_error] (at 2:11) expected 'in', got 'ins'");
|
||||
}
|
||||
for (std::string test_name : {"error-unknown"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK_THROWS_WITH(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json"),
|
||||
"[inja.exception.parser_error] (at 2:11) expected 'in', got 'ins'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("complete-files-whitespace-control") {
|
||||
inja::Environment env {test_file_directory};
|
||||
env.set_trim_blocks(true);
|
||||
env.set_lstrip_blocks(true);
|
||||
|
||||
for (std::string test_name : {"nested-whitespace"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
inja::Environment env {test_file_directory};
|
||||
env.set_trim_blocks(true);
|
||||
env.set_lstrip_blocks(true);
|
||||
|
||||
for (std::string test_name : {"nested-whitespace"}) {
|
||||
SUBCASE(test_name.c_str()) {
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") ==
|
||||
env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("global-path") {
|
||||
inja::Environment env {test_file_directory, "./"};
|
||||
inja::Environment env_result {"./"};
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
inja::Environment env {test_file_directory, "./"};
|
||||
inja::Environment env_result {"./"};
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SUBCASE("Files should be written") {
|
||||
env.write("simple.txt", data, "global-path-result.txt");
|
||||
CHECK(env_result.load_file("global-path-result.txt") == "Hello Jeff.");
|
||||
}
|
||||
SUBCASE("Files should be written") {
|
||||
env.write("simple.txt", data, "global-path-result.txt");
|
||||
CHECK(env_result.load_file("global-path-result.txt") == "Hello Jeff.");
|
||||
}
|
||||
}
|
||||
|
||||
+360
-335
@@ -3,78 +3,85 @@
|
||||
#include "doctest/doctest.h"
|
||||
#include "inja/inja.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
TEST_CASE("dot-to-pointer") {
|
||||
std::string buffer;
|
||||
CHECK(inja::convert_dot_to_json_pointer("test", buffer) == "/test");
|
||||
CHECK(inja::convert_dot_to_json_pointer("guests.2", buffer) == "/guests/2");
|
||||
CHECK(inja::convert_dot_to_json_pointer("person.names.surname", buffer) == "/person/names/surname");
|
||||
std::string buffer;
|
||||
CHECK(inja::convert_dot_to_json_pointer("test", buffer) == "/test");
|
||||
CHECK(inja::convert_dot_to_json_pointer("guests.2", buffer) == "/guests/2");
|
||||
CHECK(inja::convert_dot_to_json_pointer("person.names.surname", buffer) == "/person/names/surname");
|
||||
}
|
||||
|
||||
TEST_CASE("types") {
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = { { "name", "Maria" } };
|
||||
data["is_happy"] = true;
|
||||
data["is_sad"] = false;
|
||||
data["relatives"]["mother"] = "Maria";
|
||||
data["relatives"]["brother"] = "Chris";
|
||||
data["relatives"]["sister"] = "Jenny";
|
||||
data["vars"] = {2, 3, 4, 0, -1, -2, -3};
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = {{"name", "Maria"}};
|
||||
data["is_happy"] = true;
|
||||
data["is_sad"] = false;
|
||||
data["relatives"]["mother"] = "Maria";
|
||||
data["relatives"]["brother"] = "Chris";
|
||||
data["relatives"]["sister"] = "Jenny";
|
||||
data["vars"] = {2, 3, 4, 0, -1, -2, -3};
|
||||
|
||||
SUBCASE("basic") {
|
||||
CHECK(env.render("", data) == "");
|
||||
CHECK(env.render("Hello World!", data) == "Hello World!");
|
||||
}
|
||||
|
||||
SUBCASE("basic") {
|
||||
CHECK(env.render("", data) == "");
|
||||
CHECK(env.render("Hello World!", data) == "Hello World!");
|
||||
}
|
||||
SUBCASE("variables") {
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello Peter!");
|
||||
CHECK(env.render("{{ name }}", data) == "Peter");
|
||||
CHECK(env.render("{{name}}", data) == "Peter");
|
||||
CHECK(env.render("{{ name }} is {{ age }} years old.", data) == "Peter is 29 years old.");
|
||||
CHECK(env.render("Hello {{ name }}! I come from {{ city }}.", data) == "Hello Peter! I come from Brunswick.");
|
||||
CHECK(env.render("Hello {{ names.1 }}!", data) == "Hello Seb!");
|
||||
CHECK(env.render("Hello {{ brother.name }}!", data) == "Hello Chris!");
|
||||
CHECK(env.render("Hello {{ brother.daughter0.name }}!", data) == "Hello Maria!");
|
||||
CHECK(env.render("{{ \"{{ no_value }}\" }}", data) == "{{ no_value }}");
|
||||
|
||||
SUBCASE("variables") {
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello Peter!");
|
||||
CHECK(env.render("{{ name }}", data) == "Peter");
|
||||
CHECK(env.render("{{name}}", data) == "Peter");
|
||||
CHECK(env.render("{{ name }} is {{ age }} years old.", data) == "Peter is 29 years old.");
|
||||
CHECK(env.render("Hello {{ name }}! I come from {{ city }}.", data) == "Hello Peter! I come from Brunswick.");
|
||||
CHECK(env.render("Hello {{ names.1 }}!", data) == "Hello Seb!");
|
||||
CHECK(env.render("Hello {{ brother.name }}!", data) == "Hello Chris!");
|
||||
CHECK(env.render("Hello {{ brother.daughter0.name }}!", data) == "Hello Maria!");
|
||||
CHECK(env.render("{{ \"{{ no_value }}\" }}", data) == "{{ no_value }}");
|
||||
CHECK_THROWS_WITH(env.render("{{unknown}}", data), "[inja.exception.render_error] variable 'unknown' not found");
|
||||
}
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{{unknown}}", data), "[inja.exception.render_error] variable 'unknown' not found");
|
||||
}
|
||||
SUBCASE("comments") {
|
||||
CHECK(env.render("Hello{# This is a comment #}!", data) == "Hello!");
|
||||
CHECK(env.render("{# --- #Todo --- #}", data) == "");
|
||||
}
|
||||
|
||||
SUBCASE("comments") {
|
||||
CHECK(env.render("Hello{# This is a comment #}!", data) == "Hello!");
|
||||
CHECK(env.render("{# --- #Todo --- #}", data) == "");
|
||||
}
|
||||
SUBCASE("loops") {
|
||||
CHECK(env.render("{% for name in names %}a{% endfor %}", data) == "aa");
|
||||
CHECK(env.render("Hello {% for name in names %}{{ name }} {% endfor %}!", data) == "Hello Jeff Seb !");
|
||||
CHECK(env.render("Hello {% for name in names %}{{ loop.index }}: {{ name }}, {% endfor %}!", data) ==
|
||||
"Hello 0: Jeff, 1: Seb, !");
|
||||
CHECK(env.render("{% for type, name in relatives %}{{ loop.index1 }}: {{ type }}: {{ name }}{% if loop.is_last == "
|
||||
"false %}, {% endif %}{% endfor %}",
|
||||
data) == "1: brother: Chris, 2: mother: Maria, 3: sister: Jenny");
|
||||
CHECK(env.render("{% for v in vars %}{% if v > 0 %}+{% endif %}{% endfor %}", data) == "+++");
|
||||
CHECK(env.render(
|
||||
"{% for name in names %}{{ loop.index }}: {{ name }}{% if not loop.is_last %}, {% endif %}{% endfor %}!",
|
||||
data) == "0: Jeff, 1: Seb!");
|
||||
CHECK(env.render("{% for name in names %}{{ loop.index }}: {{ name }}{% if loop.is_last == false %}, {% endif %}{% "
|
||||
"endfor %}!",
|
||||
data) == "0: Jeff, 1: Seb!");
|
||||
|
||||
SUBCASE("loops") {
|
||||
CHECK(env.render("{% for name in names %}a{% endfor %}", data) == "aa");
|
||||
CHECK(env.render("Hello {% for name in names %}{{ name }} {% endfor %}!", data) == "Hello Jeff Seb !");
|
||||
CHECK(env.render("Hello {% for name in names %}{{ loop.index }}: {{ name }}, {% endfor %}!", data) == "Hello 0: Jeff, 1: Seb, !");
|
||||
CHECK(env.render("{% for type, name in relatives %}{{ loop.index1 }}: {{ type }}: {{ name }}{% if loop.is_last == false %}, {% endif %}{% endfor %}", data) == "1: brother: Chris, 2: mother: Maria, 3: sister: Jenny");
|
||||
CHECK(env.render("{% for v in vars %}{% if v > 0 %}+{% endif %}{% endfor %}", data) == "+++" );
|
||||
CHECK(env.render("{% for name in names %}{{ loop.index }}: {{ name }}{% if not loop.is_last %}, {% endif %}{% endfor %}!", data) == "0: Jeff, 1: Seb!");
|
||||
CHECK(env.render("{% for name in names %}{{ loop.index }}: {{ name }}{% if loop.is_last == false %}, {% endif %}{% endfor %}!", data) == "0: Jeff, 1: Seb!");
|
||||
CHECK(env.render("{% for name in {} %}a{% endfor %}", data) == "");
|
||||
|
||||
CHECK( env.render("{% for name in {} %}a{% endfor %}", data) == "");
|
||||
CHECK_THROWS_WITH(env.render("{% for name ins names %}a{% endfor %}", data),
|
||||
"[inja.exception.parser_error] (at 1:13) expected 'in', got 'ins'");
|
||||
CHECK_THROWS_WITH(env.render("{% for name in empty_loop %}a{% endfor %}", data),
|
||||
"[inja.exception.render_error] variable 'empty_loop' not found");
|
||||
// CHECK_THROWS_WITH( env.render("{% for name in relatives %}{{ name }}{% endfor %}", data),
|
||||
// "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is object" );
|
||||
}
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{% for name ins names %}a{% endfor %}", data), "[inja.exception.parser_error] (at 1:13) expected 'in', got 'ins'");
|
||||
CHECK_THROWS_WITH(env.render("{% for name in empty_loop %}a{% endfor %}", data), "[inja.exception.render_error] variable 'empty_loop' not found");
|
||||
// CHECK_THROWS_WITH( env.render("{% for name in relatives %}{{ name }}{% endfor %}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is object" );
|
||||
}
|
||||
|
||||
SUBCASE("nested loops") {
|
||||
auto ldata = json::parse(
|
||||
R"DELIM(
|
||||
SUBCASE("nested loops") {
|
||||
auto ldata = json::parse(
|
||||
R"DELIM(
|
||||
{ "outer" : [
|
||||
{ "inner" : [
|
||||
{ "in2" : [ 1, 2 ] },
|
||||
@@ -90,364 +97,382 @@ R"DELIM(
|
||||
}
|
||||
]
|
||||
}
|
||||
)DELIM"
|
||||
);
|
||||
CHECK(env.render(R"DELIM(
|
||||
)DELIM");
|
||||
CHECK(env.render(R"DELIM(
|
||||
{% for o in outer %}{% for i in o.inner %}{{loop.parent.index}}:{{loop.index}}::{{loop.parent.is_last}}
|
||||
{% for ii in i.in2%}{{ii}},{%endfor%}
|
||||
{%endfor%}{%endfor%}
|
||||
)DELIM",
|
||||
ldata) == "\n0:0::false\n1,2,\n0:1::false\n\n0:2::false\n\n2:0::true\n3,4,\n2:1::true\n5,6,\n\n");
|
||||
}
|
||||
ldata) == "\n0:0::false\n1,2,\n0:1::false\n\n0:2::false\n\n2:0::true\n3,4,\n2:1::true\n5,6,\n\n");
|
||||
}
|
||||
|
||||
SUBCASE("conditionals") {
|
||||
CHECK(env.render("{% if is_happy %}Yeah!{% endif %}", data) == "Yeah!");
|
||||
CHECK(env.render("{% if is_sad %}Yeah!{% endif %}", data) == "");
|
||||
CHECK(env.render("{% if is_sad %}Yeah!{% else %}Nooo...{% endif %}", data) == "Nooo...");
|
||||
CHECK(env.render("{% if age == 29 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age > 29 %}Right{% else %}Wrong{% endif %}", data) == "Wrong");
|
||||
CHECK(env.render("{% if age <= 29 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age != 28 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age >= 30 %}Right{% else %}Wrong{% endif %}", data) == "Wrong");
|
||||
CHECK(env.render("{% if age in [28, 29, 30] %}True{% endif %}", data) == "True");
|
||||
CHECK(env.render("{% if age == 28 %}28{% else if age == 29 %}29{% endif %}", data) == "29");
|
||||
CHECK(env.render("{% if age == 26 %}26{% else if age == 27 %}27{% else if age == 28 %}28{% else %}29{% endif %}", data) == "29");
|
||||
CHECK(env.render("{% if age == 25 %}+{% endif %}{% if age == 29 %}+{% else %}-{% endif %}", data) == "+");
|
||||
SUBCASE("conditionals") {
|
||||
CHECK(env.render("{% if is_happy %}Yeah!{% endif %}", data) == "Yeah!");
|
||||
CHECK(env.render("{% if is_sad %}Yeah!{% endif %}", data) == "");
|
||||
CHECK(env.render("{% if is_sad %}Yeah!{% else %}Nooo...{% endif %}", data) == "Nooo...");
|
||||
CHECK(env.render("{% if age == 29 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age > 29 %}Right{% else %}Wrong{% endif %}", data) == "Wrong");
|
||||
CHECK(env.render("{% if age <= 29 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age != 28 %}Right{% else %}Wrong{% endif %}", data) == "Right");
|
||||
CHECK(env.render("{% if age >= 30 %}Right{% else %}Wrong{% endif %}", data) == "Wrong");
|
||||
CHECK(env.render("{% if age in [28, 29, 30] %}True{% endif %}", data) == "True");
|
||||
CHECK(env.render("{% if age == 28 %}28{% else if age == 29 %}29{% endif %}", data) == "29");
|
||||
CHECK(env.render("{% if age == 26 %}26{% else if age == 27 %}27{% else if age == 28 %}28{% else %}29{% endif %}",
|
||||
data) == "29");
|
||||
CHECK(env.render("{% if age == 25 %}+{% endif %}{% if age == 29 %}+{% else %}-{% endif %}", data) == "+");
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{% if is_happy %}{% if is_happy %}{% endif %}", data), "[inja.exception.parser_error] (at 1:46) unmatched if");
|
||||
CHECK_THROWS_WITH(env.render("{% if is_happy %}{% else if is_happy %}{% end if %}", data), "[inja.exception.parser_error] (at 1:43) expected statement, got 'end'");
|
||||
}
|
||||
CHECK_THROWS_WITH(env.render("{% if is_happy %}{% if is_happy %}{% endif %}", data),
|
||||
"[inja.exception.parser_error] (at 1:46) unmatched if");
|
||||
CHECK_THROWS_WITH(env.render("{% if is_happy %}{% else if is_happy %}{% end if %}", data),
|
||||
"[inja.exception.parser_error] (at 1:43) expected statement, got 'end'");
|
||||
}
|
||||
|
||||
SUBCASE("line statements") {
|
||||
CHECK(env.render(R"(## if is_happy
|
||||
SUBCASE("line statements") {
|
||||
CHECK(env.render(R"(## if is_happy
|
||||
Yeah!
|
||||
## endif)", data) == R"(Yeah!
|
||||
## endif)",
|
||||
data) == R"(Yeah!
|
||||
)");
|
||||
|
||||
CHECK(env.render(R"(## if is_happy
|
||||
CHECK(env.render(R"(## if is_happy
|
||||
## if is_happy
|
||||
Yeah!
|
||||
## endif
|
||||
## endif )", data) == R"(Yeah!
|
||||
## endif )",
|
||||
data) == R"(Yeah!
|
||||
)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("functions") {
|
||||
inja::Environment env;
|
||||
inja::Environment env;
|
||||
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "New York";
|
||||
data["names"] = {"Jeff", "Seb", "Peter", "Tom"};
|
||||
data["temperature"] = 25.6789;
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["property"] = "name";
|
||||
data["age"] = 29;
|
||||
data["i"] = 1;
|
||||
data["is_happy"] = true;
|
||||
data["is_sad"] = false;
|
||||
data["vars"] = {2, 3, 4, 0, -1, -2, -3};
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "New York";
|
||||
data["names"] = {"Jeff", "Seb", "Peter", "Tom"};
|
||||
data["temperature"] = 25.6789;
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["property"] = "name";
|
||||
data["age"] = 29;
|
||||
data["i"] = 1;
|
||||
data["is_happy"] = true;
|
||||
data["is_sad"] = false;
|
||||
data["vars"] = {2, 3, 4, 0, -1, -2, -3};
|
||||
|
||||
SUBCASE("upper") {
|
||||
CHECK(env.render("{{ upper(name) }}", data) == "PETER");
|
||||
CHECK(env.render("{{ upper( name ) }}", data) == "PETER");
|
||||
CHECK(env.render("{{ upper(city) }}", data) == "NEW YORK");
|
||||
CHECK(env.render("{{ upper(upper(name)) }}", data) == "PETER");
|
||||
// CHECK_THROWS_WITH( env.render("{{ upper(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be string, but is number" );
|
||||
// CHECK_THROWS_WITH( env.render("{{ upper(true) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be string, but is boolean" );
|
||||
}
|
||||
SUBCASE("upper") {
|
||||
CHECK(env.render("{{ upper(name) }}", data) == "PETER");
|
||||
CHECK(env.render("{{ upper( name ) }}", data) == "PETER");
|
||||
CHECK(env.render("{{ upper(city) }}", data) == "NEW YORK");
|
||||
CHECK(env.render("{{ upper(upper(name)) }}", data) == "PETER");
|
||||
// CHECK_THROWS_WITH( env.render("{{ upper(5) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be string, but is number" ); CHECK_THROWS_WITH( env.render("{{
|
||||
// upper(true) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be string, but is
|
||||
// boolean" );
|
||||
}
|
||||
|
||||
SUBCASE("lower") {
|
||||
CHECK(env.render("{{ lower(name) }}", data) == "peter");
|
||||
CHECK(env.render("{{ lower(city) }}", data) == "new york");
|
||||
// CHECK_THROWS_WITH( env.render("{{ lower(5.45) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be string, but is number" );
|
||||
}
|
||||
SUBCASE("lower") {
|
||||
CHECK(env.render("{{ lower(name) }}", data) == "peter");
|
||||
CHECK(env.render("{{ lower(city) }}", data) == "new york");
|
||||
// CHECK_THROWS_WITH( env.render("{{ lower(5.45) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be string, but is number" );
|
||||
}
|
||||
|
||||
SUBCASE("range") {
|
||||
CHECK(env.render("{{ range(2) }}", data) == "[0,1]");
|
||||
CHECK(env.render("{{ range(4) }}", data) == "[0,1,2,3]");
|
||||
// CHECK_THROWS_WITH( env.render("{{ range(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
SUBCASE("range") {
|
||||
CHECK(env.render("{{ range(2) }}", data) == "[0,1]");
|
||||
CHECK(env.render("{{ range(4) }}", data) == "[0,1,2,3]");
|
||||
// CHECK_THROWS_WITH( env.render("{{ range(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("length") {
|
||||
CHECK(env.render("{{ length(names) }}", data) == "4"); // Length of array
|
||||
CHECK(env.render("{{ length(name) }}", data) == "5"); // Length of string
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
SUBCASE("length") {
|
||||
CHECK(env.render("{{ length(names) }}", data) == "4"); // Length of array
|
||||
CHECK(env.render("{{ length(name) }}", data) == "5"); // Length of string
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SUBCASE("sort") {
|
||||
CHECK(env.render("{{ sort([3, 2, 1]) }}", data) == "[1,2,3]");
|
||||
CHECK(env.render("{{ sort([\"bob\", \"charlie\", \"alice\"]) }}", data) == "[\"alice\",\"bob\",\"charlie\"]");
|
||||
// CHECK_THROWS_WITH( env.render("{{ sort(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
SUBCASE("sort") {
|
||||
CHECK(env.render("{{ sort([3, 2, 1]) }}", data) == "[1,2,3]");
|
||||
CHECK(env.render("{{ sort([\"bob\", \"charlie\", \"alice\"]) }}", data) == "[\"alice\",\"bob\",\"charlie\"]");
|
||||
// CHECK_THROWS_WITH( env.render("{{ sort(5) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SUBCASE("at") {
|
||||
CHECK(env.render("{{ at(names, 0) }}", data) == "Jeff");
|
||||
CHECK(env.render("{{ at(names, i) }}", data) == "Seb");
|
||||
}
|
||||
SUBCASE("at") {
|
||||
CHECK(env.render("{{ at(names, 0) }}", data) == "Jeff");
|
||||
CHECK(env.render("{{ at(names, i) }}", data) == "Seb");
|
||||
}
|
||||
|
||||
SUBCASE("first") {
|
||||
CHECK(env.render("{{ first(names) }}", data) == "Jeff");
|
||||
// CHECK_THROWS_WITH( env.render("{{ first(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
SUBCASE("first") {
|
||||
CHECK(env.render("{{ first(names) }}", data) == "Jeff");
|
||||
// CHECK_THROWS_WITH( env.render("{{ first(5) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SUBCASE("last") {
|
||||
CHECK(env.render("{{ last(names) }}", data) == "Tom");
|
||||
// CHECK_THROWS_WITH( env.render("{{ last(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
SUBCASE("last") {
|
||||
CHECK(env.render("{{ last(names) }}", data) == "Tom");
|
||||
// CHECK_THROWS_WITH( env.render("{{ last(5) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
SUBCASE("round") {
|
||||
CHECK(env.render("{{ round(4, 0) }}", data) == "4.0");
|
||||
CHECK(env.render("{{ round(temperature, 2) }}", data) == "25.68");
|
||||
// CHECK_THROWS_WITH( env.render("{{ round(name, 2) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
SUBCASE("round") {
|
||||
CHECK(env.render("{{ round(4, 0) }}", data) == "4.0");
|
||||
CHECK(env.render("{{ round(temperature, 2) }}", data) == "25.68");
|
||||
// CHECK_THROWS_WITH( env.render("{{ round(name, 2) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("divisibleBy") {
|
||||
CHECK(env.render("{{ divisibleBy(50, 5) }}", data) == "true");
|
||||
CHECK(env.render("{{ divisibleBy(12, 3) }}", data) == "true");
|
||||
CHECK(env.render("{{ divisibleBy(11, 3) }}", data) == "false");
|
||||
// CHECK_THROWS_WITH( env.render("{{ divisibleBy(name, 2) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
SUBCASE("divisibleBy") {
|
||||
CHECK(env.render("{{ divisibleBy(50, 5) }}", data) == "true");
|
||||
CHECK(env.render("{{ divisibleBy(12, 3) }}", data) == "true");
|
||||
CHECK(env.render("{{ divisibleBy(11, 3) }}", data) == "false");
|
||||
// CHECK_THROWS_WITH( env.render("{{ divisibleBy(name, 2) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("odd") {
|
||||
CHECK(env.render("{{ odd(11) }}", data) == "true");
|
||||
CHECK(env.render("{{ odd(12) }}", data) == "false");
|
||||
// CHECK_THROWS_WITH( env.render("{{ odd(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
SUBCASE("odd") {
|
||||
CHECK(env.render("{{ odd(11) }}", data) == "true");
|
||||
CHECK(env.render("{{ odd(12) }}", data) == "false");
|
||||
// CHECK_THROWS_WITH( env.render("{{ odd(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("even") {
|
||||
CHECK(env.render("{{ even(11) }}", data) == "false");
|
||||
CHECK(env.render("{{ even(12) }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ even(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
SUBCASE("even") {
|
||||
CHECK(env.render("{{ even(11) }}", data) == "false");
|
||||
CHECK(env.render("{{ even(12) }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ even(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be number, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("max") {
|
||||
CHECK(env.render("{{ max([1, 2, 3]) }}", data) == "3");
|
||||
CHECK(env.render("{{ max([-5.2, 100.2, 2.4]) }}", data) == "100.2");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
SUBCASE("max") {
|
||||
CHECK(env.render("{{ max([1, 2, 3]) }}", data) == "3");
|
||||
CHECK(env.render("{{ max([-5.2, 100.2, 2.4]) }}", data) == "100.2");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("min") {
|
||||
CHECK(env.render("{{ min([1, 2, 3]) }}", data) == "1");
|
||||
CHECK(env.render("{{ min([-5.2, 100.2, 2.4]) }}", data) == "-5.2");
|
||||
// CHECK_THROWS_WITH( env.render("{{ min(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
SUBCASE("min") {
|
||||
CHECK(env.render("{{ min([1, 2, 3]) }}", data) == "1");
|
||||
CHECK(env.render("{{ min([-5.2, 100.2, 2.4]) }}", data) == "-5.2");
|
||||
// CHECK_THROWS_WITH( env.render("{{ min(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("float") {
|
||||
CHECK(env.render("{{ float(\"2.2\") == 2.2 }}", data) == "true");
|
||||
CHECK(env.render("{{ float(\"-1.25\") == -1.25 }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
SUBCASE("float") {
|
||||
CHECK(env.render("{{ float(\"2.2\") == 2.2 }}", data) == "true");
|
||||
CHECK(env.render("{{ float(\"-1.25\") == -1.25 }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("int") {
|
||||
CHECK(env.render("{{ int(\"2\") == 2 }}", data) == "true");
|
||||
CHECK(env.render("{{ int(\"-1.25\") == -1 }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
SUBCASE("int") {
|
||||
CHECK(env.render("{{ int(\"2\") == 2 }}", data) == "true");
|
||||
CHECK(env.render("{{ int(\"-1.25\") == -1 }}", data) == "true");
|
||||
// CHECK_THROWS_WITH( env.render("{{ max(name) }}", data), "[inja.exception.json_error]
|
||||
// [json.exception.type_error.302] type must be array, but is string" );
|
||||
}
|
||||
|
||||
SUBCASE("default") {
|
||||
CHECK(env.render("{{ default(11, 0) }}", data) == "11");
|
||||
CHECK(env.render("{{ default(nothing, 0) }}", data) == "0");
|
||||
CHECK(env.render("{{ default(name, \"nobody\") }}", data) == "Peter");
|
||||
CHECK(env.render("{{ default(surname, \"nobody\") }}", data) == "nobody");
|
||||
CHECK(env.render("{{ default(surname, \"{{ surname }}\") }}", data) == "{{ surname }}");
|
||||
CHECK_THROWS_WITH( env.render("{{ default(surname, lastname) }}", data), "[inja.exception.render_error] variable 'lastname' not found");
|
||||
}
|
||||
SUBCASE("default") {
|
||||
CHECK(env.render("{{ default(11, 0) }}", data) == "11");
|
||||
CHECK(env.render("{{ default(nothing, 0) }}", data) == "0");
|
||||
CHECK(env.render("{{ default(name, \"nobody\") }}", data) == "Peter");
|
||||
CHECK(env.render("{{ default(surname, \"nobody\") }}", data) == "nobody");
|
||||
CHECK(env.render("{{ default(surname, \"{{ surname }}\") }}", data) == "{{ surname }}");
|
||||
CHECK_THROWS_WITH(env.render("{{ default(surname, lastname) }}", data),
|
||||
"[inja.exception.render_error] variable 'lastname' not found");
|
||||
}
|
||||
|
||||
SUBCASE("exists") {
|
||||
CHECK(env.render("{{ exists(\"name\") }}", data) == "true");
|
||||
CHECK(env.render("{{ exists(\"zipcode\") }}", data) == "false");
|
||||
CHECK(env.render("{{ exists(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ exists(property) }}", data) == "true");
|
||||
}
|
||||
SUBCASE("exists") {
|
||||
CHECK(env.render("{{ exists(\"name\") }}", data) == "true");
|
||||
CHECK(env.render("{{ exists(\"zipcode\") }}", data) == "false");
|
||||
CHECK(env.render("{{ exists(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ exists(property) }}", data) == "true");
|
||||
}
|
||||
|
||||
SUBCASE("existsIn") {
|
||||
CHECK(env.render("{{ existsIn(brother, \"name\") }}", data) == "true");
|
||||
CHECK(env.render("{{ existsIn(brother, \"parents\") }}", data) == "false");
|
||||
CHECK(env.render("{{ existsIn(brother, property) }}", data) == "true");
|
||||
CHECK(env.render("{{ existsIn(brother, name) }}", data) == "false");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(sister, \"lastname\") }}", data), "[inja.exception.render_error] variable 'sister' not found");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(brother, sister) }}", data), "[inja.exception.render_error] variable 'sister' not found");
|
||||
}
|
||||
SUBCASE("existsIn") {
|
||||
CHECK(env.render("{{ existsIn(brother, \"name\") }}", data) == "true");
|
||||
CHECK(env.render("{{ existsIn(brother, \"parents\") }}", data) == "false");
|
||||
CHECK(env.render("{{ existsIn(brother, property) }}", data) == "true");
|
||||
CHECK(env.render("{{ existsIn(brother, name) }}", data) == "false");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(sister, \"lastname\") }}", data),
|
||||
"[inja.exception.render_error] variable 'sister' not found");
|
||||
CHECK_THROWS_WITH(env.render("{{ existsIn(brother, sister) }}", data),
|
||||
"[inja.exception.render_error] variable 'sister' not found");
|
||||
}
|
||||
|
||||
SUBCASE("isType") {
|
||||
CHECK(env.render("{{ isBoolean(is_happy) }}", data) == "true");
|
||||
CHECK(env.render("{{ isBoolean(vars) }}", data) == "false");
|
||||
CHECK(env.render("{{ isNumber(age) }}", data) == "true");
|
||||
CHECK(env.render("{{ isNumber(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ isInteger(age) }}", data) == "true");
|
||||
CHECK(env.render("{{ isInteger(is_happy) }}", data) == "false");
|
||||
CHECK(env.render("{{ isFloat(temperature) }}", data) == "true");
|
||||
CHECK(env.render("{{ isFloat(age) }}", data) == "false");
|
||||
CHECK(env.render("{{ isObject(brother) }}", data) == "true");
|
||||
CHECK(env.render("{{ isObject(vars) }}", data) == "false");
|
||||
CHECK(env.render("{{ isArray(vars) }}", data) == "true");
|
||||
CHECK(env.render("{{ isArray(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ isString(name) }}", data) == "true");
|
||||
CHECK(env.render("{{ isString(names) }}", data) == "false");
|
||||
}
|
||||
SUBCASE("isType") {
|
||||
CHECK(env.render("{{ isBoolean(is_happy) }}", data) == "true");
|
||||
CHECK(env.render("{{ isBoolean(vars) }}", data) == "false");
|
||||
CHECK(env.render("{{ isNumber(age) }}", data) == "true");
|
||||
CHECK(env.render("{{ isNumber(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ isInteger(age) }}", data) == "true");
|
||||
CHECK(env.render("{{ isInteger(is_happy) }}", data) == "false");
|
||||
CHECK(env.render("{{ isFloat(temperature) }}", data) == "true");
|
||||
CHECK(env.render("{{ isFloat(age) }}", data) == "false");
|
||||
CHECK(env.render("{{ isObject(brother) }}", data) == "true");
|
||||
CHECK(env.render("{{ isObject(vars) }}", data) == "false");
|
||||
CHECK(env.render("{{ isArray(vars) }}", data) == "true");
|
||||
CHECK(env.render("{{ isArray(name) }}", data) == "false");
|
||||
CHECK(env.render("{{ isString(name) }}", data) == "true");
|
||||
CHECK(env.render("{{ isString(names) }}", data) == "false");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("callbacks") {
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["age"] = 28;
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["age"] = 28;
|
||||
|
||||
env.add_callback("double", 1, [](inja::Arguments& args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return 2 * number;
|
||||
});
|
||||
env.add_callback("double", 1, [](inja::Arguments &args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return 2 * number;
|
||||
});
|
||||
|
||||
env.add_callback("half", 1, [](inja::Arguments args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return number / 2;
|
||||
});
|
||||
env.add_callback("half", 1, [](inja::Arguments args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return number / 2;
|
||||
});
|
||||
|
||||
std::string greet = "Hello";
|
||||
env.add_callback("double-greetings", 0, [greet](inja::Arguments args) {
|
||||
return greet + " " + greet + "!";
|
||||
});
|
||||
std::string greet = "Hello";
|
||||
env.add_callback("double-greetings", 0, [greet](inja::Arguments args) { return greet + " " + greet + "!"; });
|
||||
|
||||
env.add_callback("multiply", 2, [](inja::Arguments args) {
|
||||
double number1 = args.at(0)->get<double>();
|
||||
auto number2 = args.at(1)->get<double>();
|
||||
return number1 * number2;
|
||||
});
|
||||
env.add_callback("multiply", 2, [](inja::Arguments args) {
|
||||
double number1 = args.at(0)->get<double>();
|
||||
auto number2 = args.at(1)->get<double>();
|
||||
return number1 * number2;
|
||||
});
|
||||
|
||||
env.add_callback("multiply", 3, [](inja::Arguments args) {
|
||||
double number1 = args.at(0)->get<double>();
|
||||
double number2 = args.at(1)->get<double>();
|
||||
double number3 = args.at(2)->get<double>();
|
||||
return number1 * number2 * number3;
|
||||
});
|
||||
env.add_callback("multiply", 3, [](inja::Arguments args) {
|
||||
double number1 = args.at(0)->get<double>();
|
||||
double number2 = args.at(1)->get<double>();
|
||||
double number3 = args.at(2)->get<double>();
|
||||
return number1 * number2 * number3;
|
||||
});
|
||||
|
||||
env.add_callback("multiply", 0, [](inja::Arguments args) {
|
||||
return 1.0;
|
||||
});
|
||||
env.add_callback("multiply", 0, [](inja::Arguments args) { return 1.0; });
|
||||
|
||||
CHECK(env.render("{{ double(age) }}", data) == "56");
|
||||
CHECK(env.render("{{ half(age) }}", data) == "14");
|
||||
CHECK(env.render("{{ double-greetings }}", data) == "Hello Hello!");
|
||||
CHECK(env.render("{{ double-greetings() }}", data) == "Hello Hello!");
|
||||
CHECK(env.render("{{ multiply(4, 5) }}", data) == "20.0");
|
||||
CHECK(env.render("{{ multiply(3, 4, 5) }}", data) == "60.0");
|
||||
CHECK(env.render("{{ multiply }}", data) == "1.0");
|
||||
CHECK(env.render("{{ double(age) }}", data) == "56");
|
||||
CHECK(env.render("{{ half(age) }}", data) == "14");
|
||||
CHECK(env.render("{{ double-greetings }}", data) == "Hello Hello!");
|
||||
CHECK(env.render("{{ double-greetings() }}", data) == "Hello Hello!");
|
||||
CHECK(env.render("{{ multiply(4, 5) }}", data) == "20.0");
|
||||
CHECK(env.render("{{ multiply(3, 4, 5) }}", data) == "60.0");
|
||||
CHECK(env.render("{{ multiply }}", data) == "1.0");
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("combinations") {
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = { { "name", "Maria" } };
|
||||
data["is_happy"] = true;
|
||||
inja::Environment env;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = {{"name", "Maria"}};
|
||||
data["is_happy"] = true;
|
||||
|
||||
CHECK(env.render("{% if upper(\"Peter\") == \"PETER\" %}TRUE{% endif %}", data) == "TRUE");
|
||||
CHECK(env.render("{% if lower(upper(name)) == \"peter\" %}TRUE{% endif %}", data) == "TRUE");
|
||||
CHECK(env.render("{% for i in range(4) %}{{ loop.index1 }}{% endfor %}", data) == "1234");
|
||||
CHECK(env.render("{% if upper(\"Peter\") == \"PETER\" %}TRUE{% endif %}", data) == "TRUE");
|
||||
CHECK(env.render("{% if lower(upper(name)) == \"peter\" %}TRUE{% endif %}", data) == "TRUE");
|
||||
CHECK(env.render("{% for i in range(4) %}{{ loop.index1 }}{% endfor %}", data) == "1234");
|
||||
}
|
||||
|
||||
TEST_CASE("templates") {
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["is_happy"] = true;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["is_happy"] = true;
|
||||
|
||||
SUBCASE("reuse") {
|
||||
inja::Environment env;
|
||||
inja::Template temp = env.parse("{% if is_happy %}{{ name }}{% else %}{{ city }}{% endif %}");
|
||||
SUBCASE("reuse") {
|
||||
inja::Environment env;
|
||||
inja::Template temp = env.parse("{% if is_happy %}{{ name }}{% else %}{{ city }}{% endif %}");
|
||||
|
||||
CHECK(env.render(temp, data) == "Peter");
|
||||
CHECK(env.render(temp, data) == "Peter");
|
||||
|
||||
data["is_happy"] = false;
|
||||
data["is_happy"] = false;
|
||||
|
||||
CHECK(env.render(temp, data) == "Brunswick");
|
||||
}
|
||||
CHECK(env.render(temp, data) == "Brunswick");
|
||||
}
|
||||
|
||||
SUBCASE("include") {
|
||||
inja::Environment env;
|
||||
inja::Template t1 = env.parse("Hello {{ name }}");
|
||||
env.include_template("greeting", t1);
|
||||
SUBCASE("include") {
|
||||
inja::Environment env;
|
||||
inja::Template t1 = env.parse("Hello {{ name }}");
|
||||
env.include_template("greeting", t1);
|
||||
|
||||
inja::Template t2 = env.parse("{% include \"greeting\" %}!");
|
||||
CHECK(env.render(t2, data) == "Hello Peter!");
|
||||
CHECK_THROWS_WITH(env.parse("{% include \"does-not-exist\" %}!"), "[inja.exception.file_error] failed accessing file at 'does-not-exist'");
|
||||
}
|
||||
inja::Template t2 = env.parse("{% include \"greeting\" %}!");
|
||||
CHECK(env.render(t2, data) == "Hello Peter!");
|
||||
CHECK_THROWS_WITH(env.parse("{% include \"does-not-exist\" %}!"),
|
||||
"[inja.exception.file_error] failed accessing file at 'does-not-exist'");
|
||||
}
|
||||
|
||||
SUBCASE("include-in-loop") {
|
||||
json loop_data;
|
||||
loop_data["cities"] = json::array({{{"name", "Munich"}}, {{"name", "New York"}}});
|
||||
SUBCASE("include-in-loop") {
|
||||
json loop_data;
|
||||
loop_data["cities"] = json::array({{{"name", "Munich"}}, {{"name", "New York"}}});
|
||||
|
||||
inja::Environment env;
|
||||
env.include_template("city.tpl", env.parse("{{ loop.index }}:{{ city.name }};"));
|
||||
inja::Environment env;
|
||||
env.include_template("city.tpl", env.parse("{{ loop.index }}:{{ city.name }};"));
|
||||
|
||||
CHECK(env.render("{% for city in cities %}{% include \"city.tpl\" %}{% endfor %}", loop_data) == "0:Munich;1:New York;");
|
||||
}
|
||||
CHECK(env.render("{% for city in cities %}{% include \"city.tpl\" %}{% endfor %}", loop_data) ==
|
||||
"0:Munich;1:New York;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("other-syntax") {
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = { { "name", "Maria" } };
|
||||
data["is_happy"] = true;
|
||||
json data;
|
||||
data["name"] = "Peter";
|
||||
data["city"] = "Brunswick";
|
||||
data["age"] = 29;
|
||||
data["names"] = {"Jeff", "Seb"};
|
||||
data["brother"]["name"] = "Chris";
|
||||
data["brother"]["daughters"] = {"Maria", "Helen"};
|
||||
data["brother"]["daughter0"] = {{"name", "Maria"}};
|
||||
data["is_happy"] = true;
|
||||
|
||||
SUBCASE("variables") {
|
||||
inja::Environment env;
|
||||
env.set_element_notation(inja::ElementNotation::Pointer);
|
||||
SUBCASE("variables") {
|
||||
inja::Environment env;
|
||||
env.set_element_notation(inja::ElementNotation::Pointer);
|
||||
|
||||
CHECK(env.render("{{ name }}", data) == "Peter");
|
||||
CHECK(env.render("Hello {{ names/1 }}!", data) == "Hello Seb!");
|
||||
CHECK(env.render("Hello {{ brother/name }}!", data) == "Hello Chris!");
|
||||
CHECK(env.render("Hello {{ brother/daughter0/name }}!", data) == "Hello Maria!");
|
||||
CHECK(env.render("{{ name }}", data) == "Peter");
|
||||
CHECK(env.render("Hello {{ names/1 }}!", data) == "Hello Seb!");
|
||||
CHECK(env.render("Hello {{ brother/name }}!", data) == "Hello Chris!");
|
||||
CHECK(env.render("Hello {{ brother/daughter0/name }}!", data) == "Hello Maria!");
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{{unknown/name}}", data), "[inja.exception.render_error] variable 'unknown/name' not found");
|
||||
}
|
||||
CHECK_THROWS_WITH(env.render("{{unknown/name}}", data),
|
||||
"[inja.exception.render_error] variable 'unknown/name' not found");
|
||||
}
|
||||
|
||||
SUBCASE("other expression syntax") {
|
||||
inja::Environment env;
|
||||
SUBCASE("other expression syntax") {
|
||||
inja::Environment env;
|
||||
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello Peter!");
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello Peter!");
|
||||
|
||||
env.set_expression("(&", "&)");
|
||||
env.set_expression("(&", "&)");
|
||||
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello {{ name }}!");
|
||||
CHECK(env.render("Hello (& name &)!", data) == "Hello Peter!");
|
||||
}
|
||||
CHECK(env.render("Hello {{ name }}!", data) == "Hello {{ name }}!");
|
||||
CHECK(env.render("Hello (& name &)!", data) == "Hello Peter!");
|
||||
}
|
||||
|
||||
SUBCASE("other comment syntax") {
|
||||
inja::Environment env;
|
||||
env.set_comment("(&", "&)");
|
||||
SUBCASE("other comment syntax") {
|
||||
inja::Environment env;
|
||||
env.set_comment("(&", "&)");
|
||||
|
||||
CHECK(env.render("Hello {# Test #}", data) == "Hello {# Test #}");
|
||||
CHECK(env.render("Hello (& Test &)", data) == "Hello ");
|
||||
}
|
||||
CHECK(env.render("Hello {# Test #}", data) == "Hello {# Test #}");
|
||||
CHECK(env.render("Hello (& Test &)", data) == "Hello ");
|
||||
}
|
||||
|
||||
SUBCASE("multiple changes") {
|
||||
inja::Environment env;
|
||||
env.set_line_statement("$$");
|
||||
env.set_expression("<%", "%>");
|
||||
SUBCASE("multiple changes") {
|
||||
inja::Environment env;
|
||||
env.set_line_statement("$$");
|
||||
env.set_expression("<%", "%>");
|
||||
|
||||
std::string string_template = R"DELIM(Hello <%name%>
|
||||
std::string string_template = R"DELIM(Hello <%name%>
|
||||
$$ if name == "Peter"
|
||||
You really are <%name%>
|
||||
$$ endif
|
||||
)DELIM";
|
||||
|
||||
CHECK(env.render(string_template, data) == "Hello Peter\n You really are Peter\n");
|
||||
}
|
||||
CHECK(env.render(string_template, data) == "Hello Peter\n You really are Peter\n");
|
||||
}
|
||||
}
|
||||
|
||||
+18
-19
@@ -1,34 +1,33 @@
|
||||
// Copyright (c) 2019 Pantor. All rights reserved.
|
||||
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
|
||||
#include "doctest/doctest.h"
|
||||
#include "inja/inja.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
TEST_CASE("copy-environment") {
|
||||
inja::Environment env;
|
||||
env.add_callback("double", 1, [](inja::Arguments& args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return 2 * number;
|
||||
});
|
||||
inja::Environment env;
|
||||
env.add_callback("double", 1, [](inja::Arguments &args) {
|
||||
int number = args.at(0)->get<int>();
|
||||
return 2 * number;
|
||||
});
|
||||
|
||||
inja::Template t1 = env.parse("{{ double(2) }}");
|
||||
env.include_template("tpl", t1);
|
||||
std::string test_tpl = "{% include \"tpl\" %}";
|
||||
inja::Template t1 = env.parse("{{ double(2) }}");
|
||||
env.include_template("tpl", t1);
|
||||
std::string test_tpl = "{% include \"tpl\" %}";
|
||||
|
||||
REQUIRE(env.render(test_tpl, json()) == "4");
|
||||
REQUIRE(env.render(test_tpl, json()) == "4");
|
||||
|
||||
inja::Environment copy(env);
|
||||
CHECK(copy.render(test_tpl, json()) == "4");
|
||||
inja::Environment copy(env);
|
||||
CHECK(copy.render(test_tpl, json()) == "4");
|
||||
|
||||
// overwrite template in source env
|
||||
inja::Template t2 = env.parse("{{ double(4) }}");
|
||||
env.include_template("tpl", t2);
|
||||
REQUIRE(env.render(test_tpl, json()) == "8");
|
||||
// overwrite template in source env
|
||||
inja::Template t2 = env.parse("{{ double(4) }}");
|
||||
env.include_template("tpl", t2);
|
||||
REQUIRE(env.render(test_tpl, json()) == "8");
|
||||
|
||||
// template is unchanged in copy
|
||||
CHECK(copy.render(test_tpl, json()) == "4");
|
||||
// template is unchanged in copy
|
||||
CHECK(copy.render(test_tpl, json()) == "4");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user