Skip to content

Commit

Permalink
Changed mock assertions text output to be non-unicode friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Medzinski authored and ernesto-jimenez committed Dec 31, 2017
1 parent 05aa1d4 commit 2c9035a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,13 @@ func (m *Mock) AssertExpectations(t TestingT) bool {
if !expectedCall.optional && !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) && expectedCall.totalCalls == 0 {
somethingMissing = true
failedExpectations++
t.Logf("\u274C\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
t.Logf("FAIL:\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
} else {
if expectedCall.Repeatability > 0 {
somethingMissing = true
failedExpectations++
} else {
t.Logf("\u2705\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
t.Logf("PASS:\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String())
}
}
}
Expand Down Expand Up @@ -624,18 +624,18 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {

if matcher, ok := expected.(argumentMatcher); ok {
if matcher.Matches(actual) {
output = fmt.Sprintf("%s\t%d: \u2705 %s matched by %s\n", output, i, actual, matcher)
output = fmt.Sprintf("%s\t%d: PASS: %s matched by %s\n", output, i, actual, matcher)
} else {
differences++
output = fmt.Sprintf("%s\t%d: \u2705 %s not matched by %s\n", output, i, actual, matcher)
output = fmt.Sprintf("%s\t%d: PASS: %s not matched by %s\n", output, i, actual, matcher)
}
} else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() {

// type checking
if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) {
// not match
differences++
output = fmt.Sprintf("%s\t%d: \u274C type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actual)
output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actual)
}

} else {
Expand All @@ -644,11 +644,11 @@ func (args Arguments) Diff(objects []interface{}) (string, int) {

if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) {
// match
output = fmt.Sprintf("%s\t%d: \u2705 %s == %s\n", output, i, actual, expected)
output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actual, expected)
} else {
// not match
differences++
output = fmt.Sprintf("%s\t%d: \u274C %s != %s\n", output, i, actual, expected)
output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actual, expected)
}
}

Expand Down

0 comments on commit 2c9035a

Please sign in to comment.