diff options
| author | Dave Collins <[email protected]> | 2013-01-20 12:02:36 -0600 |
|---|---|---|
| committer | Dave Collins <[email protected]> | 2013-01-20 12:02:36 -0600 |
| commit | 5c8d842977941cdb1663827b8c6a93046e211bbb (patch) | |
| tree | 2da421934d0d0c93e15c5d1a195945c5f472437b /spew/spew_test.go | |
| parent | 1c16a20c214d354cf84ca9646c73fc78b0620f7e (diff) | |
Add tests for maps with multiple entries.
Previously, the tests did not include maps with more than a single entry
since the iteration order is randomized and the tests only accepted a
single valid expected value. This commit modifies the tests to accept
multiple valid expected values and adds tests for a multi-entry map to
both Dump and Formatter.
Diffstat (limited to 'spew/spew_test.go')
| -rw-r--r-- | spew/spew_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spew/spew_test.go b/spew/spew_test.go index d2d620e..406edc1 100644 --- a/spew/spew_test.go +++ b/spew/spew_test.go @@ -25,6 +25,31 @@ import ( "testing" ) +// stringizeWants converts a slice of wanted test output into a format suitable +// for an test error message. +func stringizeWants(wants []string) string { + s := "" + for i, want := range wants { + if i > 0 { + s += fmt.Sprintf("want%d: %s", i+1, want) + } else { + s += "want: " + want + } + } + return s +} + +// testFailed returns whether or not a test failed by checking if the result +// of the test is in the slice of wanted strings. +func testFailed(result string, wants []string) bool { + for _, want := range wants { + if result == want { + return false + } + } + return true +} + // spewFunc is used to identify which public function of the spew package or // ConfigState a test applies to. type spewFunc int |
