示例#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));
        }