Skip to content

Commit

Permalink
series: update to use %q
Browse files Browse the repository at this point in the history
see exercism#414, updated to make the use of strings more apparent, so [    ]
will now be ["", "", "", "", ""].

All uses of strings have also been changed to use %q rather than %s to be
consistent.
ie. `first_test.go:20: First(1, "01234") = "".  Want "0".`
rather than
ie. `first_test.go:20: First(1, 01234) = .  Want 0.`
or
ie. `first_test.go:20: First(1, 01234) = "".  Want "0".`
  • Loading branch information
robphoenix committed Feb 21, 2017
1 parent fe41836 commit d8b7f57
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions exercises/series/asktoomuch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ func TestAskTooMuch(t *testing.T) {
test := allTests[0]
defer func() {
if recover() != nil {
t.Fatalf("Yikes, UnsafeFirst(%d, %s) panicked!", test.n, test.s)
t.Fatalf("Yikes, UnsafeFirst(%d, %q) panicked!", test.n, test.s)
}
}()
for _, test = range allTests {
switch res := UnsafeFirst(test.n, test.s); {
case len(test.out) > 0: // well, this should work
if res != test.out[0] {
t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, want %q.",
t.Fatalf("Yikes, UnsafeFirst(%d, %q) = %q, want %q.",
test.n, test.s, res, test.out[0])
}
case len(res) != test.n:
t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, but %q doesn't have %d characters.",
t.Fatalf("Yikes, UnsafeFirst(%d, %q) = %q, but %q doesn't have %d characters.",
test.n, test.s, res, res, test.n)
default:
t.Fatalf("Yikes, UnsafeFirst(%d, %s) = %q, but %q isn't in %q",
t.Fatalf("Yikes, UnsafeFirst(%d, %q) = %q, but %q isn't in %q",
test.n, test.s, res, res, test.s)
}
}
Expand Down
6 changes: 3 additions & 3 deletions exercises/series/first_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ func TestFirst(t *testing.T) {
switch res, ok := First(test.n, test.s); {
case !ok:
if len(test.out) > 0 {
t.Fatalf("First(%d, %s) returned !ok, want ok.",
t.Fatalf("First(%d, %q) returned !ok, want ok.",
test.n, test.s)
}
case len(test.out) == 0:
t.Fatalf("First(%d, %s) = %s, %t. Expected ok == false",
t.Fatalf("First(%d, %q) = %q, %t. Expected ok == false",
test.n, test.s, res, ok)
case res != test.out[0]:
t.Fatalf("First(%d, %s) = %s. Want %s.",
t.Fatalf("First(%d, %q) = %q. Want %q.",
test.n, test.s, res, test.out[0])
}
}
Expand Down
4 changes: 2 additions & 2 deletions exercises/series/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestAll(t *testing.T) {
case len(res) == 0 && len(test.out) == 0:
case reflect.DeepEqual(res, test.out):
default:
t.Fatalf("All(%d, %s) = %v, want %v.",
t.Fatalf("All(%d, %q) = %q, want %q.",
test.n, test.s, res, test.out)
}
}
Expand All @@ -87,7 +87,7 @@ func TestUnsafeFirst(t *testing.T) {
continue
}
if res := UnsafeFirst(test.n, test.s); res != test.out[0] {
t.Fatalf("UnsafeFirst(%d, %s) = %s, want %s.",
t.Fatalf("UnsafeFirst(%d, %q) = %q, want %q.",
test.n, test.s, res, test.out[0])
}
}
Expand Down

0 comments on commit d8b7f57

Please sign in to comment.