Revert D23802296: gtest-ify JIT tests, through the letter c

Test Plan: revert-hammer

Differential Revision:
D23802296 (https://github.com/pytorch/pytorch/commit/d2b045030eb60283b8aeeb2956c7ebe91628fece)

Original commit changeset: 20c9798a414e

fbshipit-source-id: a28d56039ca404fe94ed7572f1febd1673e3e788
This commit is contained in:
Michael Suo
2020-09-23 17:40:15 -07:00
committed by Facebook GitHub Bot
parent 89c570ed0a
commit e9aa6898ab
11 changed files with 299 additions and 287 deletions
+26 -24
View File
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>
#include "test/cpp/jit/test_base.h"
#include "test/cpp/jit/test_utils.h"
#include <test/cpp/jit/test_utils.h>
#include "torch/csrc/jit/frontend/code_template.h"
namespace torch {
@@ -33,29 +33,31 @@ static const auto ct_expect = R"(
int notest(int a)
)";
TEST(TestCodeTemplate, Copying) {
TemplateEnv e;
e.s("hi", "foo");
e.v("what", {"is", "this"});
TemplateEnv c(e);
c.s("hi", "foo2");
ASSERT_EQ(e.s("hi"), "foo");
ASSERT_EQ(c.s("hi"), "foo2");
ASSERT_EQ(e.v("what")[0], "is");
}
void testCodeTemplate() {
{
TemplateEnv e;
e.s("hi", "foo");
e.v("what", {"is", "this"});
TemplateEnv c(e);
c.s("hi", "foo2");
ASSERT_EQ(e.s("hi"), "foo");
ASSERT_EQ(c.s("hi"), "foo2");
ASSERT_EQ(e.v("what")[0], "is");
}
TEST(TestCodeTemplate, Formatting) {
TemplateEnv e;
e.v("args", {"hi", "8"});
e.v("bar", {"what\non many\nlines...", "7"});
e.s("a", "3");
e.s("b", "4");
e.v("stuff", {"things...", "others"});
e.v("empty", {});
auto s = ct.format(e);
// std::cout << "'" << s << "'\n";
// std::cout << "'" << ct_expect << "'\n";
ASSERT_EQ(s, ct_expect);
{
TemplateEnv e;
e.v("args", {"hi", "8"});
e.v("bar", {"what\non many\nlines...", "7"});
e.s("a", "3");
e.s("b", "4");
e.v("stuff", {"things...", "others"});
e.v("empty", {});
auto s = ct.format(e);
// std::cout << "'" << s << "'\n";
// std::cout << "'" << ct_expect << "'\n";
ASSERT_EQ(s, ct_expect);
}
}
} // namespace jit