History

Re-add example tests to failure_external_test.go

Gregory Petrosyan committed 6 years ago

Commit 06a02f31 parent 23d933b2 files · +30 −16Browse files

Showing the changes to example_function_test.go (1 of 2 files). Show all

Unified · Split

example_function_test.go+18−16
@@ -44,23 +44,25 @@ func ParseDate(s string) (int, int, int, error) { · 43 unmodified lines
4444 return y, m, d, nil
4545 }
4646
47−// Rename to TestParseDate(t *testing.T) to make an actual (failing) test.
48−func ExampleCheck_parseDate() {
49− var t *testing.T
50− rapid.Check(t, func(t *rapid.T) {
51− y := rapid.IntRange(0, 9999).Draw(t, "y").(int)
52− m := rapid.IntRange(1, 12).Draw(t, "m").(int)
53− d := rapid.IntRange(1, 31).Draw(t, "d").(int)
47+func testParseDate(t *rapid.T) {
48+ y := rapid.IntRange(0, 9999).Draw(t, "y").(int)
49+ m := rapid.IntRange(1, 12).Draw(t, "m").(int)
50+ d := rapid.IntRange(1, 31).Draw(t, "d").(int)
5451
55− s := fmt.Sprintf("%04d-%02d-%02d", y, m, d)
52+ s := fmt.Sprintf("%04d-%02d-%02d", y, m, d)
5653
57− y_, m_, d_, err := ParseDate(s)
58− if err != nil {
59− t.Fatalf("failed to parse date %q: %v", s, err)
60− }
54+ y_, m_, d_, err := ParseDate(s)
55+ if err != nil {
56+ t.Fatalf("failed to parse date %q: %v", s, err)
57+ }
6158
62− if y_ != y || m_ != m || d_ != d {
63− t.Fatalf("got back wrong date: (%d, %d, %d)", y_, m_, d_)
64− }
65− })
59+ if y_ != y || m_ != m || d_ != d {
60+ t.Fatalf("got back wrong date: (%d, %d, %d)", y_, m_, d_)
61+ }
62+}
63+
64+// Rename to TestParseDate(t *testing.T) to make an actual (failing) test.
65+func ExampleCheck_parseDate() {
66+ var t *testing.T
67+ rapid.Check(t, testParseDate)
6668 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t