Antlr4.Test.StringTemplate.TestRenderers.TestNumberRendererWithPrintfFormat C# (CSharp) Method

TestNumberRendererWithPrintfFormat() private method

private TestNumberRendererWithPrintfFormat ( ) : void
return void
        public void TestNumberRendererWithPrintfFormat()
        {
            //string templates = "foo(x,y) ::= << <x; format=\"%d\"> <y; format=\"%2.3f\"> >>\n";
            string templates = "foo(x,y) ::= << <x; format=\"{0}\"> <y; format=\"{0:0.000}\"> >>\n";

            writeFile(tmpdir, "t.stg", templates);
            TemplateGroup group = new TemplateGroupFile(Path.Combine(tmpdir, "t.stg"));
            group.RegisterRenderer(typeof(int), new NumberRenderer());
            group.RegisterRenderer(typeof(double), new NumberRenderer());
            Template st = group.GetInstanceOf("foo");
            st.Add("x", -2100);
            st.Add("y", 3.14159);
            string expecting = " -2100 3.142 ";
            string result = st.Render();
            Assert.AreEqual(expecting, result);
        }