Skip to content

Commit dee8182

Browse files
committed
string Longer/Shorter cross bug fixed
1 parent 8f4e835 commit dee8182

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

assert/assert.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ func Len(obj string, length int, a ...any) {
435435
//
436436
// Note! This is reasonably fast but not as fast as 'That' because of lacking
437437
// inlining for the current implementation of Go's type parametric functions.
438-
func Longer(obj string, length int, a ...any) {
439-
l := len(obj)
438+
func Longer(s string, length int, a ...any) {
439+
l := len(s)
440440

441-
if l > length {
441+
if l <= length {
442442
defMsg := fmt.Sprintf(assertionMsg+gotWantLongerFmt, l, length)
443443
Default().reportAssertionFault(defMsg, a)
444444
}
@@ -451,10 +451,10 @@ func Longer(obj string, length int, a ...any) {
451451
//
452452
// Note! This is reasonably fast but not as fast as 'That' because of lacking
453453
// inlining for the current implementation of Go's type parametric functions.
454-
func Shorter(obj string, length int, a ...any) {
455-
l := len(obj)
454+
func Shorter(str string, length int, a ...any) {
455+
l := len(str)
456456

457-
if l <= length {
457+
if l >= length {
458458
defMsg := fmt.Sprintf(assertionMsg+gotWantShorterFmt, l, length)
459459
Default().reportAssertionFault(defMsg, a)
460460
}

0 commit comments

Comments
 (0)