Clarify error message for incorrect use of IsIncreasing et al

Because maps are collections but not ordered.

Co-authored-by: Olivier Mengué <dolmen@cpan.org>
pull/1430/head
Bracken 2023-08-08 13:13:19 +01:00 committed by Bracken Dawson
parent 8b4aef060a
commit 685783ac52
No known key found for this signature in database
GPG Key ID: 8CB332D5A897919D
2 changed files with 5 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import (
func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
objKind := reflect.TypeOf(object).Kind()
if objKind != reflect.Slice && objKind != reflect.Array {
return Fail(t, fmt.Sprintf("object %T is not a collection", object), msgAndArgs...)
return Fail(t, fmt.Sprintf("object %T is not an ordered collection", object), msgAndArgs...)
}
objValue := reflect.ValueOf(object)

View File

@ -44,7 +44,7 @@ func TestIsIncreasing(t *testing.T) {
{collection: []uint64{2, 1}, msg: `"2" is not less than "1"`},
{collection: []float32{2.34, 1.23}, msg: `"2.34" is not less than "1.23"`},
{collection: []float64{2.34, 1.23}, msg: `"2.34" is not less than "1.23"`},
{collection: struct{}{}, msg: `object struct {} is not a collection`},
{collection: struct{}{}, msg: `object struct {} is not an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
@ -92,7 +92,7 @@ func TestIsNonIncreasing(t *testing.T) {
{collection: []uint64{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []float32{1.23, 2.34}, msg: `"1.23" is not greater than or equal to "2.34"`},
{collection: []float64{1.23, 2.34}, msg: `"1.23" is not greater than or equal to "2.34"`},
{collection: struct{}{}, msg: `object struct {} is not a collection`},
{collection: struct{}{}, msg: `object struct {} is not an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
@ -140,7 +140,7 @@ func TestIsDecreasing(t *testing.T) {
{collection: []uint64{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []float32{1.23, 2.34}, msg: `"1.23" is not greater than "2.34"`},
{collection: []float64{1.23, 2.34}, msg: `"1.23" is not greater than "2.34"`},
{collection: struct{}{}, msg: `object struct {} is not a collection`},
{collection: struct{}{}, msg: `object struct {} is not an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
@ -188,7 +188,7 @@ func TestIsNonDecreasing(t *testing.T) {
{collection: []uint64{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []float32{2.34, 1.23}, msg: `"2.34" is not less than or equal to "1.23"`},
{collection: []float64{2.34, 1.23}, msg: `"2.34" is not less than or equal to "1.23"`},
{collection: struct{}{}, msg: `object struct {} is not a collection`},
{collection: struct{}{}, msg: `object struct {} is not an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}