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
44 return y, m, d, nil44 return y, m, d, nil
45}45}
46 46
47// Rename to TestParseDate(t *testing.T) to make an actual (failing) test.47func testParseDate(t *rapid.T) {
48func ExampleCheck_parseDate() {48 y := rapid.IntRange(0, 9999).Draw(t, "y").(int)
49 var t *testing.T49 m := rapid.IntRange(1, 12).Draw(t, "m").(int)
50 rapid.Check(t, func(t *rapid.T) {50 d := rapid.IntRange(1, 31).Draw(t, "d").(int)
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)
54 51
55 s := fmt.Sprintf("%04d-%02d-%02d", y, m, d)52 s := fmt.Sprintf("%04d-%02d-%02d", y, m, d)
56 53
57 y_, m_, d_, err := ParseDate(s)54 y_, m_, d_, err := ParseDate(s)
58 if err != nil {55 if err != nil {
59 t.Fatalf("failed to parse date %q: %v", s, err)56 t.Fatalf("failed to parse date %q: %v", s, err)
60 }57 }
61 58
62 if y_ != y || m_ != m || d_ != d {59 if y_ != y || m_ != m || d_ != d {
63 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_)
64 }61 }
65 })62}
63
64// Rename to TestParseDate(t *testing.T) to make an actual (failing) test.
65func ExampleCheck_parseDate() {
66 var t *testing.T
67 rapid.Check(t, testParseDate)
66}68}

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