예제 #1
0
        private static NcParser GetSqlParser()
        {
            var assembly = Assembly.GetExecutingAssembly();

            return(NcParser.LoadFromAssembly(assembly, "Nccc.Tests.SQL.sql.grammer", settings =>
            {
                settings.CaseSensitive = false;
            }));
        }
예제 #2
0
파일: JsonTests.cs 프로젝트: sKabYY/Nccc
        public void TestSample()
        {
            var src         = Assembly.GetExecutingAssembly().ReadString("Nccc.Tests.Json.sample.json");
            var parser      = NcParser.LoadFromAssembly(Assembly.GetExecutingAssembly(), "Nccc.Tests.Json.json.grammer");
            var parseResult = parser.Parse(src);

            Console.WriteLine(parseResult.ToSExp().ToPrettyString());
            Assert.IsTrue(parseResult.IsSuccess());
        }
예제 #3
0
파일: JsonTests.cs 프로젝트: sKabYY/Nccc
        public void TestError()
        {
            var expectMessage = "哈哈";
            var src           = "[1,2,3";
            var parser        = NcParser.LoadFromAssembly(Assembly.GetExecutingAssembly(), "Nccc.Tests.Json.json.grammer", settings =>
            {
                settings.Locale.Language = "zh-cn";
                settings.Locale.Set("zh-cn", new Dictionary <string, string>
                {
                    { "expect", expectMessage }
                });
            });
            var parseResult = parser.Parse(src);

            Console.WriteLine(parseResult.ToSExp().ToPrettyString());
            Assert.IsFalse(parseResult.IsSuccess());
            Assert.IsTrue(parseResult.Message.Contains(expectMessage));
        }