コード例 #1
0
ファイル: SchemaTests.cs プロジェクト: xen2/stride
        public void TestJsonSchemaCommon(IYamlSchema schema)
        {
            Assert.Equal(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar(null, null, "true", ScalarStyle.DoubleQuoted, false, false)));
            Assert.Equal(JsonSchema.BoolShortTag, schema.GetDefaultTag(new Scalar("true")));
            Assert.Equal(JsonSchema.NullShortTag, schema.GetDefaultTag(new Scalar("null")));
            Assert.Equal(JsonSchema.IntShortTag, schema.GetDefaultTag(new Scalar("5")));
            Assert.Equal(JsonSchema.FloatShortTag, schema.GetDefaultTag(new Scalar("5.5")));

            Assert.Equal(JsonSchema.NullLongTag, schema.ExpandTag("!!null"));
            Assert.Equal(JsonSchema.BoolLongTag, schema.ExpandTag("!!bool"));
            Assert.Equal(JsonSchema.IntLongTag, schema.ExpandTag("!!int"));
            Assert.Equal(JsonSchema.FloatLongTag, schema.ExpandTag("!!float"));

            Assert.Equal("!!null", schema.ShortenTag(JsonSchema.NullLongTag));
            Assert.Equal("!!bool", schema.ShortenTag(JsonSchema.BoolLongTag));
            Assert.Equal("!!int", schema.ShortenTag(JsonSchema.IntLongTag));
            Assert.Equal("!!float", schema.ShortenTag(JsonSchema.FloatLongTag));

            TryParse(schema, "null", JsonSchema.NullShortTag, null);
            TryParse(schema, "true", JsonSchema.BoolShortTag, true);
            TryParse(schema, "false", JsonSchema.BoolShortTag, false);
            TryParse(schema, "5", JsonSchema.IntShortTag, 5);
            TryParse(schema, "5.5", JsonSchema.FloatShortTag, 5.5);
            TryParse(schema, ".inf", JsonSchema.FloatShortTag, double.PositiveInfinity);
        }
コード例 #2
0
ファイル: SchemaTests.cs プロジェクト: xen2/stride
        public void TestFailsafeSchemaCommon(IYamlSchema schema)
        {
            Assert.Equal(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar("true")));
            Assert.Equal(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar("custom", "boom")));
            Assert.Equal(FailsafeSchema.MapShortTag, schema.GetDefaultTag(new MappingStart()));
            Assert.Equal(FailsafeSchema.SeqShortTag, schema.GetDefaultTag(new SequenceStart()));

            Assert.Equal(FailsafeSchema.MapLongTag, schema.ExpandTag("!!map"));
            Assert.Equal(FailsafeSchema.SeqLongTag, schema.ExpandTag("!!seq"));
            Assert.Equal(SchemaBase.StrLongTag, schema.ExpandTag("!!str"));

            Assert.Equal("!!map", schema.ShortenTag(FailsafeSchema.MapLongTag));
            Assert.Equal("!!seq", schema.ShortenTag(FailsafeSchema.SeqLongTag));
            Assert.Equal("!!str", schema.ShortenTag(SchemaBase.StrLongTag));

            TryParse(schema, "true", SchemaBase.StrShortTag, "true");
        }
コード例 #3
0
        public void TestFailsafeSchemaCommon(IYamlSchema schema)
        {
            Assert.AreEqual(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar("true")));
            Assert.AreEqual(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar("custom", "boom")));
            Assert.AreEqual(FailsafeSchema.MapShortTag, schema.GetDefaultTag(new MappingStart()));
            Assert.AreEqual(FailsafeSchema.SeqShortTag, schema.GetDefaultTag(new SequenceStart()));

            Assert.AreEqual(FailsafeSchema.MapLongTag, schema.ExpandTag("!!map"));
            Assert.AreEqual(FailsafeSchema.SeqLongTag, schema.ExpandTag("!!seq"));
            Assert.AreEqual(SchemaBase.StrLongTag, schema.ExpandTag("!!str"));

            Assert.AreEqual("!!map", schema.ShortenTag(FailsafeSchema.MapLongTag));
            Assert.AreEqual("!!seq", schema.ShortenTag(FailsafeSchema.SeqLongTag));
            Assert.AreEqual("!!str", schema.ShortenTag(SchemaBase.StrLongTag));

            TryParse(schema, "true", SchemaBase.StrShortTag, "true");
        }
コード例 #4
0
        public void TestJsonSchemaCommon(IYamlSchema schema)
        {
            Assert.AreEqual(SchemaBase.StrShortTag, schema.GetDefaultTag(new Scalar(null, null, "true", ScalarStyle.DoubleQuoted, false, false)));
            Assert.AreEqual(JsonSchema.BoolShortTag, schema.GetDefaultTag(new Scalar("true")));
            Assert.AreEqual(JsonSchema.NullShortTag, schema.GetDefaultTag(new Scalar("null")));
            Assert.AreEqual(JsonSchema.IntShortTag, schema.GetDefaultTag(new Scalar("5")));
            Assert.AreEqual(JsonSchema.FloatShortTag, schema.GetDefaultTag(new Scalar("5.5")));

            Assert.AreEqual(JsonSchema.NullLongTag, schema.ExpandTag("!!null"));
            Assert.AreEqual(JsonSchema.BoolLongTag, schema.ExpandTag("!!bool"));
            Assert.AreEqual(JsonSchema.IntLongTag, schema.ExpandTag("!!int"));
            Assert.AreEqual(JsonSchema.FloatLongTag, schema.ExpandTag("!!float"));

            Assert.AreEqual("!!null", schema.ShortenTag(JsonSchema.NullLongTag));
            Assert.AreEqual("!!bool", schema.ShortenTag(JsonSchema.BoolLongTag));
            Assert.AreEqual("!!int", schema.ShortenTag(JsonSchema.IntLongTag));
            Assert.AreEqual("!!float", schema.ShortenTag(JsonSchema.FloatLongTag));

            TryParse(schema, "null", JsonSchema.NullShortTag, null);
            TryParse(schema, "true", JsonSchema.BoolShortTag, true);
            TryParse(schema, "false", JsonSchema.BoolShortTag, false);
            TryParse(schema, "5", JsonSchema.IntShortTag, 5);
            TryParse(schema, "5.5", JsonSchema.FloatShortTag, 5.5);
            TryParse(schema, ".inf", JsonSchema.FloatShortTag, double.PositiveInfinity);
        }