From 149d33fa6adb9be835d1c1404346d82124dda454 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 19 Oct 2024 18:11:33 -0300 Subject: Setup conventional functional tests, fuzz targets and benchmarks --- tests/benchmarks/string-roundtrip/guuid.go | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/benchmarks/string-roundtrip/guuid.go (limited to 'tests/benchmarks/string-roundtrip/guuid.go') diff --git a/tests/benchmarks/string-roundtrip/guuid.go b/tests/benchmarks/string-roundtrip/guuid.go new file mode 100644 index 0000000..9fef55c --- /dev/null +++ b/tests/benchmarks/string-roundtrip/guuid.go @@ -0,0 +1,37 @@ +package guuid + +import ( + "flag" + "fmt" +) + + + +var nFlag = flag.Int( + "n", + 10_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + uuid := New() + + for i := 0; i < n; i++ { + derived, err := FromString(uuid.String()) + if err != nil { + panic(err) + } + + eq := uuid == derived + if !eq { + panic(fmt.Sprintf( + "bad round trip: orig (%#v); derived (%#v)", + uuid, + derived, + )) + } + } +} -- cgit v1.2.3