MCPcopy
hub / github.com/go-yaml/yaml / TestDecoderSingleDocument

Method TestDecoderSingleDocument

decode_test.go:847–864  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

845}
846
847func (s *S) TestDecoderSingleDocument(c *C) {
848 // Test that Decoder.Decode works as expected on
849 // all the unmarshal tests.
850 for i, item := range unmarshalTests {
851 c.Logf("test %d: %q", i, item.data)
852 if item.data == "" {
853 // Behaviour differs when there's no YAML.
854 continue
855 }
856 t := reflect.ValueOf(item.value).Type()
857 value := reflect.New(t)
858 err := yaml.NewDecoder(strings.NewReader(item.data)).Decode(value.Interface())
859 if _, ok := err.(*yaml.TypeError); !ok {
860 c.Assert(err, IsNil)
861 }
862 c.Assert(value.Elem().Interface(), DeepEquals, item.value)
863 }
864}
865
866var decoderTests = []struct {
867 data string

Callers

nothing calls this directly

Calls 1

DecodeMethod · 0.45

Tested by

no test coverage detected