From d8b7f571e60ee07fb243719b172ce28af67b0f86 Mon Sep 17 00:00:00 2001 From: Rob Phoenix Date: Tue, 21 Feb 2017 12:28:06 +0000 Subject: [PATCH] series: update to use %q see #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".` --- exercises/series/asktoomuch_test.go | 8 ++++---- exercises/series/first_test.go | 6 +++--- exercises/series/series_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/series/asktoomuch_test.go b/exercises/series/asktoomuch_test.go index e29703a2e..471d35ad4 100644 --- a/exercises/series/asktoomuch_test.go +++ b/exercises/series/asktoomuch_test.go @@ -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) } } diff --git a/exercises/series/first_test.go b/exercises/series/first_test.go index cbe524b2a..16fafb633 100644 --- a/exercises/series/first_test.go +++ b/exercises/series/first_test.go @@ -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]) } } diff --git a/exercises/series/series_test.go b/exercises/series/series_test.go index 682d78f05..1b358b680 100644 --- a/exercises/series/series_test.go +++ b/exercises/series/series_test.go @@ -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) } } @@ -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]) } }