Showing the changes to example_function_test.go (1 of 14 files). Show all
Unified · Split
| @@ -44,7 +44,11 @@ func ParseDate(s string) (int, int, int, error) { · 43 unmodified lines | |||
| 44 | 44 | ||
| 45 | // Rename to TestParseDate to make an actual (failing) test. | 45 | // Rename to TestParseDate to make an actual (failing) test. |
| 46 | func Example_parseDate(t *testing.T) { | 46 | func Example_parseDate(t *testing.T) { |
| 47 | rapid.Check(t, func(t *rapid.T, y int, m int, d int) { | 47 | rapid.Check(t, func(t *rapid.T) { |
| 48 | y := rapid.IntsRange(0, 9999).Draw(t, "y").(int) | ||
| 49 | m := rapid.IntsRange(1, 12).Draw(t, "m").(int) | ||
| 50 | d := rapid.IntsRange(1, 31).Draw(t, "d").(int) | ||
| 51 | |||
| 48 | s := fmt.Sprintf("%04d-%02d-%02d", y, m, d) | 52 | s := fmt.Sprintf("%04d-%02d-%02d", y, m, d) |
| 49 | 53 | ||
| 50 | y_, m_, d_, err := ParseDate(s) | 54 | y_, m_, d_, err := ParseDate(s) |
| @@ -55,5 +59,5 @@ func Example_parseDate(t *testing.T) { · 4 unmodified lines | |||
| 55 | if y_ != y || m_ != m || d_ != d { | 59 | if y_ != y || m_ != m || d_ != d { |
| 56 | t.Fatalf("got back wrong date: (%d, %d, %d)", y_, m_, d_) | 60 | t.Fatalf("got back wrong date: (%d, %d, %d)", y_, m_, d_) |
| 57 | } | 61 | } |
| 58 | }, rapid.IntsRange(0, 9999), rapid.IntsRange(1, 12), rapid.IntsRange(1, 31)) | 62 | }) |
| 59 | } | 63 | } |