Skip to content

Commit 4aec944

Browse files
Merge branch 'master' into issue1076
2 parents 2f1c840 + 352d243 commit 4aec944

32 files changed

+1061
-397
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug report
3+
about: Format to report a bug
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
<!-- If this is a question, consider using the discussion section of this repo -->
11+
<!-- Here: https://github.com/stretchr/testify/discussions/new?category=q-a -->
12+
13+
## Description
14+
<!-- A detailed description of the bug -->
15+
16+
## Step To Reproduce
17+
<!-- Steps or code snippet to reproduce the behavior -->
18+
19+
## Expected behavior
20+
<!-- A clear and concise description of what you expected to happen -->
21+
22+
## Actual behavior
23+
<!-- What testify does -->
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Propose a new feature
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
<!-- If this is a question, consider using the discussion section of this repo -->
11+
<!-- Here: https://github.com/stretchr/testify/discussions/new?category=q-a -->
12+
13+
## Description
14+
<!-- A clear and concise description of what feature you are proposing -->
15+
16+
## Proposed solution
17+
<!-- Optionally a suggested implementation -->
18+
19+
## Use case
20+
<!-- What is the motivation? What workarounds have you used? -->

.github/workflows/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ jobs:
77
strategy:
88
matrix:
99
go_version:
10-
- "1.19"
11-
- "1.20"
10+
- stable
11+
- oldstable
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Setup Go
15-
uses: actions/setup-go@v4.1.0
15+
uses: actions/setup-go@v5
1616
with:
1717
go-version: ${{ matrix.go_version }}
1818
- run: ./.ci.gogenerate.sh
@@ -28,10 +28,11 @@ jobs:
2828
- "1.18"
2929
- "1.19"
3030
- "1.20"
31+
- "1.21"
3132
steps:
3233
- uses: actions/checkout@v4
3334
- name: Setup Go
34-
uses: actions/setup-go@v4.1.0
35+
uses: actions/setup-go@v5
3536
with:
3637
go-version: ${{ matrix.go_version }}
3738
- run: go test -v -race ./...

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Create GitHub release from tag
19-
uses: softprops/action-gh-release@v1
19+
uses: softprops/action-gh-release@v1
20+
with:
21+
generate_release_notes: true

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ _testmain.go
2222
*.exe
2323

2424
.DS_Store
25+
26+
# Output of "go test -c"
27+
/assert/assert.test
28+
/require/require.test
29+
/suite/suite.test
30+
/mock/mock.test

EMERITUS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Emeritus
2+
3+
We would like to acknowledge previous testify maintainers and their huge contributions to our collective success:
4+
5+
* @matryer
6+
* @glesica
7+
* @ernesto-jimenez
8+
* @mvdkleijn
9+
* @georgelesica-wf
10+
* @bencampbell-wf
11+
12+
We thank these members for their service to this community.

MAINTAINERS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
The individuals listed below are active in the project and have the ability to approve and merge
44
pull requests.
55

6-
* @glesica
76
* @boyan-soubachov
8-
7+
* @dolmen
8+
* @MovieStoreGuy
9+
* @arjunmahishi
10+
* @brackendawson

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Testify - Thou Shalt Write Tests
33

44
ℹ️ We are working on testify v2 and would love to hear what you'd like to see in it, have your say here: https://cutt.ly/testify
55

