| 845 | } |
| 846 | |
| 847 | func (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 | |
| 866 | var decoderTests = []struct { |
| 867 | data string |