fuzz.go 472 B

12345678910111213141516171819202122232425262728293031
  1. // +build gofuzz
  2. package toml
  3. func Fuzz(data []byte) int {
  4. tree, err := LoadBytes(data)
  5. if err != nil {
  6. if tree != nil {
  7. panic("tree must be nil if there is an error")
  8. }
  9. return 0
  10. }
  11. str, err := tree.ToTomlString()
  12. if err != nil {
  13. if str != "" {
  14. panic(`str must be "" if there is an error`)
  15. }
  16. panic(err)
  17. }
  18. tree, err = Load(str)
  19. if err != nil {
  20. if tree != nil {
  21. panic("tree must be nil if there is an error")
  22. }
  23. return 0
  24. }
  25. return 1
  26. }