This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
test_multiple_plustache.cpp
69 lines (59 loc) · 1.64 KB
/
test_multiple_plustache.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <string>
#include <iostream>
#include <fstream>
#include <gtest/gtest.h>
#include "include/template.hpp"
#include "include/plustache_types.hpp"
// The fixture for testing class Foo.
class MultipleTest : public ::testing::Test
{
protected:
std::string result_string;
std::string result_file;
std::string template_string;
std::string expected;
PlustacheTypes::ObjectType ctx;
std::string file;
MultipleTest()
{
}
virtual ~MultipleTest()
{
}
virtual void SetUp()
{
template_string = "<title>{{title}}</title>\n";
template_string += "Hi I am {{name}}{{lastname}}.\n";
template_string += "I like {{pet}}.{{!comment}}\n";
file = "multiple.mustache";
std::ofstream myfile;
myfile.open(file.c_str());
myfile << template_string;
myfile.close();
ctx["title"] = "Multiple Mustaches";
ctx["name"] = "Daniel";
ctx["pet"] = "turtles";
template_t t;
result_string = t.render(template_string, ctx);
result_file = t.render(file, ctx);
}
virtual void TearDown()
{
remove(file.c_str());
}
};
// Tests that multiple mustache tags are replaced
TEST_F(MultipleTest, TestMultipleMustacheFromString)
{
expected = "<title>Multiple Mustaches</title>\n";
expected += "Hi I am Daniel.\n";
expected += "I like turtles.\n";
EXPECT_EQ(expected, result_string);
}
TEST_F(MultipleTest, TestMultipleMustacheFromFile)
{
expected = "<title>Multiple Mustaches</title>\n";
expected += "Hi I am Daniel.\n";
expected += "I like turtles.\n";
EXPECT_EQ(expected, result_file);
}