-
Notifications
You must be signed in to change notification settings - Fork 2
/
fuzzer.go
32 lines (29 loc) · 720 Bytes
/
fuzzer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//
// Copyright 2018-2023 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// +build gofuzz
package semver
// Fuzz is used for fuzzy testing the project
func Fuzz(data []byte) int {
v, err := Parse(string(data))
if err != nil {
if v != nil {
panic("v != nil on error")
}
return 0
}
if v.String() != string(data) {
panic("reserialized string != deserialized string")
}
v.Normalize()
if v.CompareTo(v) != 0 {
panic("compare != 0 while comparing with self")
}
r := ParseRelaxed(string(data))
if r.String() != string(data) {
panic("reserialized relaxed string != deserialized string")
}
return 1
}