6-
[![Build Status](https://travis-ci.org/stretchr/testify.svg)](https://travis-ci.org/stretchr/testify) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/testify)](https://goreportcard.com/report/github.com/stretchr/testify) [![PkgGoDev](https://pkg.go.dev/badge/github.com/stretchr/testify)](https://pkg.go.dev/github.com/stretchr/testify)
6+
[![Build Status](https://github.com/stretchr/testify/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/stretchr/testify/actions/workflows/main.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/testify)](https://goreportcard.com/report/github.com/stretchr/testify) [![PkgGoDev](https://pkg.go.dev/badge/github.com/stretchr/testify)](https://pkg.go.dev/github.com/stretchr/testify)
77

88
Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend.
99

@@ -18,11 +18,9 @@ Get started:
1818
* Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date)
1919
* For an introduction to writing test code in Go, see https://go.dev/doc/code#Testing
2020
* Check out the API Documentation https://pkg.go.dev/github.com/stretchr/testify
21-
* To make your testing life easier, check out our other project, [gorc](https://github.com/stretchr/gorc)
21+
* Use [testifylint](https://github.com/Antonboom/testifylint) (via [golanci-lint](https://golangci-lint.run/)) to avoid common mistakes
2222
* A little about [Test-Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development)
2323

24-
25-
2624
[`assert`](https://pkg.go.dev/github.com/stretchr/testify/assert "API documentation") package
2725
-------------------------------------------------------------------------------------------
2826

assert/assertion_compare.go

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ import (
77
"time"
88
)
99

10-
type CompareType int
10+
// Deprecated: CompareType has only ever been for internal use and has accidentally been published since v1.6.0. Do not use it.
11+
type CompareType = compareResult
12+
13+
type compareResult int
1114

1215
const (
13-
compareLess CompareType = iota - 1
16+
compareLess compareResult = iota - 1
1417
compareEqual
1518
compareGreater
1619
)
@@ -28,6 +31,8 @@ var (
2831
uint32Type = reflect.TypeOf(uint32(1))
2932
uint64Type = reflect.TypeOf(uint64(1))
3033

34+
uintptrType = reflect.TypeOf(uintptr(1))
35+
3136
float32Type = reflect.TypeOf(float32(1))
3237
float64Type = reflect.TypeOf(float64(1))
3338

@@ -37,7 +42,7 @@ var (
3742
bytesType = reflect.TypeOf([]byte{})
3843
)
3944

40-
func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
45+
func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, bool) {
4146
obj1Value := reflect.ValueOf(obj1)
4247
obj2Value := reflect.ValueOf(obj2)
4348

@@ -323,7 +328,13 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
323328
timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
324329
}
325330

326-
return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
331+
if timeObj1.Before(timeObj2) {
332+
return compareLess, true
333+
}
334+
if timeObj1.Equal(timeObj2) {
335+
return compareEqual, true
336+
}
337+
return compareGreater, true
327338
}
328339
case reflect.Slice:
329340
{
@@ -343,7 +354,27 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
343354
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
344355
}
345356

346-
return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
357+
return compareResult(bytes.Compare(bytesObj1, bytesObj2)), true
358+
}
359+
case reflect.Uintptr:
360+
{
361+
uintptrObj1, ok := obj1.(uintptr)
362+
if !ok {
363+
uintptrObj1 = obj1Value.Convert(uintptrType).Interface().(uintptr)
364+
}
365+
uintptrObj2, ok := obj2.(uintptr)
366+
if !ok {
367+
uintptrObj2 = obj2Value.Convert(uintptrType).Interface().(uintptr)
368+
}
369+
if uintptrObj1 > uintptrObj2 {
370+
return compareGreater, true
371+
}
372+
if uintptrObj1 == uintptrObj2 {
373+
return compareEqual, true
374+
}
375+
if uintptrObj1 < uintptrObj2 {
376+
return compareLess, true
377+
}
347378
}
348379
}
349380

@@ -359,7 +390,7 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
359390
if h, ok := t.(tHelper); ok {
360391
h.Helper()
361392
}
362-
return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
393+
return compareTwoValues(t, e1, e2, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
363394
}
364395

365396
// GreaterOrEqual asserts that the first element is greater than or equal to the second
@@ -372,7 +403,7 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
372403
if h, ok := t.(tHelper); ok {
373404
h.Helper()
374405
}
375-
return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
406+
return compareTwoValues(t, e1, e2, []compareResult{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
376407
}
377408

378409
// Less asserts that the first element is less than the second
@@ -384,7 +415,7 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
384415
if h, ok := t.(tHelper); ok {
385416
h.Helper()
386417
}
387-
return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
418+
return compareTwoValues(t, e1, e2, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
388419
}
389420

390421
// LessOrEqual asserts that the first element is less than or equal to the second
@@ -397,7 +428,7 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
397428
if h, ok := t.(tHelper); ok {
398429
h.Helper()
399430
}
400-
return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
431+
return compareTwoValues(t, e1, e2, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
401432
}
402433

403434
// Positive asserts that the specified element is positive
@@ -409,7 +440,7 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
409440
h.Helper()
410441
}
411442
zero := reflect.Zero(reflect.TypeOf(e))
412-
return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
443+
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
413444
}
414445

415446
// Negative asserts that the specified element is negative
@@ -421,10 +452,10 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
421452
h.Helper()
422453
}
423454
zero := reflect.Zero(reflect.TypeOf(e))
424-
return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...)
455+
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareLess}, "\"%v\" is not negative", msgAndArgs...)
425456
}
426457

427-
func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
458+
func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
428459
if h, ok := t.(tHelper); ok {
429460
h.Helper()
430461
}
@@ -447,7 +478,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare
447478
return true
448479
}
449480

450-
func containsValue(values []CompareType, value CompareType) bool {
481+
func containsValue(values []compareResult, value compareResult) bool {
451482
for _, v := range values {
452483
if v == value {
453484
return true

0 commit comments

Comments
 (0)