Showing preview only (920K chars total). Download the full file or copy to clipboard to get everything.
Repository: stretchr/testify
Branch: master
Commit: 5f80e4aef7be
Files: 86
Total size: 884.8 KB
Directory structure:
gitextract_0dnewmdf/
├── .ci.gofmt.sh
├── .ci.gogenerate.sh
├── .ci.govet.sh
├── .ci.readme.fmt.sh
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── dependabot.yml
│ ├── pull_request_template.md
│ └── workflows/
│ ├── main.yml
│ └── release.yml
├── .gitignore
├── .mdsf.json
├── CONTRIBUTING.md
├── EMERITUS.md
├── LICENSE
├── MAINTAINERS.md
├── README.md
├── assert/
│ ├── assertion_compare.go
│ ├── assertion_compare_test.go
│ ├── assertion_format.go
│ ├── assertion_format.go.tmpl
│ ├── assertion_forward.go
│ ├── assertion_forward.go.tmpl
│ ├── assertion_order.go
│ ├── assertion_order_test.go
│ ├── assertions.go
│ ├── assertions_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── forward_assertions.go
│ ├── forward_assertions_test.go
│ ├── http_assertions.go
│ ├── http_assertions_test.go
│ ├── internal/
│ │ └── unsafetests/
│ │ ├── doc.go
│ │ └── unsafetests_test.go
│ └── yaml/
│ ├── yaml_custom.go
│ ├── yaml_default.go
│ └── yaml_fail.go
├── doc.go
├── go.mod
├── go.sum
├── http/
│ ├── doc.go
│ ├── test_response_writer.go
│ └── test_round_tripper.go
├── internal/
│ ├── difflib/
│ │ ├── LICENSE
│ │ ├── difflib.go
│ │ └── difflib_test.go
│ └── spew/
│ ├── LICENSE
│ ├── README.md
│ ├── bypass.go
│ ├── bypasssafe.go
│ ├── common.go
│ ├── common_test.go
│ ├── config.go
│ ├── doc.go
│ ├── dump.go
│ ├── dump_test.go
│ ├── dumpcgo_test.go
│ ├── dumpnocgo_test.go
│ ├── format.go
│ ├── format_test.go
│ ├── internal_test.go
│ ├── internalunsafe_test.go
│ ├── spew.go
│ ├── spew_test.go
│ └── testdata/
│ └── dumpcgo.go
├── mock/
│ ├── doc.go
│ ├── mock.go
│ └── mock_test.go
├── package_test.go
├── require/
│ ├── doc.go
│ ├── forward_requirements.go
│ ├── forward_requirements_test.go
│ ├── require.go
│ ├── require.go.tmpl
│ ├── require_forward.go
│ ├── require_forward.go.tmpl
│ ├── requirements.go
│ └── requirements_test.go
└── suite/
├── doc.go
├── interfaces.go
├── stats.go
├── stats_test.go
├── suite.go
└── suite_test.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .ci.gofmt.sh
================================================
#!/usr/bin/env bash
if [ -n "$(gofmt -l .)" ]; then
echo "Go code is not formatted:"
gofmt -d .
exit 1
fi
go generate ./...
if [ -n "$(git status -s -uno)" ]; then
echo "Go generate output does not match commit."
echo "Did you forget to run go generate ./... ?"
exit 1
fi
================================================
FILE: .ci.gogenerate.sh
================================================
#!/usr/bin/env bash
# If GOMOD is defined we are running with Go Modules enabled, either
# automatically or via the GO111MODULE=on environment variable. Codegen only
# works with modules, so skip generation if modules is not in use.
if [[ -z "$(go env GOMOD)" ]]; then
echo "Skipping go generate because modules not enabled and required"
exit 0
fi
go generate ./...
if [ -n "$(git diff)" ]; then
echo "Go generate had not been run"
git diff
exit 1
fi
================================================
FILE: .ci.govet.sh
================================================
#!/usr/bin/env bash
set -e
go vet ./...
================================================
FILE: .ci.readme.fmt.sh
================================================
#!/usr/bin/env bash
# Verify that the code snippets in README.md are formatted.
# The tool https://github.com/hougesen/mdsf is used.
if [ -n "$(mdsf verify --config .mdsf.json --log-level error README.md 2>&1)" ]; then
echo "Go code in the README.md is not formatted."
echo "Did you forget to run 'mdsf format --config .mdsf.json README.md'?"
mdsf format --config .mdsf.json README.md
git diff
exit 1
fi
================================================
FILE: .gitattributes
================================================
# This file is used to configure Git attributes for the repository.
# It is particularly useful for managing how generated code is treated in pull requests.
# For more information, see:
# https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github
# Code for assertions and requirements is generated automatically by _codegen.
# This also updates code comments and code examples in the documentation.
# These comments and examples must be reviewed when they change,
# since updates to the generated code comments may not always be correct.
assert/*.go linguist-generated=false
require/*.go linguist-generated=false
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Format to report a bug
title: ''
labels: bug
assignees: ''
---
<!-- If this is a question, consider using the discussion section of this repo -->
<!-- Here: https://github.com/stretchr/testify/discussions/new?category=q-a -->
## Description
<!-- A detailed description of the bug -->
## Step To Reproduce
<!-- Steps or code snippet to reproduce the behavior -->
## Expected behavior
<!-- A clear and concise description of what you expected to happen -->
## Actual behavior
<!-- What testify does -->
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Propose a new feature
title: ''
labels: enhancement
assignees: ''
---
<!-- If this is a question, consider using the discussion section of this repo -->
<!-- Here: https://github.com/stretchr/testify/discussions/new?category=q-a -->
## Description
<!-- A clear and concise description of what feature you are proposing -->
## Proposed solution
<!-- Optionally a suggested implementation -->
## Use case
<!-- What is the motivation? What workarounds have you used? -->
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
================================================
FILE: .github/pull_request_template.md
================================================
## Summary
<!-- High-level, one sentence summary of what this PR accomplishes -->
## Changes
<!-- * Description of change 1 -->
<!-- * Description of change 2 -->
<!-- ... -->
## Motivation
<!-- Why were the changes necessary. -->
<!-- ## Example usage (if applicable) -->
## Related issues
<!-- Put `Closes #XXXX` for each issue number this PR fixes/closes -->
================================================
FILE: .github/workflows/main.yml
================================================
name: All builds
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go_version:
- stable
- oldstable
steps:
- uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go_version }}
- run: npm install -g mdsf-cli
- run: ./.ci.gogenerate.sh
- run: ./.ci.gofmt.sh
- run: ./.ci.readme.fmt.sh
- run: ./.ci.govet.sh
- run: go test -v -race ./...
test:
runs-on: ubuntu-latest
strategy:
matrix:
go_version:
- "1.17"
- "1.18"
- "1.19"
- "1.20"
- "1.21"
- "1.22"
- "1.23"
- "1.24"
steps:
- uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go_version }}
- run: go test -v -race ./...
================================================
FILE: .github/workflows/release.yml
================================================
name: Create release from new tag
# this flow will be run only when new tags are pushed that match our pattern
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Create GitHub release from tag
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
================================================
FILE: .gitignore
================================================
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
.DS_Store
# Output of "go test -c"
/assert/assert.test
/require/require.test
/suite/suite.test
/mock/mock.test
================================================
FILE: .mdsf.json
================================================
{
"$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.8.2/mdsf.schema.json",
"format_finished_document": false,
"languages": {
"go": [
[
"gofmt",
"goimports"
]
]
}
}
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to Testify
So you'd like to contribute to Testify? First of all, thank you! Testify is widely used, so each
contribution has a significant impact within the Golang community! Below you'll find everything you
need to know to get up to speed on the project.
## Philosophy
The Testify maintainers generally attempt to follow widely accepted practices within the Golang
community. That being said, the first priority is always to make sure that the package is useful to
the community. A few general guidelines are listed here:
*Keep it simple (whenever practical)* - Try not to expand the API unless the new surface area
provides meaningful benefits. For example, don't add functions because they might be useful to
someone, someday. Add what is useful to specific users, today.
*Ease of use is paramount* - This means good documentation and package organization. It also means
that we should try hard to use meaningful, descriptive function names, avoid breaking the API
unnecessarily, and try not to surprise the user.
*Quality isn't an afterthought* - Testify is a testing library, so it seems reasonable that we
should have a decent test suite. This is doubly important because a bug in Testify doesn't just mean
a bug in our users' code, it means a bug in our users' tests, which means a potentially unnoticed
and hard-to-find bug in our users' code.
## Pull Requests
We welcome pull requests! Please include the following in the description:
* Motivation, why your change is important or helpful
* Example usage (if applicable)
* Whether you intend to add / change behavior or fix a bug
Please be aware that the maintainers may ask for changes. This isn't a commentary on the quality of
your idea or your code. Testify is the result of many contributions from many individuals, so we
need to enforce certain practices and patterns to keep the package easy for others to understand.
Essentially, we recognize that there are often many good ways to do a given thing, but we have to
pick one and stick with it.
See `MAINTAINERS.md` for a list of users who can approve / merge your changes.
## Issues
If you find a bug or think of a useful feature you'd like to see added to Testify, the best thing
you can do is make the necessary changes and open a pull request (see above). If that isn't an
option, or if you'd like to discuss your change before you write the code, open an issue!
Please provide enough context in the issue description that other members of the community can
easily understand what it is that you'd like to see.
================================================
FILE: EMERITUS.md
================================================
# Emeritus
We would like to acknowledge previous testify maintainers and their huge contributions to our collective success:
* @tylerb
* @matryer
* @glesica
* @ernesto-jimenez
* @mvdkleijn
* @georgelesica-wf
* @bencampbell-wf
We thank these members for their service to this community.
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: MAINTAINERS.md
================================================
# Testify Maintainers
The individuals listed below are active in the project and have the ability to approve and merge
pull requests.
* @boyan-soubachov
* @dolmen
* @MovieStoreGuy
* @brackendawson
* @ccoVeille
## Approvers
The individuals listed below are active in the project and have the ability to approve pull
requests.
* @arjunmahishi
================================================
FILE: README.md
================================================
Testify - Thou Shalt Write Tests
================================
> [!NOTE]
> Testify is being maintained at v1, no breaking changes will be accepted in this repo.
> [See discussion about v2](https://github.com/stretchr/testify/discussions/1560).
[](https://github.com/stretchr/testify/actions/workflows/main.yml) [](https://goreportcard.com/report/github.com/stretchr/testify) [](https://pkg.go.dev/github.com/stretchr/testify)
Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend.
Features include:
* [Easy assertions](#assert-package)
* [Mocking](#mock-package)
* [Testing suite interfaces and functions](#suite-package)
Get started:
* Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date)
* For an introduction to writing test code in Go, see https://go.dev/doc/code#Testing
* Check out the API Documentation https://pkg.go.dev/github.com/stretchr/testify
* Use [testifylint](https://github.com/Antonboom/testifylint) (via [golangci-lint](https://golangci-lint.run/)) to avoid common mistakes
* A little about [Test-Driven Development (TDD)](https://en.wikipedia.org/wiki/Test-driven_development)
[`assert`](https://pkg.go.dev/github.com/stretchr/testify/assert "API documentation") package
-------------------------------------------------------------------------------------------
The `assert` package provides some helpful methods that allow you to write better test code in Go.
* Prints friendly, easy to read failure descriptions
* Allows for very readable code
* Optionally annotate each assertion with a message
See it in action:
```go
package yours
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSomething(t *testing.T) {
// assert equality
assert.Equal(t, 123, 123, "they should be equal")
// assert inequality
assert.NotEqual(t, 123, 456, "they should not be equal")
// assert for nil (good for errors)
assert.Nil(t, object)
// assert for not nil (good when you expect something)
if assert.NotNil(t, object) {
// now we know that object isn't nil, we are safe to make
// further assertions without causing any errors
assert.Equal(t, "Something", object.Value)
}
}
```
* Every assert func takes the `testing.T` object as the first argument. This is how it writes the errors out through the normal `go test` capabilities.
* Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions.
if you assert many times, use the below:
```go
package yours
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSomething(t *testing.T) {
assert := assert.New(t)
// assert equality
assert.Equal(123, 123, "they should be equal")
// assert inequality
assert.NotEqual(123, 456, "they should not be equal")
// assert for nil (good for errors)
assert.Nil(object)
// assert for not nil (good when you expect something)
if assert.NotNil(object) {
// now we know that object isn't nil, we are safe to make
// further assertions without causing any errors
assert.Equal("Something", object.Value)
}
}
```
[`require`](https://pkg.go.dev/github.com/stretchr/testify/require "API documentation") package
---------------------------------------------------------------------------------------------
The `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test.
These functions must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test.
Otherwise race conditions may occur.
See [t.FailNow](https://pkg.go.dev/testing#T.FailNow) for details.
[`mock`](https://pkg.go.dev/github.com/stretchr/testify/mock "API documentation") package
----------------------------------------------------------------------------------------
The `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code.
An example test function that tests a piece of code that relies on an external object `testObj`, can set up expectations (testify) and assert that they indeed happened:
```go
package yours
import (
"testing"
"github.com/stretchr/testify/mock"
)
/*
Test objects
*/
// MyMockedObject is a mocked object that implements an interface
// that describes an object that the code I am testing relies on.
type MyMockedObject struct {
mock.Mock
}
// DoSomething is a method on MyMockedObject that implements some interface
// and just records the activity, and returns what the Mock object tells it to.
//
// In the real object, this method would do something useful, but since this
// is a mocked object - we're just going to stub it out.
//
// NOTE: This method is not being tested here, code that uses this object is.
func (m *MyMockedObject) DoSomething(number int) (bool, error) {
args := m.Called(number)
return args.Bool(0), args.Error(1)
}
/*
Actual test functions
*/
// TestSomething is an example of how to use our test object to
// make assertions about some target code we are testing.
func TestSomething(t *testing.T) {
// create an instance of our test object
testObj := new(MyMockedObject)
// set up expectations
testObj.On("DoSomething", 123).Return(true, nil)
// call the code we are testing
targetFuncThatDoesSomethingWithObj(testObj)
// assert that the expectations were met
testObj.AssertExpectations(t)
}
// TestSomethingWithPlaceholder is a second example of how to use our test object to
// make assertions about some target code we are testing.
// This time using a placeholder. Placeholders might be used when the
// data being passed in is normally dynamically generated and cannot be
// predicted beforehand (eg. containing hashes that are time sensitive)
func TestSomethingWithPlaceholder(t *testing.T) {
// create an instance of our test object
testObj := new(MyMockedObject)
// set up expectations with a placeholder in the argument list
testObj.On("DoSomething", mock.Anything).Return(true, nil)
// call the code we are testing
targetFuncThatDoesSomethingWithObj(testObj)
// assert that the expectations were met
testObj.AssertExpectations(t)
}
// TestSomethingElse2 is a third example that shows how you can use
// the Unset method to cleanup handlers and then add new ones.
func TestSomethingElse2(t *testing.T) {
// create an instance of our test object
testObj := new(MyMockedObject)
// set up expectations with a placeholder in the argument list
mockCall := testObj.On("DoSomething", mock.Anything).Return(true, nil)
// call the code we are testing
targetFuncThatDoesSomethingWithObj(testObj)
// assert that the expectations were met
testObj.AssertExpectations(t)
// remove the handler now so we can add another one that takes precedence
mockCall.Unset()
// return false now instead of true
testObj.On("DoSomething", mock.Anything).Return(false, nil)
testObj.AssertExpectations(t)
}
```
For more information on how to write mock code, check out the [API documentation for the `mock` package](https://pkg.go.dev/github.com/stretchr/testify/mock).
You can use the [mockery tool](https://vektra.github.io/mockery/latest/) to autogenerate the mock code against an interface as well, making using mocks much quicker.
[`suite`](https://pkg.go.dev/github.com/stretchr/testify/suite "API documentation") package
-----------------------------------------------------------------------------------------
> [!WARNING]
> The suite package does not support parallel tests. See [#934](https://github.com/stretchr/testify/issues/934).
The `suite` package provides functionality that you might be used to from more common object-oriented languages. With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal.
An example suite is shown below:
```go
// Basic imports
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
// Define the suite, and absorb the built-in basic suite
// functionality from testify - including a T() method which
// returns the current testing context
type ExampleTestSuite struct {
suite.Suite
VariableThatShouldStartAtFive int
}
// Make sure that VariableThatShouldStartAtFive is set to five
// before each test
func (suite *ExampleTestSuite) SetupTest() {
suite.VariableThatShouldStartAtFive = 5
}
// All methods that begin with "Test" are run as tests within a
// suite.
func (suite *ExampleTestSuite) TestExample() {
assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive)
}
// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestExampleTestSuite(t *testing.T) {
suite.Run(t, new(ExampleTestSuite))
}
```
For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go)
For more information on writing suites, check out the [API documentation for the `suite` package](https://pkg.go.dev/github.com/stretchr/testify/suite).
`Suite` object has assertion methods:
```go
// Basic imports
import (
"testing"
"github.com/stretchr/testify/suite"
)
// Define the suite, and absorb the built-in basic suite
// functionality from testify - including assertion methods.
type ExampleTestSuite struct {
suite.Suite
VariableThatShouldStartAtFive int
}
// Make sure that VariableThatShouldStartAtFive is set to five
// before each test
func (suite *ExampleTestSuite) SetupTest() {
suite.VariableThatShouldStartAtFive = 5
}
// All methods that begin with "Test" are run as tests within a
// suite.
func (suite *ExampleTestSuite) TestExample() {
suite.Equal(suite.VariableThatShouldStartAtFive, 5)
}
// In order for 'go test' to run this suite, we need to create
// a normal test function and pass our suite to suite.Run
func TestExampleTestSuite(t *testing.T) {
suite.Run(t, new(ExampleTestSuite))
}
```
------
Installation
============
To install Testify, use `go get`:
go get github.com/stretchr/testify
This will then make the following packages available to you:
github.com/stretchr/testify/assert
github.com/stretchr/testify/require
github.com/stretchr/testify/mock
github.com/stretchr/testify/suite
github.com/stretchr/testify/http (deprecated)
Import the `testify/assert` package into your code using this template:
```go
package yours
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSomething(t *testing.T) {
assert.True(t, true, "True is true!")
}
```
------
Staying up to date
==================
To update Testify to the latest version, use `go get -u github.com/stretchr/testify`.
------
Supported go versions
==================
We currently support the most recent major Go versions from 1.19 onward.
------
Contributing
============
Please feel free to submit issues, fork the repository and send pull requests!
When submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it.
Code generation is used. [Look for `Code generated with`](https://github.com/search?q=repo%3Astretchr%2Ftestify%20%22Code%20generated%20with%22&type=code) at the top of some files. Run `go generate ./...` to update generated files.
We also chat on the [Gophers Slack](https://gophers.slack.com) group in the `#testify` and `#testify-dev` channels.
------
License
=======
This project is licensed under the terms of the MIT license.
================================================
FILE: assert/assertion_compare.go
================================================
package assert
import (
"bytes"
"fmt"
"reflect"
"time"
)
// Deprecated: CompareType has only ever been for internal use and has accidentally been published since v1.6.0. Do not use it.
type CompareType = compareResult
type compareResult int
const (
compareLess compareResult = iota - 1
compareEqual
compareGreater
)
var (
intType = reflect.TypeOf(int(1))
int8Type = reflect.TypeOf(int8(1))
int16Type = reflect.TypeOf(int16(1))
int32Type = reflect.TypeOf(int32(1))
int64Type = reflect.TypeOf(int64(1))
uintType = reflect.TypeOf(uint(1))
uint8Type = reflect.TypeOf(uint8(1))
uint16Type = reflect.TypeOf(uint16(1))
uint32Type = reflect.TypeOf(uint32(1))
uint64Type = reflect.TypeOf(uint64(1))
uintptrType = reflect.TypeOf(uintptr(1))
float32Type = reflect.TypeOf(float32(1))
float64Type = reflect.TypeOf(float64(1))
stringType = reflect.TypeOf("")
timeType = reflect.TypeOf(time.Time{})
bytesType = reflect.TypeOf([]byte{})
)
func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, bool) {
obj1Value := reflect.ValueOf(obj1)
obj2Value := reflect.ValueOf(obj2)
// throughout this switch we try and avoid calling .Convert() if possible,
// as this has a pretty big performance impact
switch kind {
case reflect.Int:
{
intobj1, ok := obj1.(int)
if !ok {
intobj1 = obj1Value.Convert(intType).Interface().(int)
}
intobj2, ok := obj2.(int)
if !ok {
intobj2 = obj2Value.Convert(intType).Interface().(int)
}
if intobj1 > intobj2 {
return compareGreater, true
}
if intobj1 == intobj2 {
return compareEqual, true
}
if intobj1 < intobj2 {
return compareLess, true
}
}
case reflect.Int8:
{
int8obj1, ok := obj1.(int8)
if !ok {
int8obj1 = obj1Value.Convert(int8Type).Interface().(int8)
}
int8obj2, ok := obj2.(int8)
if !ok {
int8obj2 = obj2Value.Convert(int8Type).Interface().(int8)
}
if int8obj1 > int8obj2 {
return compareGreater, true
}
if int8obj1 == int8obj2 {
return compareEqual, true
}
if int8obj1 < int8obj2 {
return compareLess, true
}
}
case reflect.Int16:
{
int16obj1, ok := obj1.(int16)
if !ok {
int16obj1 = obj1Value.Convert(int16Type).Interface().(int16)
}
int16obj2, ok := obj2.(int16)
if !ok {
int16obj2 = obj2Value.Convert(int16Type).Interface().(int16)
}
if int16obj1 > int16obj2 {
return compareGreater, true
}
if int16obj1 == int16obj2 {
return compareEqual, true
}
if int16obj1 < int16obj2 {
return compareLess, true
}
}
case reflect.Int32:
{
int32obj1, ok := obj1.(int32)
if !ok {
int32obj1 = obj1Value.Convert(int32Type).Interface().(int32)
}
int32obj2, ok := obj2.(int32)
if !ok {
int32obj2 = obj2Value.Convert(int32Type).Interface().(int32)
}
if int32obj1 > int32obj2 {
return compareGreater, true
}
if int32obj1 == int32obj2 {
return compareEqual, true
}
if int32obj1 < int32obj2 {
return compareLess, true
}
}
case reflect.Int64:
{
int64obj1, ok := obj1.(int64)
if !ok {
int64obj1 = obj1Value.Convert(int64Type).Interface().(int64)
}
int64obj2, ok := obj2.(int64)
if !ok {
int64obj2 = obj2Value.Convert(int64Type).Interface().(int64)
}
if int64obj1 > int64obj2 {
return compareGreater, true
}
if int64obj1 == int64obj2 {
return compareEqual, true
}
if int64obj1 < int64obj2 {
return compareLess, true
}
}
case reflect.Uint:
{
uintobj1, ok := obj1.(uint)
if !ok {
uintobj1 = obj1Value.Convert(uintType).Interface().(uint)
}
uintobj2, ok := obj2.(uint)
if !ok {
uintobj2 = obj2Value.Convert(uintType).Interface().(uint)
}
if uintobj1 > uintobj2 {
return compareGreater, true
}
if uintobj1 == uintobj2 {
return compareEqual, true
}
if uintobj1 < uintobj2 {
return compareLess, true
}
}
case reflect.Uint8:
{
uint8obj1, ok := obj1.(uint8)
if !ok {
uint8obj1 = obj1Value.Convert(uint8Type).Interface().(uint8)
}
uint8obj2, ok := obj2.(uint8)
if !ok {
uint8obj2 = obj2Value.Convert(uint8Type).Interface().(uint8)
}
if uint8obj1 > uint8obj2 {
return compareGreater, true
}
if uint8obj1 == uint8obj2 {
return compareEqual, true
}
if uint8obj1 < uint8obj2 {
return compareLess, true
}
}
case reflect.Uint16:
{
uint16obj1, ok := obj1.(uint16)
if !ok {
uint16obj1 = obj1Value.Convert(uint16Type).Interface().(uint16)
}
uint16obj2, ok := obj2.(uint16)
if !ok {
uint16obj2 = obj2Value.Convert(uint16Type).Interface().(uint16)
}
if uint16obj1 > uint16obj2 {
return compareGreater, true
}
if uint16obj1 == uint16obj2 {
return compareEqual, true
}
if uint16obj1 < uint16obj2 {
return compareLess, true
}
}
case reflect.Uint32:
{
uint32obj1, ok := obj1.(uint32)
if !ok {
uint32obj1 = obj1Value.Convert(uint32Type).Interface().(uint32)
}
uint32obj2, ok := obj2.(uint32)
if !ok {
uint32obj2 = obj2Value.Convert(uint32Type).Interface().(uint32)
}
if uint32obj1 > uint32obj2 {
return compareGreater, true
}
if uint32obj1 == uint32obj2 {
return compareEqual, true
}
if uint32obj1 < uint32obj2 {
return compareLess, true
}
}
case reflect.Uint64:
{
uint64obj1, ok := obj1.(uint64)
if !ok {
uint64obj1 = obj1Value.Convert(uint64Type).Interface().(uint64)
}
uint64obj2, ok := obj2.(uint64)
if !ok {
uint64obj2 = obj2Value.Convert(uint64Type).Interface().(uint64)
}
if uint64obj1 > uint64obj2 {
return compareGreater, true
}
if uint64obj1 == uint64obj2 {
return compareEqual, true
}
if uint64obj1 < uint64obj2 {
return compareLess, true
}
}
case reflect.Float32:
{
float32obj1, ok := obj1.(float32)
if !ok {
float32obj1 = obj1Value.Convert(float32Type).Interface().(float32)
}
float32obj2, ok := obj2.(float32)
if !ok {
float32obj2 = obj2Value.Convert(float32Type).Interface().(float32)
}
if float32obj1 > float32obj2 {
return compareGreater, true
}
if float32obj1 == float32obj2 {
return compareEqual, true
}
if float32obj1 < float32obj2 {
return compareLess, true
}
}
case reflect.Float64:
{
float64obj1, ok := obj1.(float64)
if !ok {
float64obj1 = obj1Value.Convert(float64Type).Interface().(float64)
}
float64obj2, ok := obj2.(float64)
if !ok {
float64obj2 = obj2Value.Convert(float64Type).Interface().(float64)
}
if float64obj1 > float64obj2 {
return compareGreater, true
}
if float64obj1 == float64obj2 {
return compareEqual, true
}
if float64obj1 < float64obj2 {
return compareLess, true
}
}
case reflect.String:
{
stringobj1, ok := obj1.(string)
if !ok {
stringobj1 = obj1Value.Convert(stringType).Interface().(string)
}
stringobj2, ok := obj2.(string)
if !ok {
stringobj2 = obj2Value.Convert(stringType).Interface().(string)
}
if stringobj1 > stringobj2 {
return compareGreater, true
}
if stringobj1 == stringobj2 {
return compareEqual, true
}
if stringobj1 < stringobj2 {
return compareLess, true
}
}
// Check for known struct types we can check for compare results.
case reflect.Struct:
{
// All structs enter here. We're not interested in most types.
if !obj1Value.CanConvert(timeType) {
break
}
// time.Time can be compared!
timeObj1, ok := obj1.(time.Time)
if !ok {
timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time)
}
timeObj2, ok := obj2.(time.Time)
if !ok {
timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
}
if timeObj1.Before(timeObj2) {
return compareLess, true
}
if timeObj1.Equal(timeObj2) {
return compareEqual, true
}
return compareGreater, true
}
case reflect.Slice:
{
// We only care about the []byte type.
if !obj1Value.CanConvert(bytesType) {
break
}
// []byte can be compared!
bytesObj1, ok := obj1.([]byte)
if !ok {
bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte)
}
bytesObj2, ok := obj2.([]byte)
if !ok {
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
}
return compareResult(bytes.Compare(bytesObj1, bytesObj2)), true
}
case reflect.Uintptr:
{
uintptrObj1, ok := obj1.(uintptr)
if !ok {
uintptrObj1 = obj1Value.Convert(uintptrType).Interface().(uintptr)
}
uintptrObj2, ok := obj2.(uintptr)
if !ok {
uintptrObj2 = obj2Value.Convert(uintptrType).Interface().(uintptr)
}
if uintptrObj1 > uintptrObj2 {
return compareGreater, true
}
if uintptrObj1 == uintptrObj2 {
return compareEqual, true
}
if uintptrObj1 < uintptrObj2 {
return compareLess, true
}
}
}
return compareEqual, false
}
// Greater asserts that the first element is greater than the second
//
// assert.Greater(t, 2, 1)
// assert.Greater(t, float64(2), float64(1))
// assert.Greater(t, "b", "a")
func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
failMessage := fmt.Sprintf("\"%v\" is not greater than \"%v\"", e1, e2)
return compareTwoValues(t, e1, e2, []compareResult{compareGreater}, failMessage, msgAndArgs...)
}
// GreaterOrEqual asserts that the first element is greater than or equal to the second
//
// assert.GreaterOrEqual(t, 2, 1)
// assert.GreaterOrEqual(t, 2, 2)
// assert.GreaterOrEqual(t, "b", "a")
// assert.GreaterOrEqual(t, "b", "b")
func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
failMessage := fmt.Sprintf("\"%v\" is not greater than or equal to \"%v\"", e1, e2)
return compareTwoValues(t, e1, e2, []compareResult{compareGreater, compareEqual}, failMessage, msgAndArgs...)
}
// Less asserts that the first element is less than the second
//
// assert.Less(t, 1, 2)
// assert.Less(t, float64(1), float64(2))
// assert.Less(t, "a", "b")
func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
failMessage := fmt.Sprintf("\"%v\" is not less than \"%v\"", e1, e2)
return compareTwoValues(t, e1, e2, []compareResult{compareLess}, failMessage, msgAndArgs...)
}
// LessOrEqual asserts that the first element is less than or equal to the second
//
// assert.LessOrEqual(t, 1, 2)
// assert.LessOrEqual(t, 2, 2)
// assert.LessOrEqual(t, "a", "b")
// assert.LessOrEqual(t, "b", "b")
func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
failMessage := fmt.Sprintf("\"%v\" is not less than or equal to \"%v\"", e1, e2)
return compareTwoValues(t, e1, e2, []compareResult{compareLess, compareEqual}, failMessage, msgAndArgs...)
}
// Positive asserts that the specified element is positive
//
// assert.Positive(t, 1)
// assert.Positive(t, 1.23)
func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
zero := reflect.Zero(reflect.TypeOf(e))
failMessage := fmt.Sprintf("\"%v\" is not positive", e)
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareGreater}, failMessage, msgAndArgs...)
}
// Negative asserts that the specified element is negative
//
// assert.Negative(t, -1)
// assert.Negative(t, -1.23)
func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
zero := reflect.Zero(reflect.TypeOf(e))
failMessage := fmt.Sprintf("\"%v\" is not negative", e)
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareLess}, failMessage, msgAndArgs...)
}
func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
e1Kind := reflect.ValueOf(e1).Kind()
e2Kind := reflect.ValueOf(e2).Kind()
if e1Kind != e2Kind {
return Fail(t, "Elements should be the same type", msgAndArgs...)
}
compareResult, isComparable := compare(e1, e2, e1Kind)
if !isComparable {
return Fail(t, fmt.Sprintf(`Can not compare type "%T"`, e1), msgAndArgs...)
}
if !containsValue(allowedComparesResults, compareResult) {
return Fail(t, failMessage, msgAndArgs...)
}
return true
}
func containsValue(values []compareResult, value compareResult) bool {
for _, v := range values {
if v == value {
return true
}
}
return false
}
================================================
FILE: assert/assertion_compare_test.go
================================================
package assert
import (
"bytes"
"fmt"
"reflect"
"runtime"
"testing"
"time"
)
func TestCompare(t *testing.T) {
t.Parallel()
type customString string
type customInt int
type customInt8 int8
type customInt16 int16
type customInt32 int32
type customInt64 int64
type customUInt uint
type customUInt8 uint8
type customUInt16 uint16
type customUInt32 uint32
type customUInt64 uint64
type customFloat32 float32
type customFloat64 float64
type customUintptr uintptr
type customTime time.Time
type customBytes []byte
for _, currCase := range []struct {
less interface{}
greater interface{}
cType string
}{
{less: customString("a"), greater: customString("b"), cType: "string"},
{less: "a", greater: "b", cType: "string"},
{less: customInt(1), greater: customInt(2), cType: "int"},
{less: int(1), greater: int(2), cType: "int"},
{less: customInt8(1), greater: customInt8(2), cType: "int8"},
{less: int8(1), greater: int8(2), cType: "int8"},
{less: customInt16(1), greater: customInt16(2), cType: "int16"},
{less: int16(1), greater: int16(2), cType: "int16"},
{less: customInt32(1), greater: customInt32(2), cType: "int32"},
{less: int32(1), greater: int32(2), cType: "int32"},
{less: customInt64(1), greater: customInt64(2), cType: "int64"},
{less: int64(1), greater: int64(2), cType: "int64"},
{less: customUInt(1), greater: customUInt(2), cType: "uint"},
{less: uint8(1), greater: uint8(2), cType: "uint8"},
{less: customUInt8(1), greater: customUInt8(2), cType: "uint8"},
{less: uint16(1), greater: uint16(2), cType: "uint16"},
{less: customUInt16(1), greater: customUInt16(2), cType: "uint16"},
{less: uint32(1), greater: uint32(2), cType: "uint32"},
{less: customUInt32(1), greater: customUInt32(2), cType: "uint32"},
{less: uint64(1), greater: uint64(2), cType: "uint64"},
{less: customUInt64(1), greater: customUInt64(2), cType: "uint64"},
{less: float32(1.23), greater: float32(2.34), cType: "float32"},
{less: customFloat32(1.23), greater: customFloat32(2.23), cType: "float32"},
{less: float64(1.23), greater: float64(2.34), cType: "float64"},
{less: customFloat64(1.23), greater: customFloat64(2.34), cType: "float64"},
{less: uintptr(1), greater: uintptr(2), cType: "uintptr"},
{less: customUintptr(1), greater: customUintptr(2), cType: "uint64"},
{less: time.Now(), greater: time.Now().Add(time.Hour), cType: "time.Time"},
{less: time.Date(2024, 0, 0, 0, 0, 0, 0, time.Local), greater: time.Date(2263, 0, 0, 0, 0, 0, 0, time.Local), cType: "time.Time"},
{less: customTime(time.Now()), greater: customTime(time.Now().Add(time.Hour)), cType: "time.Time"},
{less: []byte{1, 1}, greater: []byte{1, 2}, cType: "[]byte"},
{less: customBytes([]byte{1, 1}), greater: customBytes([]byte{1, 2}), cType: "[]byte"},
} {
resLess, isComparable := compare(currCase.less, currCase.greater, reflect.ValueOf(currCase.less).Kind())
if !isComparable {
t.Error("object should be comparable for type " + currCase.cType)
}
if resLess != compareLess {
t.Errorf("object less (%v) should be less than greater (%v) for type "+currCase.cType,
currCase.less, currCase.greater)
}
resGreater, isComparable := compare(currCase.greater, currCase.less, reflect.ValueOf(currCase.less).Kind())
if !isComparable {
t.Error("object are comparable for type " + currCase.cType)
}
if resGreater != compareGreater {
t.Errorf("object greater should be greater than less for type " + currCase.cType)
}
resEqual, isComparable := compare(currCase.less, currCase.less, reflect.ValueOf(currCase.less).Kind())
if !isComparable {
t.Error("object are comparable for type " + currCase.cType)
}
if resEqual != 0 {
t.Errorf("objects should be equal for type " + currCase.cType)
}
}
}
type outputT struct {
buf *bytes.Buffer
helpers map[string]struct{}
}
// Implements TestingT
func (t *outputT) Errorf(format string, args ...interface{}) {
s := fmt.Sprintf(format, args...)
t.buf.WriteString(s)
}
func (t *outputT) Helper() {
if t.helpers == nil {
t.helpers = make(map[string]struct{})
}
t.helpers[callerName(1)] = struct{}{}
}
// callerName gives the function name (qualified with a package path)
// for the caller after skip frames (where 0 means the current function).
func callerName(skip int) string {
// Make room for the skip PC.
var pc [1]uintptr
n := runtime.Callers(skip+2, pc[:]) // skip + runtime.Callers + callerName
if n == 0 {
panic("testing: zero callers found")
}
frames := runtime.CallersFrames(pc[:n])
frame, _ := frames.Next()
return frame.Function
}
func TestGreater(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !Greater(mockT, 2, 1) {
t.Error("Greater should return true")
}
if Greater(mockT, 1, 1) {
t.Error("Greater should return false")
}
if Greater(mockT, 1, 2) {
t.Error("Greater should return false")
}
// Check error report
for _, currCase := range []struct {
less interface{}
greater interface{}
msg string
}{
{less: "a", greater: "b", msg: `"a" is not greater than "b"`},
{less: int(1), greater: int(2), msg: `"1" is not greater than "2"`},
{less: int8(1), greater: int8(2), msg: `"1" is not greater than "2"`},
{less: int16(1), greater: int16(2), msg: `"1" is not greater than "2"`},
{less: int32(1), greater: int32(2), msg: `"1" is not greater than "2"`},
{less: int64(1), greater: int64(2), msg: `"1" is not greater than "2"`},
{less: uint8(1), greater: uint8(2), msg: `"1" is not greater than "2"`},
{less: uint16(1), greater: uint16(2), msg: `"1" is not greater than "2"`},
{less: uint32(1), greater: uint32(2), msg: `"1" is not greater than "2"`},
{less: uint64(1), greater: uint64(2), msg: `"1" is not greater than "2"`},
{less: float32(1.23), greater: float32(2.34), msg: `"1.23" is not greater than "2.34"`},
{less: float64(1.23), greater: float64(2.34), msg: `"1.23" is not greater than "2.34"`},
{less: uintptr(1), greater: uintptr(2), msg: `"1" is not greater than "2"`},
{less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 00:00:00 +0000 UTC" is not greater than "0001-01-01 01:00:00 +0000 UTC"`},
{less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 1]" is not greater than "[1 2]"`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Greater(out, currCase.less, currCase.greater))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Greater")
}
}
func TestGreaterOrEqual(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !GreaterOrEqual(mockT, 2, 1) {
t.Error("GreaterOrEqual should return true")
}
if !GreaterOrEqual(mockT, 1, 1) {
t.Error("GreaterOrEqual should return true")
}
if GreaterOrEqual(mockT, 1, 2) {
t.Error("GreaterOrEqual should return false")
}
// Check error report
for _, currCase := range []struct {
less interface{}
greater interface{}
msg string
}{
{less: "a", greater: "b", msg: `"a" is not greater than or equal to "b"`},
{less: int(1), greater: int(2), msg: `"1" is not greater than or equal to "2"`},
{less: int8(1), greater: int8(2), msg: `"1" is not greater than or equal to "2"`},
{less: int16(1), greater: int16(2), msg: `"1" is not greater than or equal to "2"`},
{less: int32(1), greater: int32(2), msg: `"1" is not greater than or equal to "2"`},
{less: int64(1), greater: int64(2), msg: `"1" is not greater than or equal to "2"`},
{less: uint8(1), greater: uint8(2), msg: `"1" is not greater than or equal to "2"`},
{less: uint16(1), greater: uint16(2), msg: `"1" is not greater than or equal to "2"`},
{less: uint32(1), greater: uint32(2), msg: `"1" is not greater than or equal to "2"`},
{less: uint64(1), greater: uint64(2), msg: `"1" is not greater than or equal to "2"`},
{less: float32(1.23), greater: float32(2.34), msg: `"1.23" is not greater than or equal to "2.34"`},
{less: float64(1.23), greater: float64(2.34), msg: `"1.23" is not greater than or equal to "2.34"`},
{less: uintptr(1), greater: uintptr(2), msg: `"1" is not greater than or equal to "2"`},
{less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 00:00:00 +0000 UTC" is not greater than or equal to "0001-01-01 01:00:00 +0000 UTC"`},
{less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 1]" is not greater than or equal to "[1 2]"`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, GreaterOrEqual(out, currCase.less, currCase.greater))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.GreaterOrEqual")
}
}
func TestLess(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !Less(mockT, 1, 2) {
t.Error("Less should return true")
}
if Less(mockT, 1, 1) {
t.Error("Less should return false")
}
if Less(mockT, 2, 1) {
t.Error("Less should return false")
}
// Check error report
for _, currCase := range []struct {
less interface{}
greater interface{}
msg string
}{
{less: "a", greater: "b", msg: `"b" is not less than "a"`},
{less: int(1), greater: int(2), msg: `"2" is not less than "1"`},
{less: int8(1), greater: int8(2), msg: `"2" is not less than "1"`},
{less: int16(1), greater: int16(2), msg: `"2" is not less than "1"`},
{less: int32(1), greater: int32(2), msg: `"2" is not less than "1"`},
{less: int64(1), greater: int64(2), msg: `"2" is not less than "1"`},
{less: uint8(1), greater: uint8(2), msg: `"2" is not less than "1"`},
{less: uint16(1), greater: uint16(2), msg: `"2" is not less than "1"`},
{less: uint32(1), greater: uint32(2), msg: `"2" is not less than "1"`},
{less: uint64(1), greater: uint64(2), msg: `"2" is not less than "1"`},
{less: float32(1.23), greater: float32(2.34), msg: `"2.34" is not less than "1.23"`},
{less: float64(1.23), greater: float64(2.34), msg: `"2.34" is not less than "1.23"`},
{less: uintptr(1), greater: uintptr(2), msg: `"2" is not less than "1"`},
{less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 01:00:00 +0000 UTC" is not less than "0001-01-01 00:00:00 +0000 UTC"`},
{less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 2]" is not less than "[1 1]"`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Less(out, currCase.greater, currCase.less))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Less")
}
}
func TestLessOrEqual(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !LessOrEqual(mockT, 1, 2) {
t.Error("LessOrEqual should return true")
}
if !LessOrEqual(mockT, 1, 1) {
t.Error("LessOrEqual should return true")
}
if LessOrEqual(mockT, 2, 1) {
t.Error("LessOrEqual should return false")
}
// Check error report
for _, currCase := range []struct {
less interface{}
greater interface{}
msg string
}{
{less: "a", greater: "b", msg: `"b" is not less than or equal to "a"`},
{less: int(1), greater: int(2), msg: `"2" is not less than or equal to "1"`},
{less: int8(1), greater: int8(2), msg: `"2" is not less than or equal to "1"`},
{less: int16(1), greater: int16(2), msg: `"2" is not less than or equal to "1"`},
{less: int32(1), greater: int32(2), msg: `"2" is not less than or equal to "1"`},
{less: int64(1), greater: int64(2), msg: `"2" is not less than or equal to "1"`},
{less: uint8(1), greater: uint8(2), msg: `"2" is not less than or equal to "1"`},
{less: uint16(1), greater: uint16(2), msg: `"2" is not less than or equal to "1"`},
{less: uint32(1), greater: uint32(2), msg: `"2" is not less than or equal to "1"`},
{less: uint64(1), greater: uint64(2), msg: `"2" is not less than or equal to "1"`},
{less: float32(1.23), greater: float32(2.34), msg: `"2.34" is not less than or equal to "1.23"`},
{less: float64(1.23), greater: float64(2.34), msg: `"2.34" is not less than or equal to "1.23"`},
{less: uintptr(1), greater: uintptr(2), msg: `"2" is not less than or equal to "1"`},
{less: time.Time{}, greater: time.Time{}.Add(time.Hour), msg: `"0001-01-01 01:00:00 +0000 UTC" is not less than or equal to "0001-01-01 00:00:00 +0000 UTC"`},
{less: []byte{1, 1}, greater: []byte{1, 2}, msg: `"[1 2]" is not less than or equal to "[1 1]"`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, LessOrEqual(out, currCase.greater, currCase.less))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.LessOrEqual")
}
}
func TestPositive(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !Positive(mockT, 1) {
t.Error("Positive should return true")
}
if !Positive(mockT, 1.23) {
t.Error("Positive should return true")
}
if Positive(mockT, -1) {
t.Error("Positive should return false")
}
if Positive(mockT, -1.23) {
t.Error("Positive should return false")
}
// Check error report
for _, currCase := range []struct {
e interface{}
msg string
}{
{e: int(-1), msg: `"-1" is not positive`},
{e: int8(-1), msg: `"-1" is not positive`},
{e: int16(-1), msg: `"-1" is not positive`},
{e: int32(-1), msg: `"-1" is not positive`},
{e: int64(-1), msg: `"-1" is not positive`},
{e: float32(-1.23), msg: `"-1.23" is not positive`},
{e: float64(-1.23), msg: `"-1.23" is not positive`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Positive(out, currCase.e))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Positive")
}
}
func TestNegative(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !Negative(mockT, -1) {
t.Error("Negative should return true")
}
if !Negative(mockT, -1.23) {
t.Error("Negative should return true")
}
if Negative(mockT, 1) {
t.Error("Negative should return false")
}
if Negative(mockT, 1.23) {
t.Error("Negative should return false")
}
// Check error report
for _, currCase := range []struct {
e interface{}
msg string
}{
{e: int(1), msg: `"1" is not negative`},
{e: int8(1), msg: `"1" is not negative`},
{e: int16(1), msg: `"1" is not negative`},
{e: int32(1), msg: `"1" is not negative`},
{e: int64(1), msg: `"1" is not negative`},
{e: float32(1.23), msg: `"1.23" is not negative`},
{e: float64(1.23), msg: `"1.23" is not negative`},
} {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, Negative(out, currCase.e))
Contains(t, out.buf.String(), currCase.msg)
Contains(t, out.helpers, "github.com/stretchr/testify/assert.Negative")
}
}
func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
for _, currCase := range []struct {
v1 interface{}
v2 interface{}
compareResult bool
}{
{v1: 123, v2: "abc"},
{v1: "abc", v2: 123456},
{v1: float64(12), v2: "123"},
{v1: "float(12)", v2: float64(1)},
} {
result := compareTwoValues(mockT, currCase.v1, currCase.v2, []compareResult{compareLess, compareEqual, compareGreater}, "testFailMessage")
False(t, result)
}
}
func Test_compareTwoValuesNotComparableValues(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
type CompareStruct struct {
}
for _, currCase := range []struct {
v1 interface{}
v2 interface{}
}{
{v1: CompareStruct{}, v2: CompareStruct{}},
{v1: map[string]int{}, v2: map[string]int{}},
{v1: make([]int, 5), v2: make([]int, 5)},
} {
result := compareTwoValues(mockT, currCase.v1, currCase.v2, []compareResult{compareLess, compareEqual, compareGreater}, "testFailMessage")
False(t, result)
}
}
func Test_compareTwoValuesCorrectCompareResult(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
for _, currCase := range []struct {
v1 interface{}
v2 interface{}
allowedResults []compareResult
}{
{v1: 1, v2: 2, allowedResults: []compareResult{compareLess}},
{v1: 1, v2: 2, allowedResults: []compareResult{compareLess, compareEqual}},
{v1: 2, v2: 2, allowedResults: []compareResult{compareGreater, compareEqual}},
{v1: 2, v2: 2, allowedResults: []compareResult{compareEqual}},
{v1: 2, v2: 1, allowedResults: []compareResult{compareEqual, compareGreater}},
{v1: 2, v2: 1, allowedResults: []compareResult{compareGreater}},
} {
result := compareTwoValues(mockT, currCase.v1, currCase.v2, currCase.allowedResults, "testFailMessage")
True(t, result)
}
}
func Test_containsValue(t *testing.T) {
t.Parallel()
for _, currCase := range []struct {
values []compareResult
value compareResult
result bool
}{
{values: []compareResult{compareGreater}, value: compareGreater, result: true},
{values: []compareResult{compareGreater, compareLess}, value: compareGreater, result: true},
{values: []compareResult{compareGreater, compareLess}, value: compareLess, result: true},
{values: []compareResult{compareGreater, compareLess}, value: compareEqual, result: false},
} {
result := containsValue(currCase.values, currCase.value)
Equal(t, currCase.result, result)
}
}
func TestComparingMsgAndArgsForwarding(t *testing.T) {
msgAndArgs := []interface{}{"format %s %x", "this", 0xc001}
expectedOutput := "format this c001\n"
funcs := []func(t TestingT){
func(t TestingT) { Greater(t, 1, 2, msgAndArgs...) },
func(t TestingT) { GreaterOrEqual(t, 1, 2, msgAndArgs...) },
func(t TestingT) { Less(t, 2, 1, msgAndArgs...) },
func(t TestingT) { LessOrEqual(t, 2, 1, msgAndArgs...) },
func(t TestingT) { Positive(t, 0, msgAndArgs...) },
func(t TestingT) { Negative(t, 0, msgAndArgs...) },
}
for _, f := range funcs {
out := &outputT{buf: bytes.NewBuffer(nil)}
f(out)
Contains(t, out.buf.String(), expectedOutput)
}
}
================================================
FILE: assert/assertion_format.go
================================================
// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package assert
import (
http "net/http"
url "net/url"
time "time"
)
// Conditionf uses a Comparison to assert a complex condition.
func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Condition(t, comp, append([]interface{}{msg}, args...)...)
}
// Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
}
// DirExistsf checks whether a directory exists in the given path. It also fails
// if the path is a file rather a directory or there is an error checking whether it exists.
func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return DirExists(t, path, append([]interface{}{msg}, args...)...)
}
// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
}
// Emptyf asserts that the given value is "empty".
//
// [Zero values] are "empty".
//
// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
//
// Slices, maps and channels with zero length are "empty".
//
// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
//
// assert.Emptyf(t, obj, "error message %s", "formatted")
//
// [Zero values]: https://go.dev/ref/spec#The_zero_value
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Empty(t, object, append([]interface{}{msg}, args...)...)
}
// Equalf asserts that two objects are equal.
//
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// EqualErrorf asserts that a function returned a non-nil error (i.e. an error)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
}
// EqualExportedValuesf asserts that the types of two objects are equal and their public
// fields are also equal. This is useful for comparing structs that have private fields
// that could potentially differ.
//
// type S struct {
// Exported int
// notExported int
// }
// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// EqualValuesf asserts that two objects are equal or convertible to the larger
// type and equal.
//
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// Errorf asserts that a function returned a non-nil error (ie. an error).
//
// actualObj, err := SomeFunction()
// assert.Errorf(t, err, "error message %s", "formatted")
func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Error(t, err, append([]interface{}{msg}, args...)...)
}
// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
// This is a wrapper for errors.As.
func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return ErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
}
// ErrorContainsf asserts that a function returned a non-nil error (i.e. an
// error) and that the error contains the specified substring.
//
// actualObj, err := SomeFunction()
// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted")
func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return ErrorContains(t, theError, contains, append([]interface{}{msg}, args...)...)
}
// ErrorIsf asserts that at least one of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return ErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
}
// Eventuallyf asserts that given condition will be met in waitFor time,
// periodically checking target function each tick.
//
// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
}
// EventuallyWithTf asserts that given condition will be met in waitFor time,
// periodically checking target function each tick. In contrast to Eventually,
// it supplies a CollectT to the condition function, so that the condition
// function can use the CollectT to call other assertions.
// The condition is considered "met" if no errors are raised in a tick.
// The supplied CollectT collects all errors from one tick (if there are any).
// If the condition is not met before waitFor, the collected errors of
// the last tick are copied to t.
//
// externalValue := false
// go func() {
// time.Sleep(8*time.Second)
// externalValue = true
// }()
// assert.EventuallyWithTf(t, func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
}
// Exactlyf asserts that two objects are equal in value and type.
//
// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// Failf reports a failure through
func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
}
// FailNowf fails test
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
}
// Falsef asserts that the specified value is false.
//
// assert.Falsef(t, myBool, "error message %s", "formatted")
func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return False(t, value, append([]interface{}{msg}, args...)...)
}
// FileExistsf checks whether a file exists in the given path. It also fails if
// the path points to a directory or there is an error when trying to check the file.
func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return FileExists(t, path, append([]interface{}{msg}, args...)...)
}
// Greaterf asserts that the first element is greater than the second
//
// assert.Greaterf(t, 2, 1, "error message %s", "formatted")
// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted")
// assert.Greaterf(t, "b", "a", "error message %s", "formatted")
func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Greater(t, e1, e2, append([]interface{}{msg}, args...)...)
}
// GreaterOrEqualf asserts that the first element is greater than or equal to the second
//
// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted")
// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted")
// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted")
// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted")
func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return GreaterOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
}
// HTTPBodyContainsf asserts that a specified handler returns a
// body that contains a string.
//
// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
}
// HTTPBodyNotContainsf asserts that a specified handler returns a
// body that does not contain a string.
//
// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...)
}
// HTTPErrorf asserts that a specified handler returns an error status code.
//
// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
}
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
//
// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
}
// HTTPStatusCodef asserts that a specified handler returns a specified status code.
//
// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPStatusCode(t, handler, method, url, values, statuscode, append([]interface{}{msg}, args...)...)
}
// HTTPSuccessf asserts that a specified handler returns a success status code.
//
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...)
}
// Implementsf asserts that an object is implemented by the specified interface.
//
// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
}
// InDeltaf asserts that the two numerals are within delta of each other.
//
// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
}
// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
}
// InDeltaSlicef is the same as InDelta, except it compares two slices.
func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
}
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
}
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
}
// IsDecreasingf asserts that the collection is decreasing
//
// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted")
// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted")
// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsDecreasing(t, object, append([]interface{}{msg}, args...)...)
}
// IsIncreasingf asserts that the collection is increasing
//
// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted")
// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted")
// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsIncreasing(t, object, append([]interface{}{msg}, args...)...)
}
// IsNonDecreasingf asserts that the collection is not decreasing
//
// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted")
// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted")
// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted")
func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsNonDecreasing(t, object, append([]interface{}{msg}, args...)...)
}
// IsNonIncreasingf asserts that the collection is not increasing
//
// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted")
// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted")
// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted")
func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsNonIncreasing(t, object, append([]interface{}{msg}, args...)...)
}
// IsNotTypef asserts that the specified objects are not of the same type.
//
// assert.IsNotTypef(t, &NotMyStruct{}, &MyStruct{}, "error message %s", "formatted")
func IsNotTypef(t TestingT, theType interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsNotType(t, theType, object, append([]interface{}{msg}, args...)...)
}
// IsTypef asserts that the specified objects are of the same type.
//
// assert.IsTypef(t, &MyStruct{}, &MyStruct{}, "error message %s", "formatted")
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
}
// JSONEqf asserts that two JSON strings are equivalent.
//
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Len(t, object, length, append([]interface{}{msg}, args...)...)
}
// Lessf asserts that the first element is less than the second
//
// assert.Lessf(t, 1, 2, "error message %s", "formatted")
// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted")
// assert.Lessf(t, "a", "b", "error message %s", "formatted")
func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Less(t, e1, e2, append([]interface{}{msg}, args...)...)
}
// LessOrEqualf asserts that the first element is less than or equal to the second
//
// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted")
// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted")
// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted")
// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted")
func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return LessOrEqual(t, e1, e2, append([]interface{}{msg}, args...)...)
}
// Negativef asserts that the specified element is negative
//
// assert.Negativef(t, -1, "error message %s", "formatted")
// assert.Negativef(t, -1.23, "error message %s", "formatted")
func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Negative(t, e, append([]interface{}{msg}, args...)...)
}
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
// periodically checking the target function each tick.
//
// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Never(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
}
// Nilf asserts that the specified object is nil.
//
// assert.Nilf(t, err, "error message %s", "formatted")
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Nil(t, object, append([]interface{}{msg}, args...)...)
}
// NoDirExistsf checks whether a directory does not exist in the given path.
// It fails if the path points to an existing _directory_ only.
func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NoDirExists(t, path, append([]interface{}{msg}, args...)...)
}
// NoErrorf asserts that a function returned a nil error (ie. no error).
//
// actualObj, err := SomeFunction()
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
// assert.Equal(t, expectedObj, actualObj)
// }
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NoError(t, err, append([]interface{}{msg}, args...)...)
}
// NoFileExistsf checks whether a file does not exist in a given path. It fails
// if the path points to an existing _file_ only.
func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NoFileExists(t, path, append([]interface{}{msg}, args...)...)
}
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
}
// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should not match.
// This is an inverse of ElementsMatch.
//
// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
//
// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
//
// assert.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
}
// NotEmptyf asserts that the specified object is NOT [Empty].
//
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
// assert.Equal(t, "two", obj[1])
// }
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
}
// NotEqualf asserts that the specified values are NOT equal.
//
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
//
// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted")
func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// NotErrorAsf asserts that none of the errors in err's chain matches target,
// but if so, sets target to that error value.
func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
}
// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...)
}
// NotImplementsf asserts that an object does not implement the specified interface.
//
// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
}
// NotNilf asserts that the specified object is not nil.
//
// assert.NotNilf(t, err, "error message %s", "formatted")
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotNil(t, object, append([]interface{}{msg}, args...)...)
}
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotPanics(t, f, append([]interface{}{msg}, args...)...)
}
// NotRegexpf asserts that a specified regexp does not match a string.
//
// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
}
// NotSamef asserts that two pointers do not reference the same object.
//
// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// NotSubsetf asserts that the list (array, slice, or map) does NOT contain all
// elements given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted")
// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
// assert.NotSubsetf(t, [1, 3, 4], {1: "one", 2: "two"}, "error message %s", "formatted")
// assert.NotSubsetf(t, {"x": 1, "y": 2}, ["z"], "error message %s", "formatted")
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
}
// NotZerof asserts that i is not the zero value for its type.
func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return NotZero(t, i, append([]interface{}{msg}, args...)...)
}
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
//
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Panics(t, f, append([]interface{}{msg}, args...)...)
}
// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
// panics, and that the recovered panic value is an error that satisfies the
// EqualError comparison.
//
// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return PanicsWithError(t, errString, f, append([]interface{}{msg}, args...)...)
}
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
}
// Positivef asserts that the specified element is positive
//
// assert.Positivef(t, 1, "error message %s", "formatted")
// assert.Positivef(t, 1.23, "error message %s", "formatted")
func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Positive(t, e, append([]interface{}{msg}, args...)...)
}
// Regexpf asserts that a specified regexp matches a string.
//
// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
}
// Samef asserts that two pointers reference the same object.
//
// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func Samef(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Same(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// Subsetf asserts that the list (array, slice, or map) contains all elements
// given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted")
// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
// assert.Subsetf(t, [1, 2, 3], {1: "one", 2: "two"}, "error message %s", "formatted")
// assert.Subsetf(t, {"x": 1, "y": 2}, ["x"], "error message %s", "formatted")
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
}
// Truef asserts that the specified value is true.
//
// assert.Truef(t, myBool, "error message %s", "formatted")
func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return True(t, value, append([]interface{}{msg}, args...)...)
}
// WithinDurationf asserts that the two times are within duration delta of each other.
//
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
}
// WithinRangef asserts that a time is within a time range (inclusive).
//
// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...)
}
// YAMLEqf asserts that the first documents in the two YAML strings are equivalent.
//
// expected := `---
// key: value
// ---
// key: this is a second document, it is not evaluated
// `
// actual := `---
// key: value
// ---
// key: this is a subsequent document, it is not evaluated
// `
// assert.YAMLEqf(t, expected, actual, "error message %s", "formatted")
func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return YAMLEq(t, expected, actual, append([]interface{}{msg}, args...)...)
}
// Zerof asserts that i is the zero value for its type.
func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Zero(t, i, append([]interface{}{msg}, args...)...)
}
================================================
FILE: assert/assertion_format.go.tmpl
================================================
{{.CommentFormat}}
func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
if h, ok := t.(tHelper); ok { h.Helper() }
return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
}
================================================
FILE: assert/assertion_forward.go
================================================
// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.
package assert
import (
http "net/http"
url "net/url"
time "time"
)
// Condition uses a Comparison to assert a complex condition.
func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Condition(a.t, comp, msgAndArgs...)
}
// Conditionf uses a Comparison to assert a complex condition.
func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Conditionf(a.t, comp, msg, args...)
}
// Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Contains("Hello World", "World")
// a.Contains(["Hello", "World"], "World")
// a.Contains({"Hello": "World"}, "Hello")
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Contains(a.t, s, contains, msgAndArgs...)
}
// Containsf asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// a.Containsf("Hello World", "World", "error message %s", "formatted")
// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Containsf(a.t, s, contains, msg, args...)
}
// DirExists checks whether a directory exists in the given path. It also fails
// if the path is a file rather a directory or there is an error checking whether it exists.
func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return DirExists(a.t, path, msgAndArgs...)
}
// DirExistsf checks whether a directory exists in the given path. It also fails
// if the path is a file rather a directory or there is an error checking whether it exists.
func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return DirExistsf(a.t, path, msg, args...)
}
// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2])
func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ElementsMatch(a.t, listA, listB, msgAndArgs...)
}
// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should match.
//
// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted")
func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ElementsMatchf(a.t, listA, listB, msg, args...)
}
// Empty asserts that the given value is "empty".
//
// [Zero values] are "empty".
//
// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
//
// Slices, maps and channels with zero length are "empty".
//
// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
//
// a.Empty(obj)
//
// [Zero values]: https://go.dev/ref/spec#The_zero_value
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Empty(a.t, object, msgAndArgs...)
}
// Emptyf asserts that the given value is "empty".
//
// [Zero values] are "empty".
//
// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
//
// Slices, maps and channels with zero length are "empty".
//
// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
//
// a.Emptyf(obj, "error message %s", "formatted")
//
// [Zero values]: https://go.dev/ref/spec#The_zero_value
func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Emptyf(a.t, object, msg, args...)
}
// Equal asserts that two objects are equal.
//
// a.Equal(123, 123)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Equal(a.t, expected, actual, msgAndArgs...)
}
// EqualError asserts that a function returned a non-nil error (i.e. an error)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualError(err, expectedErrorString)
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualError(a.t, theError, errString, msgAndArgs...)
}
// EqualErrorf asserts that a function returned a non-nil error (i.e. an error)
// and that it is equal to the provided error.
//
// actualObj, err := SomeFunction()
// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualErrorf(a.t, theError, errString, msg, args...)
}
// EqualExportedValues asserts that the types of two objects are equal and their public
// fields are also equal. This is useful for comparing structs that have private fields
// that could potentially differ.
//
// type S struct {
// Exported int
// notExported int
// }
// a.EqualExportedValues(S{1, 2}, S{1, 3}) => true
// a.EqualExportedValues(S{1, 2}, S{2, 3}) => false
func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualExportedValues(a.t, expected, actual, msgAndArgs...)
}
// EqualExportedValuesf asserts that the types of two objects are equal and their public
// fields are also equal. This is useful for comparing structs that have private fields
// that could potentially differ.
//
// type S struct {
// Exported int
// notExported int
// }
// a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
// a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
}
// EqualValues asserts that two objects are equal or convertible to the larger
// type and equal.
//
// a.EqualValues(uint32(123), int32(123))
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualValues(a.t, expected, actual, msgAndArgs...)
}
// EqualValuesf asserts that two objects are equal or convertible to the larger
// type and equal.
//
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EqualValuesf(a.t, expected, actual, msg, args...)
}
// Equalf asserts that two objects are equal.
//
// a.Equalf(123, 123, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Equalf(a.t, expected, actual, msg, args...)
}
// Error asserts that a function returned a non-nil error (ie. an error).
//
// actualObj, err := SomeFunction()
// a.Error(err)
func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Error(a.t, err, msgAndArgs...)
}
// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
// This is a wrapper for errors.As.
func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorAs(a.t, err, target, msgAndArgs...)
}
// ErrorAsf asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
// This is a wrapper for errors.As.
func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorAsf(a.t, err, target, msg, args...)
}
// ErrorContains asserts that a function returned a non-nil error (i.e. an
// error) and that the error contains the specified substring.
//
// actualObj, err := SomeFunction()
// a.ErrorContains(err, expectedErrorSubString)
func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorContains(a.t, theError, contains, msgAndArgs...)
}
// ErrorContainsf asserts that a function returned a non-nil error (i.e. an
// error) and that the error contains the specified substring.
//
// actualObj, err := SomeFunction()
// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted")
func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorContainsf(a.t, theError, contains, msg, args...)
}
// ErrorIs asserts that at least one of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorIs(a.t, err, target, msgAndArgs...)
}
// ErrorIsf asserts that at least one of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return ErrorIsf(a.t, err, target, msg, args...)
}
// Errorf asserts that a function returned a non-nil error (ie. an error).
//
// actualObj, err := SomeFunction()
// a.Errorf(err, "error message %s", "formatted")
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Errorf(a.t, err, msg, args...)
}
// Eventually asserts that given condition will be met in waitFor time,
// periodically checking target function each tick.
//
// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond)
func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
}
// EventuallyWithT asserts that given condition will be met in waitFor time,
// periodically checking target function each tick. In contrast to Eventually,
// it supplies a CollectT to the condition function, so that the condition
// function can use the CollectT to call other assertions.
// The condition is considered "met" if no errors are raised in a tick.
// The supplied CollectT collects all errors from one tick (if there are any).
// If the condition is not met before waitFor, the collected errors of
// the last tick are copied to t.
//
// externalValue := false
// go func() {
// time.Sleep(8*time.Second)
// externalValue = true
// }()
// a.EventuallyWithT(func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...)
}
// EventuallyWithTf asserts that given condition will be met in waitFor time,
// periodically checking target function each tick. In contrast to Eventually,
// it supplies a CollectT to the condition function, so that the condition
// function can use the CollectT to call other assertions.
// The condition is considered "met" if no errors are raised in a tick.
// The supplied CollectT collects all errors from one tick (if there are any).
// If the condition is not met before waitFor, the collected errors of
// the last tick are copied to t.
//
// externalValue := false
// go func() {
// time.Sleep(8*time.Second)
// externalValue = true
// }()
// a.EventuallyWithTf(func(c *assert.CollectT) {
// // add assertions as needed; any assertion failure will fail the current tick
// assert.True(c, externalValue, "expected 'externalValue' to be true")
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...)
}
// Eventuallyf asserts that given condition will be met in waitFor time,
// periodically checking target function each tick.
//
// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Eventuallyf(a.t, condition, waitFor, tick, msg, args...)
}
// Exactly asserts that two objects are equal in value and type.
//
// a.Exactly(int32(123), int64(123))
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Exactly(a.t, expected, actual, msgAndArgs...)
}
// Exactlyf asserts that two objects are equal in value and type.
//
// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted")
func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Exactlyf(a.t, expected, actual, msg, args...)
}
// Fail reports a failure through
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Fail(a.t, failureMessage, msgAndArgs...)
}
// FailNow fails test
func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return FailNow(a.t, failureMessage, msgAndArgs...)
}
// FailNowf fails test
func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return FailNowf(a.t, failureMessage, msg, args...)
}
// Failf reports a failure through
func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Failf(a.t, failureMessage, msg, args...)
}
// False asserts that the specified value is false.
//
// a.False(myBool)
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return False(a.t, value, msgAndArgs...)
}
// Falsef asserts that the specified value is false.
//
// a.Falsef(myBool, "error message %s", "formatted")
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Falsef(a.t, value, msg, args...)
}
// FileExists checks whether a file exists in the given path. It also fails if
// the path points to a directory or there is an error when trying to check the file.
func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return FileExists(a.t, path, msgAndArgs...)
}
// FileExistsf checks whether a file exists in the given path. It also fails if
// the path points to a directory or there is an error when trying to check the file.
func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return FileExistsf(a.t, path, msg, args...)
}
// Greater asserts that the first element is greater than the second
//
// a.Greater(2, 1)
// a.Greater(float64(2), float64(1))
// a.Greater("b", "a")
func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Greater(a.t, e1, e2, msgAndArgs...)
}
// GreaterOrEqual asserts that the first element is greater than or equal to the second
//
// a.GreaterOrEqual(2, 1)
// a.GreaterOrEqual(2, 2)
// a.GreaterOrEqual("b", "a")
// a.GreaterOrEqual("b", "b")
func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return GreaterOrEqual(a.t, e1, e2, msgAndArgs...)
}
// GreaterOrEqualf asserts that the first element is greater than or equal to the second
//
// a.GreaterOrEqualf(2, 1, "error message %s", "formatted")
// a.GreaterOrEqualf(2, 2, "error message %s", "formatted")
// a.GreaterOrEqualf("b", "a", "error message %s", "formatted")
// a.GreaterOrEqualf("b", "b", "error message %s", "formatted")
func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return GreaterOrEqualf(a.t, e1, e2, msg, args...)
}
// Greaterf asserts that the first element is greater than the second
//
// a.Greaterf(2, 1, "error message %s", "formatted")
// a.Greaterf(float64(2), float64(1), "error message %s", "formatted")
// a.Greaterf("b", "a", "error message %s", "formatted")
func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Greaterf(a.t, e1, e2, msg, args...)
}
// HTTPBodyContains asserts that a specified handler returns a
// body that contains a string.
//
// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...)
}
// HTTPBodyContainsf asserts that a specified handler returns a
// body that contains a string.
//
// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...)
}
// HTTPBodyNotContains asserts that a specified handler returns a
// body that does not contain a string.
//
// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...)
}
// HTTPBodyNotContainsf asserts that a specified handler returns a
// body that does not contain a string.
//
// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...)
}
// HTTPError asserts that a specified handler returns an error status code.
//
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPError(a.t, handler, method, url, values, msgAndArgs...)
}
// HTTPErrorf asserts that a specified handler returns an error status code.
//
// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPErrorf(a.t, handler, method, url, values, msg, args...)
}
// HTTPRedirect asserts that a specified handler returns a redirect status code.
//
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...)
}
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
//
// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPRedirectf(a.t, handler, method, url, values, msg, args...)
}
// HTTPStatusCode asserts that a specified handler returns a specified status code.
//
// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501)
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPStatusCode(a.t, handler, method, url, values, statuscode, msgAndArgs...)
}
// HTTPStatusCodef asserts that a specified handler returns a specified status code.
//
// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPStatusCodef(a.t, handler, method, url, values, statuscode, msg, args...)
}
// HTTPSuccess asserts that a specified handler returns a success status code.
//
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...)
}
// HTTPSuccessf asserts that a specified handler returns a success status code.
//
// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
//
// Returns whether the assertion was successful (true) or not (false).
func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return HTTPSuccessf(a.t, handler, method, url, values, msg, args...)
}
// Implements asserts that an object is implemented by the specified interface.
//
// a.Implements((*MyInterface)(nil), new(MyObject))
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Implements(a.t, interfaceObject, object, msgAndArgs...)
}
// Implementsf asserts that an object is implemented by the specified interface.
//
// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Implementsf(a.t, interfaceObject, object, msg, args...)
}
// InDelta asserts that the two numerals are within delta of each other.
//
// a.InDelta(math.Pi, 22/7.0, 0.01)
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDelta(a.t, expected, actual, delta, msgAndArgs...)
}
// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...)
}
// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys.
func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...)
}
// InDeltaSlice is the same as InDelta, except it compares two slices.
func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
}
// InDeltaSlicef is the same as InDelta, except it compares two slices.
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
}
// InDeltaf asserts that the two numerals are within delta of each other.
//
// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted")
func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InDeltaf(a.t, expected, actual, delta, msg, args...)
}
// InEpsilon asserts that expected and actual have a relative error less than epsilon
func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
}
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
}
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
}
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
}
// IsDecreasing asserts that the collection is decreasing
//
// a.IsDecreasing([]int{2, 1, 0})
// a.IsDecreasing([]float{2, 1})
// a.IsDecreasing([]string{"b", "a"})
func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsDecreasing(a.t, object, msgAndArgs...)
}
// IsDecreasingf asserts that the collection is decreasing
//
// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted")
// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted")
// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted")
func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsDecreasingf(a.t, object, msg, args...)
}
// IsIncreasing asserts that the collection is increasing
//
// a.IsIncreasing([]int{1, 2, 3})
// a.IsIncreasing([]float{1, 2})
// a.IsIncreasing([]string{"a", "b"})
func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsIncreasing(a.t, object, msgAndArgs...)
}
// IsIncreasingf asserts that the collection is increasing
//
// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted")
// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted")
// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted")
func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsIncreasingf(a.t, object, msg, args...)
}
// IsNonDecreasing asserts that the collection is not decreasing
//
// a.IsNonDecreasing([]int{1, 1, 2})
// a.IsNonDecreasing([]float{1, 2})
// a.IsNonDecreasing([]string{"a", "b"})
func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNonDecreasing(a.t, object, msgAndArgs...)
}
// IsNonDecreasingf asserts that the collection is not decreasing
//
// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted")
// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted")
// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted")
func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNonDecreasingf(a.t, object, msg, args...)
}
// IsNonIncreasing asserts that the collection is not increasing
//
// a.IsNonIncreasing([]int{2, 1, 1})
// a.IsNonIncreasing([]float{2, 1})
// a.IsNonIncreasing([]string{"b", "a"})
func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNonIncreasing(a.t, object, msgAndArgs...)
}
// IsNonIncreasingf asserts that the collection is not increasing
//
// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted")
// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted")
// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted")
func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNonIncreasingf(a.t, object, msg, args...)
}
// IsNotType asserts that the specified objects are not of the same type.
//
// a.IsNotType(&NotMyStruct{}, &MyStruct{})
func (a *Assertions) IsNotType(theType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNotType(a.t, theType, object, msgAndArgs...)
}
// IsNotTypef asserts that the specified objects are not of the same type.
//
// a.IsNotTypef(&NotMyStruct{}, &MyStruct{}, "error message %s", "formatted")
func (a *Assertions) IsNotTypef(theType interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsNotTypef(a.t, theType, object, msg, args...)
}
// IsType asserts that the specified objects are of the same type.
//
// a.IsType(&MyStruct{}, &MyStruct{})
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsType(a.t, expectedType, object, msgAndArgs...)
}
// IsTypef asserts that the specified objects are of the same type.
//
// a.IsTypef(&MyStruct{}, &MyStruct{}, "error message %s", "formatted")
func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return IsTypef(a.t, expectedType, object, msg, args...)
}
// JSONEq asserts that two JSON strings are equivalent.
//
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return JSONEq(a.t, expected, actual, msgAndArgs...)
}
// JSONEqf asserts that two JSON strings are equivalent.
//
// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return JSONEqf(a.t, expected, actual, msg, args...)
}
// Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept.
//
// a.Len(mySlice, 3)
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Len(a.t, object, length, msgAndArgs...)
}
// Lenf asserts that the specified object has specific length.
// Lenf also fails if the object has a type that len() not accept.
//
// a.Lenf(mySlice, 3, "error message %s", "formatted")
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Lenf(a.t, object, length, msg, args...)
}
// Less asserts that the first element is less than the second
//
// a.Less(1, 2)
// a.Less(float64(1), float64(2))
// a.Less("a", "b")
func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Less(a.t, e1, e2, msgAndArgs...)
}
// LessOrEqual asserts that the first element is less than or equal to the second
//
// a.LessOrEqual(1, 2)
// a.LessOrEqual(2, 2)
// a.LessOrEqual("a", "b")
// a.LessOrEqual("b", "b")
func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return LessOrEqual(a.t, e1, e2, msgAndArgs...)
}
// LessOrEqualf asserts that the first element is less than or equal to the second
//
// a.LessOrEqualf(1, 2, "error message %s", "formatted")
// a.LessOrEqualf(2, 2, "error message %s", "formatted")
// a.LessOrEqualf("a", "b", "error message %s", "formatted")
// a.LessOrEqualf("b", "b", "error message %s", "formatted")
func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return LessOrEqualf(a.t, e1, e2, msg, args...)
}
// Lessf asserts that the first element is less than the second
//
// a.Lessf(1, 2, "error message %s", "formatted")
// a.Lessf(float64(1), float64(2), "error message %s", "formatted")
// a.Lessf("a", "b", "error message %s", "formatted")
func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Lessf(a.t, e1, e2, msg, args...)
}
// Negative asserts that the specified element is negative
//
// a.Negative(-1)
// a.Negative(-1.23)
func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Negative(a.t, e, msgAndArgs...)
}
// Negativef asserts that the specified element is negative
//
// a.Negativef(-1, "error message %s", "formatted")
// a.Negativef(-1.23, "error message %s", "formatted")
func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Negativef(a.t, e, msg, args...)
}
// Never asserts that the given condition doesn't satisfy in waitFor time,
// periodically checking the target function each tick.
//
// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond)
func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Never(a.t, condition, waitFor, tick, msgAndArgs...)
}
// Neverf asserts that the given condition doesn't satisfy in waitFor time,
// periodically checking the target function each tick.
//
// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted")
func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Neverf(a.t, condition, waitFor, tick, msg, args...)
}
// Nil asserts that the specified object is nil.
//
// a.Nil(err)
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Nil(a.t, object, msgAndArgs...)
}
// Nilf asserts that the specified object is nil.
//
// a.Nilf(err, "error message %s", "formatted")
func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Nilf(a.t, object, msg, args...)
}
// NoDirExists checks whether a directory does not exist in the given path.
// It fails if the path points to an existing _directory_ only.
func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoDirExists(a.t, path, msgAndArgs...)
}
// NoDirExistsf checks whether a directory does not exist in the given path.
// It fails if the path points to an existing _directory_ only.
func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoDirExistsf(a.t, path, msg, args...)
}
// NoError asserts that a function returned a nil error (ie. no error).
//
// actualObj, err := SomeFunction()
// if a.NoError(err) {
// assert.Equal(t, expectedObj, actualObj)
// }
func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoError(a.t, err, msgAndArgs...)
}
// NoErrorf asserts that a function returned a nil error (ie. no error).
//
// actualObj, err := SomeFunction()
// if a.NoErrorf(err, "error message %s", "formatted") {
// assert.Equal(t, expectedObj, actualObj)
// }
func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoErrorf(a.t, err, msg, args...)
}
// NoFileExists checks whether a file does not exist in a given path. It fails
// if the path points to an existing _file_ only.
func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoFileExists(a.t, path, msgAndArgs...)
}
// NoFileExistsf checks whether a file does not exist in a given path. It fails
// if the path points to an existing _file_ only.
func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NoFileExistsf(a.t, path, msg, args...)
}
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// a.NotContains("Hello World", "Earth")
// a.NotContains(["Hello", "World"], "Earth")
// a.NotContains({"Hello": "World"}, "Earth")
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotContains(a.t, s, contains, msgAndArgs...)
}
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotContainsf(a.t, s, contains, msg, args...)
}
// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should not match.
// This is an inverse of ElementsMatch.
//
// a.NotElementsMatch([1, 1, 2, 3], [1, 1, 2, 3]) -> false
//
// a.NotElementsMatch([1, 1, 2, 3], [1, 2, 3]) -> true
//
// a.NotElementsMatch([1, 2, 3], [1, 2, 4]) -> true
func (a *Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotElementsMatch(a.t, listA, listB, msgAndArgs...)
}
// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
// the number of appearances of each of them in both lists should not match.
// This is an inverse of ElementsMatch.
//
// a.NotElementsMatchf([1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
//
// a.NotElementsMatchf([1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
//
// a.NotElementsMatchf([1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotElementsMatchf(a.t, listA, listB, msg, args...)
}
// NotEmpty asserts that the specified object is NOT [Empty].
//
// if a.NotEmpty(obj) {
// assert.Equal(t, "two", obj[1])
// }
func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEmpty(a.t, object, msgAndArgs...)
}
// NotEmptyf asserts that the specified object is NOT [Empty].
//
// if a.NotEmptyf(obj, "error message %s", "formatted") {
// assert.Equal(t, "two", obj[1])
// }
func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEmptyf(a.t, object, msg, args...)
}
// NotEqual asserts that the specified values are NOT equal.
//
// a.NotEqual(obj1, obj2)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEqual(a.t, expected, actual, msgAndArgs...)
}
// NotEqualValues asserts that two objects are not equal even when converted to the same type
//
// a.NotEqualValues(obj1, obj2)
func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEqualValues(a.t, expected, actual, msgAndArgs...)
}
// NotEqualValuesf asserts that two objects are not equal even when converted to the same type
//
// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted")
func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEqualValuesf(a.t, expected, actual, msg, args...)
}
// NotEqualf asserts that the specified values are NOT equal.
//
// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotEqualf(a.t, expected, actual, msg, args...)
}
// NotErrorAs asserts that none of the errors in err's chain matches target,
// but if so, sets target to that error value.
func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotErrorAs(a.t, err, target, msgAndArgs...)
}
// NotErrorAsf asserts that none of the errors in err's chain matches target,
// but if so, sets target to that error value.
func (a *Assertions) NotErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotErrorAsf(a.t, err, target, msg, args...)
}
// NotErrorIs asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotErrorIs(a.t, err, target, msgAndArgs...)
}
// NotErrorIsf asserts that none of the errors in err's chain matches target.
// This is a wrapper for errors.Is.
func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotErrorIsf(a.t, err, target, msg, args...)
}
// NotImplements asserts that an object does not implement the specified interface.
//
// a.NotImplements((*MyInterface)(nil), new(MyObject))
func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotImplements(a.t, interfaceObject, object, msgAndArgs...)
}
// NotImplementsf asserts that an object does not implement the specified interface.
//
// a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted")
func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotImplementsf(a.t, interfaceObject, object, msg, args...)
}
// NotNil asserts that the specified object is not nil.
//
// a.NotNil(err)
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotNil(a.t, object, msgAndArgs...)
}
// NotNilf asserts that the specified object is not nil.
//
// a.NotNilf(err, "error message %s", "formatted")
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotNilf(a.t, object, msg, args...)
}
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// a.NotPanics(func(){ RemainCalm() })
func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotPanics(a.t, f, msgAndArgs...)
}
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
//
// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotPanicsf(a.t, f, msg, args...)
}
// NotRegexp asserts that a specified regexp does not match a string.
//
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
// a.NotRegexp("^start", "it's not starting")
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotRegexp(a.t, rx, str, msgAndArgs...)
}
// NotRegexpf asserts that a specified regexp does not match a string.
//
// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted")
// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotRegexpf(a.t, rx, str, msg, args...)
}
// NotSame asserts that two pointers do not reference the same object.
//
// a.NotSame(ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotSame(a.t, expected, actual, msgAndArgs...)
}
// NotSamef asserts that two pointers do not reference the same object.
//
// a.NotSamef(ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotSamef(a.t, expected, actual, msg, args...)
}
// NotSubset asserts that the list (array, slice, or map) does NOT contain all
// elements given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// a.NotSubset([1, 3, 4], [1, 2])
// a.NotSubset({"x": 1, "y": 2}, {"z": 3})
// a.NotSubset([1, 3, 4], {1: "one", 2: "two"})
// a.NotSubset({"x": 1, "y": 2}, ["z"])
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotSubset(a.t, list, subset, msgAndArgs...)
}
// NotSubsetf asserts that the list (array, slice, or map) does NOT contain all
// elements given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted")
// a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted")
// a.NotSubsetf([1, 3, 4], {1: "one", 2: "two"}, "error message %s", "formatted")
// a.NotSubsetf({"x": 1, "y": 2}, ["z"], "error message %s", "formatted")
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotSubsetf(a.t, list, subset, msg, args...)
}
// NotZero asserts that i is not the zero value for its type.
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotZero(a.t, i, msgAndArgs...)
}
// NotZerof asserts that i is not the zero value for its type.
func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return NotZerof(a.t, i, msg, args...)
}
// Panics asserts that the code inside the specified PanicTestFunc panics.
//
// a.Panics(func(){ GoCrazy() })
func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Panics(a.t, f, msgAndArgs...)
}
// PanicsWithError asserts that the code inside the specified PanicTestFunc
// panics, and that the recovered panic value is an error that satisfies the
// EqualError comparison.
//
// a.PanicsWithError("crazy error", func(){ GoCrazy() })
func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return PanicsWithError(a.t, errString, f, msgAndArgs...)
}
// PanicsWithErrorf asserts that the code inside the specified PanicTestFunc
// panics, and that the recovered panic value is an error that satisfies the
// EqualError comparison.
//
// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return PanicsWithErrorf(a.t, errString, f, msg, args...)
}
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return PanicsWithValue(a.t, expected, f, msgAndArgs...)
}
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
// the recovered panic value equals the expected panic value.
//
// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return PanicsWithValuef(a.t, expected, f, msg, args...)
}
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
//
// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Panicsf(a.t, f, msg, args...)
}
// Positive asserts that the specified element is positive
//
// a.Positive(1)
// a.Positive(1.23)
func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Positive(a.t, e, msgAndArgs...)
}
// Positivef asserts that the specified element is positive
//
// a.Positivef(1, "error message %s", "formatted")
// a.Positivef(1.23, "error message %s", "formatted")
func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Positivef(a.t, e, msg, args...)
}
// Regexp asserts that a specified regexp matches a string.
//
// a.Regexp(regexp.MustCompile("start"), "it's starting")
// a.Regexp("start...$", "it's not starting")
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Regexp(a.t, rx, str, msgAndArgs...)
}
// Regexpf asserts that a specified regexp matches a string.
//
// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted")
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Regexpf(a.t, rx, str, msg, args...)
}
// Same asserts that two pointers reference the same object.
//
// a.Same(ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Same(a.t, expected, actual, msgAndArgs...)
}
// Samef asserts that two pointers reference the same object.
//
// a.Samef(ptr1, ptr2, "error message %s", "formatted")
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Samef(a.t, expected, actual, msg, args...)
}
// Subset asserts that the list (array, slice, or map) contains all elements
// given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// a.Subset([1, 2, 3], [1, 2])
// a.Subset({"x": 1, "y": 2}, {"x": 1})
// a.Subset([1, 2, 3], {1: "one", 2: "two"})
// a.Subset({"x": 1, "y": 2}, ["x"])
func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Subset(a.t, list, subset, msgAndArgs...)
}
// Subsetf asserts that the list (array, slice, or map) contains all elements
// given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted")
// a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted")
// a.Subsetf([1, 2, 3], {1: "one", 2: "two"}, "error message %s", "formatted")
// a.Subsetf({"x": 1, "y": 2}, ["x"], "error message %s", "formatted")
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Subsetf(a.t, list, subset, msg, args...)
}
// True asserts that the specified value is true.
//
// a.True(myBool)
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return True(a.t, value, msgAndArgs...)
}
// Truef asserts that the specified value is true.
//
// a.Truef(myBool, "error message %s", "formatted")
func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Truef(a.t, value, msg, args...)
}
// WithinDuration asserts that the two times are within duration delta of each other.
//
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
}
// WithinDurationf asserts that the two times are within duration delta of each other.
//
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return WithinDurationf(a.t, expected, actual, delta, msg, args...)
}
// WithinRange asserts that a time is within a time range (inclusive).
//
// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second))
func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return WithinRange(a.t, actual, start, end, msgAndArgs...)
}
// WithinRangef asserts that a time is within a time range (inclusive).
//
// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted")
func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return WithinRangef(a.t, actual, start, end, msg, args...)
}
// YAMLEq asserts that the first documents in the two YAML strings are equivalent.
//
// expected := `---
// key: value
// ---
// key: this is a second document, it is not evaluated
// `
// actual := `---
// key: value
// ---
// key: this is a subsequent document, it is not evaluated
// `
// a.YAMLEq(expected, actual)
func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return YAMLEq(a.t, expected, actual, msgAndArgs...)
}
// YAMLEqf asserts that the first documents in the two YAML strings are equivalent.
//
// expected := `---
// key: value
// ---
// key: this is a second document, it is not evaluated
// `
// actual := `---
// key: value
// ---
// key: this is a subsequent document, it is not evaluated
// `
// a.YAMLEqf(expected, actual, "error message %s", "formatted")
func (a *Assertions) YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return YAMLEqf(a.t, expected, actual, msg, args...)
}
// Zero asserts that i is the zero value for its type.
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Zero(a.t, i, msgAndArgs...)
}
// Zerof asserts that i is the zero value for its type.
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
if h, ok := a.t.(tHelper); ok {
h.Helper()
}
return Zerof(a.t, i, msg, args...)
}
================================================
FILE: assert/assertion_forward.go.tmpl
================================================
{{.CommentWithoutT "a"}}
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
if h, ok := a.t.(tHelper); ok { h.Helper() }
return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
}
================================================
FILE: assert/assertion_order.go
================================================
package assert
import (
"fmt"
"reflect"
)
// isOrdered checks that collection contains orderable elements.
func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, 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 an ordered collection", object), msgAndArgs...)
}
objValue := reflect.ValueOf(object)
objLen := objValue.Len()
if objLen <= 1 {
return true
}
value := objValue.Index(0)
valueInterface := value.Interface()
firstValueKind := value.Kind()
for i := 1; i < objLen; i++ {
prevValue := value
prevValueInterface := valueInterface
value = objValue.Index(i)
valueInterface = value.Interface()
compareResult, isComparable := compare(prevValueInterface, valueInterface, firstValueKind)
if !isComparable {
return Fail(t, fmt.Sprintf(`Can not compare type "%T" and "%T"`, value, prevValue), msgAndArgs...)
}
if !containsValue(allowedComparesResults, compareResult) {
return Fail(t, fmt.Sprintf(failMessage, prevValue, value), msgAndArgs...)
}
}
return true
}
// IsIncreasing asserts that the collection is increasing
//
// assert.IsIncreasing(t, []int{1, 2, 3})
// assert.IsIncreasing(t, []float{1, 2})
// assert.IsIncreasing(t, []string{"a", "b"})
func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
}
// IsNonIncreasing asserts that the collection is not increasing
//
// assert.IsNonIncreasing(t, []int{2, 1, 1})
// assert.IsNonIncreasing(t, []float{2, 1})
// assert.IsNonIncreasing(t, []string{"b", "a"})
func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
}
// IsDecreasing asserts that the collection is decreasing
//
// assert.IsDecreasing(t, []int{2, 1, 0})
// assert.IsDecreasing(t, []float{2, 1})
// assert.IsDecreasing(t, []string{"b", "a"})
func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
}
// IsNonDecreasing asserts that the collection is not decreasing
//
// assert.IsNonDecreasing(t, []int{1, 1, 2})
// assert.IsNonDecreasing(t, []float{1, 2})
// assert.IsNonDecreasing(t, []string{"a", "b"})
func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
}
================================================
FILE: assert/assertion_order_test.go
================================================
package assert
import (
"bytes"
"fmt"
"testing"
)
func TestIsIncreasing(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !IsIncreasing(mockT, []int{1, 2}) {
t.Error("IsIncreasing should return true")
}
if !IsIncreasing(mockT, []int{1, 2, 3, 4, 5}) {
t.Error("IsIncreasing should return true")
}
if IsIncreasing(mockT, []int{1, 1}) {
t.Error("IsIncreasing should return false")
}
if IsIncreasing(mockT, []int{2, 1}) {
t.Error("IsIncreasing should return false")
}
// Check error report
for _, currCase := range []struct {
collection interface{}
msg string
}{
{collection: []string{"b", "a"}, msg: `"b" is not less than "a"`},
{collection: []int{2, 1}, msg: `"2" is not less than "1"`},
{collection: []int{2, 1, 3, 4, 5, 6, 7}, msg: `"2" is not less than "1"`},
{collection: []int{-1, 0, 2, 1}, msg: `"2" is not less than "1"`},
{collection: []int8{2, 1}, msg: `"2" is not less than "1"`},
{collection: []int16{2, 1}, msg: `"2" is not less than "1"`},
{collection: []int32{2, 1}, msg: `"2" is not less than "1"`},
{collection: []int64{2, 1}, msg: `"2" is not less than "1"`},
{collection: []uint8{2, 1}, msg: `"2" is not less than "1"`},
{collection: []uint16{2, 1}, msg: `"2" is not less than "1"`},
{collection: []uint32{2, 1}, msg: `"2" is not less than "1"`},
{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 an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsIncreasing(out, currCase.collection))
Contains(t, out.buf.String(), currCase.msg)
})
}
}
func TestIsNonIncreasing(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !IsNonIncreasing(mockT, []int{2, 1}) {
t.Error("IsNonIncreasing should return true")
}
if !IsNonIncreasing(mockT, []int{5, 4, 4, 3, 2, 1}) {
t.Error("IsNonIncreasing should return true")
}
if !IsNonIncreasing(mockT, []int{1, 1}) {
t.Error("IsNonIncreasing should return true")
}
if IsNonIncreasing(mockT, []int{1, 2}) {
t.Error("IsNonIncreasing should return false")
}
// Check error report
for _, currCase := range []struct {
collection interface{}
msg string
}{
{collection: []string{"a", "b"}, msg: `"a" is not greater than or equal to "b"`},
{collection: []int{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int{1, 2, 7, 6, 5, 4, 3}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int{5, 4, 3, 1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int8{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int16{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int32{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []int64{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []uint8{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []uint16{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{collection: []uint32{1, 2}, msg: `"1" is not greater than or equal to "2"`},
{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 an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsNonIncreasing(out, currCase.collection))
Contains(t, out.buf.String(), currCase.msg)
})
}
}
func TestIsDecreasing(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !IsDecreasing(mockT, []int{2, 1}) {
t.Error("IsDecreasing should return true")
}
if !IsDecreasing(mockT, []int{5, 4, 3, 2, 1}) {
t.Error("IsDecreasing should return true")
}
if IsDecreasing(mockT, []int{1, 1}) {
t.Error("IsDecreasing should return false")
}
if IsDecreasing(mockT, []int{1, 2}) {
t.Error("IsDecreasing should return false")
}
// Check error report
for _, currCase := range []struct {
collection interface{}
msg string
}{
{collection: []string{"a", "b"}, msg: `"a" is not greater than "b"`},
{collection: []int{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []int{1, 2, 7, 6, 5, 4, 3}, msg: `"1" is not greater than "2"`},
{collection: []int{5, 4, 3, 1, 2}, msg: `"1" is not greater than "2"`},
{collection: []int8{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []int16{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []int32{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []int64{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []uint8{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []uint16{1, 2}, msg: `"1" is not greater than "2"`},
{collection: []uint32{1, 2}, msg: `"1" is not greater than "2"`},
{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 an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsDecreasing(out, currCase.collection))
Contains(t, out.buf.String(), currCase.msg)
})
}
}
func TestIsNonDecreasing(t *testing.T) {
t.Parallel()
mockT := new(testing.T)
if !IsNonDecreasing(mockT, []int{1, 2}) {
t.Error("IsNonDecreasing should return true")
}
if !IsNonDecreasing(mockT, []int{1, 1, 2, 3, 4, 5}) {
t.Error("IsNonDecreasing should return true")
}
if !IsNonDecreasing(mockT, []int{1, 1}) {
t.Error("IsNonDecreasing should return false")
}
if IsNonDecreasing(mockT, []int{2, 1}) {
t.Error("IsNonDecreasing should return false")
}
// Check error report
for _, currCase := range []struct {
collection interface{}
msg string
}{
{collection: []string{"b", "a"}, msg: `"b" is not less than or equal to "a"`},
{collection: []int{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []int{2, 1, 3, 4, 5, 6, 7}, msg: `"2" is not less than or equal to "1"`},
{collection: []int{-1, 0, 2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []int8{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []int16{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []int32{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []int64{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []uint8{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []uint16{2, 1}, msg: `"2" is not less than or equal to "1"`},
{collection: []uint32{2, 1}, msg: `"2" is not less than or equal to "1"`},
{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 an ordered collection`},
} {
t.Run(fmt.Sprintf("%#v", currCase.collection), func(t *testing.T) {
out := &outputT{buf: bytes.NewBuffer(nil)}
False(t, IsNonDecreasing(out, currCase.collection))
Contains(t, out.buf.String(), currCase.msg)
})
}
}
func TestOrderingMsgAndArgsForwarding(t *testing.T) {
t.Parallel()
msgAndArgs := []interface{}{"format %s %x", "this", 0xc001}
expectedOutput := "format this c001\n"
collection := []int{1, 2, 1}
funcs := []func(t TestingT){
func(t TestingT) { IsIncreasing(t, collection, msgAndArgs...) },
func(t TestingT) { IsNonIncreasing(t, collection, msgAndArgs...) },
func(t TestingT) { IsDecreasing(t, collection, msgAndArgs...) },
func(t TestingT) { IsNonDecreasing(t, collection, msgAndArgs...) },
}
for _, f := range funcs {
out := &outputT{buf: bytes.NewBuffer(nil)}
f(out)
Contains(t, out.buf.String(), expectedOutput)
}
}
================================================
FILE: assert/assertions.go
================================================
package assert
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"math"
"os"
"reflect"
"regexp"
"runtime"
"runtime/debug"
"strings"
"time"
"unicode"
"unicode/utf8"
// Wrapper around gopkg.in/yaml.v3
"github.com/stretchr/testify/assert/yaml"
"github.com/stretchr/testify/internal/difflib"
"github.com/stretchr/testify/internal/spew"
)
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
// TestingT is an interface wrapper around *testing.T
type TestingT interface {
Errorf(format string, args ...interface{})
}
// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
// for table driven tests.
type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool
// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
// for table driven tests.
type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool
// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
// for table driven tests.
type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool
// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
// for table driven tests.
type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool
// PanicAssertionFunc is a common function prototype when validating a panic value. Can be useful
// for table driven tests.
type PanicAssertionFunc = func(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool
// Comparison is a custom function that returns true on success and false on failure
type Comparison func() (success bool)
/*
Helper functions
*/
// ObjectsAreEqual determines if two objects are considered equal.
//
// This function does no assertion of any kind.
func ObjectsAreEqual(expected, actual interface{}) bool {
if expected == nil || actual == nil {
return expected == actual
}
exp, ok := expected.([]byte)
if !ok {
return reflect.DeepEqual(expected, actual)
}
act, ok := actual.([]byte)
if !ok {
return false
}
if exp == nil || act == nil {
return exp == nil && act == nil
}
return bytes.Equal(exp, act)
}
// copyExportedFields iterates downward through nested data structures and creates a copy
// that only contains the exported struct fields.
func copyExportedFields(expected interface{}) interface{} {
if isNil(expected) {
return expected
}
expectedType := reflect.TypeOf(expected)
expectedKind := expectedType.Kind()
expectedValue := reflect.ValueOf(expected)
switch expectedKind {
case reflect.Struct:
result := reflect.New(expectedType).Elem()
for i := 0; i < expectedType.NumField(); i++ {
field := expectedType.Field(i)
isExported := field.IsExported()
if isExported {
fieldValue := expectedValue.Field(i)
if isNil(fieldValue) || isNil(fieldValue.Interface()) {
continue
}
newValue := copyExportedFields(fieldValue.Interface())
result.Field(i).Set(reflect.ValueOf(newValue))
}
}
return result.Interface()
case reflect.Ptr:
result := reflect.New(expectedType.Elem())
unexportedRemoved := copyExportedFields(expectedValue.Elem().Interface())
result.Elem().Set(reflect.ValueOf(unexportedRemoved))
return result.Interface()
case reflect.Array, reflect.Slice:
var result reflect.Value
if expectedKind == reflect.Array {
result = reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem()
} else {
result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
}
for i := 0; i < expectedValue.Len(); i++ {
index := expectedValue.Index(i)
if isNil(index) {
continue
}
unexportedRemoved := copyExportedFields(index.Interface())
result.Index(i).Set(reflect.ValueOf(unexportedRemoved))
}
return result.Interface()
case reflect.Map:
result := reflect.MakeMap(expectedType)
for _, k := range expectedValue.MapKeys() {
index := expectedValue.MapIndex(k)
unexportedRemoved := copyExportedFields(index.Interface())
result.SetMapIndex(k, reflect.ValueOf(unexportedRemoved))
}
return result.Interface()
default:
return expected
}
}
// ObjectsExportedFieldsAreEqual determines if the exported (public) fields of two objects are
// considered equal. This comparison of only exported fields is applied recursively to nested data
// structures.
//
// This function does no assertion of any kind.
//
// Deprecated: Use [EqualExportedValues] instead.
func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool {
expectedCleaned := copyExportedFields(expected)
actualCleaned := copyExportedFields(actual)
return ObjectsAreEqualValues(expectedCleaned, actualCleaned)
}
// ObjectsAreEqualValues gets whether two objects are equal, or if their
// values are equal.
func ObjectsAreEqualValues(expected, actual interface{}) bool {
if ObjectsAreEqual(expected, actual) {
return true
}
expectedValue := reflect.ValueOf(expected)
actualValue := reflect.ValueOf(actual)
if !expectedValue.IsValid() || !actualValue.IsValid() {
return false
}
expectedType := expectedValue.Type()
actualType := actualValue.Type()
if !expectedType.ConvertibleTo(actualType) {
return false
}
if !isNumericType(expectedType) || !isNumericType(actualType) {
// Attempt comparison after type conversion
return reflect.DeepEqual(
expectedValue.Convert(actualType).Interface(), actual,
)
}
// If BOTH values are numeric, there are chances of false positives due
// to overflow or underflow. So, we need to make sure to always convert
// the smaller type to a larger type before comparing.
if expectedType.Size() >= actualType.Size() {
return actualValue.Convert(expectedType).Interface() == expected
}
return expectedValue.Convert(actualType).Interface() == actual
}
// isNumericType returns true if the type is one of:
// int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64,
// float32, float64, complex64, complex128
func isNumericType(t reflect.Type) bool {
return t.Kind() >= reflect.Int && t.Kind() <= reflect.Complex128
}
/* CallerInfo is necessary because the assert functions use the testing object
internally, causing it to print the file:line of the assert method, rather than where
the problem actually occurred in calling code.*/
// CallerInfo returns an array of strings containing the file and line number
// of each stack frame leading from the current test to the assert call that
// failed.
func CallerInfo() []string {
var pc uintptr
var file string
var line int
var name string
const stackFrameBufferSize = 10
pcs := make([]uintptr, stackFrameBufferSize)
callers := []string{}
offset := 1
for {
n := runtime.Callers(offset, pcs)
if n == 0 {
break
}
frames := runtime.CallersFrames(pcs[:n])
for {
frame, more := frames.Next()
pc = frame.PC
file = frame.File
line = frame.Line
// This is a huge edge case, but it will panic if this is the case, see #180
if file == "<autogenerated>" {
break
}
f := runtime.FuncForPC(pc)
if f == nil {
break
}
name = f.Name()
// testing.tRunner is the standard library function that calls
// tests. Subtests are called directly by tRunner, without going through
// the Test/Benchmark/Example function that contains the t.Run calls, so
// with subtests we should break when we hit tRunner, without adding it
// to the list of callers.
if name == "testing.tRunner" {
break
}
parts := strings.Split(file, "/")
if len(parts) > 1 {
filename := parts[len(parts)-1]
dir := parts[len(parts)-2]
if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" {
callers = append(callers, fmt.Sprintf("%s:%d", file, line))
}
}
// Drop the package
dotPos := strings.LastIndexByte(name, '.')
name = name[dotPos+1:]
if isTest(name, "Test") ||
isTest(name, "Benchmark") ||
isTest(name, "Example") {
break
}
if !more {
break
}
}
// Next batch
offset += cap(pcs)
}
return callers
}
// Stolen from the `go test` tool.
// isTest tells whether name looks like a test (or benchmark, according to prefix).
// It is a Test (say) if there is a character after Test that is not a lower-case letter.
// We don't want TesticularCancer.
func isTest(name, prefix string) bool {
if !strings.HasPrefix(name, prefix) {
return false
}
if len(name) == len(prefix) { // "Test" is ok
return true
}
r, _ := utf8.DecodeRuneInString(name[len(prefix):])
return !unicode.IsLower(r)
}
func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
if len(msgAndArgs) == 0 || msgAndArgs == nil {
return ""
}
if len(msgAndArgs) == 1 {
msg := msgAndArgs[0]
if msgAsStr, ok := msg.(string); ok {
return msgAsStr
}
return fmt.Sprintf("%+v", msg)
}
if len(msgAndArgs) > 1 {
return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
}
return ""
}
// Aligns the provided message so that all lines after the first line start at the same location as the first line.
// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab).
// The longestLabelLen parameter specifies the length of the longest label in the output (required because this is the
// basis on which the alignment occurs).
func indentMessageLines(message string, longestLabelLen int) string {
outBuf := new(bytes.Buffer)
scanner := bufio.NewScanner(strings.NewReader(message))
for firstLine := true; scanner.Scan(); firstLine = false {
if !firstLine {
fmt.Fprint(outBuf, "\n\t"+strings.Repeat(" ", longestLabelLen+1)+"\t")
}
fmt.Fprint(outBuf, scanner.Text())
}
if err := scanner.Err(); err != nil {
return fmt.Sprintf("cannot display message: %s", err)
}
return outBuf.String()
}
type failNower interface {
FailNow()
}
// FailNow fails test
func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
Fail(t, failureMessage, msgAndArgs...)
// We cannot extend TestingT with FailNow() and
// maintain backwards compatibility, so we fallback
// to panicking when FailNow is not available in
// TestingT.
// See issue #263
if t, ok := t.(failNower); ok {
t.FailNow()
} else {
panic("test failed and t is missing `FailNow()`")
}
return false
}
// Fail reports a failure through
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
content := []labeledContent{
{"Error Trace", strings.Join(CallerInfo(), "\n\t\t\t")},
{"Error", failureMessage},
}
// Add test name if the Go version supports it
if n, ok := t.(interface {
Name() string
}); ok {
content = append(content, labeledContent{"Test", n.Name()})
}
message := messageFromMsgAndArgs(msgAndArgs...)
if len(message) > 0 {
content = append(content, labeledContent{"Messages", message})
}
t.Errorf("\n%s", ""+labeledOutput(content...))
return false
}
type labeledContent struct {
label string
content string
}
// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner:
//
// \t{{label}}:{{align_spaces}}\t{{content}}\n
//
// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label.
// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this
// alignment is achieved, "\t{{content}}\n" is added for the output.
//
// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line.
func labeledOutput(content ...labeledContent) string {
longestLabel := 0
for _, v := range content {
if len(v.label) > longestLabel {
longestLabel = len(v.label)
}
}
var output string
for _, v := range content {
output += "\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n"
}
return output
}
// Implements asserts that an object is implemented by the specified interface.
//
// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
interfaceType := reflect.TypeOf(interfaceObject).Elem()
if object == nil {
return Fail(t, fmt.Sprintf("Cannot check if nil implements %v", interfaceType), msgAndArgs...)
}
if !reflect.TypeOf(object).Implements(interfaceType) {
return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...)
}
return true
}
// NotImplements asserts that an object does not implement the specified interface.
//
// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject))
func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
interfaceType := reflect.TypeOf(interfaceObject).Elem()
if object == nil {
return Fail(t, fmt.Sprintf("Cannot check if nil does not implement %v", interfaceType), msgAndArgs...)
}
if reflect.TypeOf(object).Implements(interfaceType) {
return Fail(t, fmt.Sprintf("%T implements %v", object, interfaceType), msgAndArgs...)
}
return true
}
func isType(expectedType, object interface{}) bool {
return ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType))
}
// IsType asserts that the specified objects are of the same type.
//
// assert.IsType(t, &MyStruct{}, &MyStruct{})
func IsType(t TestingT, expectedType, object interface{}, msgAndArgs ...interface{}) bool {
if isType(expectedType, object) {
return true
}
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, fmt.Sprintf("Object expected to be of type %T, but was %T", expectedType, object), msgAndArgs...)
}
// IsNotType asserts that the specified objects are not of the same type.
//
// assert.IsNotType(t, &NotMyStruct{}, &MyStruct{})
func IsNotType(t TestingT, theType, object interface{}, msgAndArgs ...interface{}) bool {
if !isType(theType, object) {
return true
}
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, fmt.Sprintf("Object type expected to be different than %T", theType), msgAndArgs...)
}
// Equal asserts that two objects are equal.
//
// assert.Equal(t, 123, 123)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses). Function equality
// cannot be determined and will always fail.
func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if err := validateEqualArgs(expected, actual); err != nil {
return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)",
expected, actual, err), msgAndArgs...)
}
if !ObjectsAreEqual(expected, actual) {
diff := diff(expected, actual)
expected, actual = formatUnequalValues(expected, actual)
return Fail(t, fmt.Sprintf("Not equal: \n"+
"expected: %s\n"+
"actual : %s%s", expected, actual, diff), msgAndArgs...)
}
return true
}
// validateEqualArgs checks whether provided arguments can be safely used in the
// Equal/NotEqual functions.
func validateEqualArgs(expected, actual interface{}) error {
if expected == nil && actual == nil {
return nil
}
if isFunction(expected) || isFunction(actual) {
return errors.New("cannot take func type as argument")
}
return nil
}
// Same asserts that two pointers reference the same object.
//
// assert.Same(t, ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
same, ok := samePointers(expected, actual)
if !ok {
return Fail(t, "Both arguments must be pointers", msgAndArgs...)
}
if !same {
// both are pointers but not the same type & pointing to the same address
return Fail(t, fmt.Sprintf("Not same: \n"+
"expected: %[2]s (%[1]T)(%[1]p)\n"+
"actual : %[4]s (%[3]T)(%[3]p)", expected, truncatingFormat("%#v", expected), actual, truncatingFormat("%#v", actual)), msgAndArgs...)
}
return true
}
// NotSame asserts that two pointers do not reference the same object.
//
// assert.NotSame(t, ptr1, ptr2)
//
// Both arguments must be pointer variables. Pointer variable sameness is
// determined based on the equality of both type and value.
func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
same, ok := samePointers(expected, actual)
if !ok {
// fails when the arguments are not pointers
return !(Fail(t, "Both arguments must be pointers", msgAndArgs...))
}
if same {
return Fail(t, fmt.Sprintf(
"Expected and actual point to the same object: %p %s",
expected, truncatingFormat("%#v", expected)), msgAndArgs...)
}
return true
}
// samePointers checks if two generic interface objects are pointers of the same
// type pointing to the same object. It returns two values: same indicating if
// they are the same type and point to the same object, and ok indicating that
// both inputs are pointers.
func samePointers(first, second interface{}) (same bool, ok bool) {
firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second)
if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr {
return false, false // not both are pointers
}
firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second)
if firstType != secondType {
return false, true // both are pointers, but of different types
}
// compare pointer addresses
return first == second, true
}
// formatUnequalValues takes two values of arbitrary types and returns string
// representations appropriate to be presented to the user.
//
// If the values are not of like type, the returned strings will be prefixed
// with the type name, and the value will be enclosed in parentheses similar
// to a type conversion in the Go grammar.
func formatUnequalValues(expected, actual interface{}) (e string, a string) {
if reflect.TypeOf(expected) != reflect.TypeOf(actual) {
return fmt.Sprintf("%T(%s)", expected, truncatingFormat("%#v", expected)),
fmt.Sprintf("%T(%s)", actual, truncatingFormat("%#v", actual))
}
switch expected.(type) {
case time.Duration:
return fmt.Sprintf("%v", expected), fmt.Sprintf("%v", actual)
}
return truncatingFormat("%#v", expected), truncatingFormat("%#v", actual)
}
// truncatingFormat formats the data and truncates it if it's too long.
//
// This helps keep formatted error messages lines from exceeding the
// bufio.MaxScanTokenSize max line length that the go testing framework imposes.
func truncatingFormat(format string, data interface{}) string {
value := fmt.Sprintf(format, data)
// Give us space for two truncated objects and the surrounding sentence.
maxMessageSize := bufio.MaxScanTokenSize/2 - 100
if len(value) > maxMessageSize {
value = value[0:maxMessageSize] + "<... truncated>"
}
return value
}
// EqualValues asserts that two objects are equal or convertible to the larger
// type and equal.
//
// assert.EqualValues(t, uint32(123), int32(123))
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if !ObjectsAreEqualValues(expected, actual) {
diff := diff(expected, actual)
expected, actual = formatUnequalValues(expected, actual)
return Fail(t, fmt.Sprintf("Not equal: \n"+
"expected: %s\n"+
"actual : %s%s", expected, actual, diff), msgAndArgs...)
}
return true
}
// EqualExportedValues asserts that the types of two objects are equal and their public
// fields are also equal. This is useful for comparing structs that have private fields
// that could potentially differ.
//
// type S struct {
// Exported int
// notExported int
// }
// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
aType := reflect.TypeOf(expected)
bType := reflect.TypeOf(actual)
if aType != bType {
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
}
expected = copyExportedFields(expected)
actual = copyExportedFields(actual)
if !ObjectsAreEqualValues(expected, actual) {
diff := diff(expected, actual)
expected, actual = formatUnequalValues(expected, actual)
return Fail(t, fmt.Sprintf("Not equal (comparing only exported fields): \n"+
"expected: %s\n"+
"actual : %s%s", expected, actual, diff), msgAndArgs...)
}
return true
}
// Exactly asserts that two objects are equal in value and type.
//
// assert.Exactly(t, int32(123), int64(123))
func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
aType := reflect.TypeOf(expected)
bType := reflect.TypeOf(actual)
if aType != bType {
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
}
return Equal(t, expected, actual, msgAndArgs...)
}
// NotNil asserts that the specified object is not nil.
//
// assert.NotNil(t, err)
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if !isNil(object) {
return true
}
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, "Expected value not to be nil.", msgAndArgs...)
}
// isNil checks if a specified object is nil or not, without Failing.
func isNil(object interface{}) bool {
if object == nil {
return true
}
value := reflect.ValueOf(object)
switch value.Kind() {
case
reflect.Chan, reflect.Func,
reflect.Interface, reflect.Map,
reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
return value.IsNil()
}
return false
}
// Nil asserts that the specified object is nil.
//
// assert.Nil(t, err)
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
if isNil(object) {
return true
}
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, fmt.Sprintf("Expected nil, but got: %s", truncatingFormat("%#v", object)), msgAndArgs...)
}
// isEmpty gets whether the specified object is considered empty or not.
func isEmpty(object interface{}) bool {
// get nil case out of the way
if object == nil {
return true
}
return isEmptyValue(reflect.ValueOf(object))
}
// isEmptyValue gets whether the specified reflect.Value is considered empty or not.
func isEmptyValue(objValue reflect.Value) bool {
if objValue.IsZero() {
return true
}
// Special cases of non-zero values that we consider empty
switch objValue.Kind() {
// collection types are empty when they have no element
// Note: array types are empty when they match their zero-initialized state.
case reflect.Chan, reflect.Map, reflect.Slice:
return objValue.Len() == 0
// non-nil pointers are empty if the value they point to is empty
case reflect.Ptr:
return isEmptyValue(objValue.Elem())
}
return false
}
// Empty asserts that the given value is "empty".
//
// [Zero values] are "empty".
//
// Arrays are "empty" if every element is the zero value of the type (stricter than "empty").
//
// Slices, maps and channels with zero length are "empty".
//
// Pointer values are "empty" if the pointer is nil or if the pointed value is "empty".
//
// assert.Empty(t, obj)
//
// [Zero values]: https://go.dev/ref/spec#The_zero_value
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
pass := isEmpty(object)
if !pass {
if h, ok := t.(tHelper); ok {
h.Helper()
}
Fail(t, fmt.Sprintf("Should be empty, but was %s", truncatingFormat("%v", object)), msgAndArgs...)
}
return pass
}
// NotEmpty asserts that the specified object is NOT [Empty].
//
// if assert.NotEmpty(t, obj) {
// assert.Equal(t, "two", obj[1])
// }
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
pass := !isEmpty(object)
if !pass {
if h, ok := t.(tHelper); ok {
h.Helper()
}
Fail(t, fmt.Sprintf("Should NOT be empty, but was %v", object), msgAndArgs...)
}
return pass
}
// getLen tries to get the length of an object.
// It returns (0, false) if impossible.
func getLen(x interface{}) (length int, ok bool) {
v := reflect.ValueOf(x)
defer func() {
ok = recover() == nil
}()
return v.Len(), true
}
// Len asserts that the specified object has specific length.
// Len also fails if the object has a type that len() not accept.
//
// assert.Len(t, mySlice, 3)
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
l, ok := getLen(object)
if !ok {
return Fail(t, fmt.Sprintf("%q could not be applied builtin len()", truncatingFormat("%v", object)), msgAndArgs...)
}
if l != length {
return Fail(t, fmt.Sprintf("%q should have %d item(s), but has %d", truncatingFormat("%v", object), length, l), msgAndArgs...)
}
return true
}
// True asserts that the specified value is true.
//
// assert.True(t, myBool)
func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
if !value {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, "Should be true", msgAndArgs...)
}
return true
}
// False asserts that the specified value is false.
//
// assert.False(t, myBool)
func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
if value {
if h, ok := t.(tHelper); ok {
h.Helper()
}
return Fail(t, "Should be false", msgAndArgs...)
}
return true
}
// NotEqual asserts that the specified values are NOT equal.
//
// assert.NotEqual(t, obj1, obj2)
//
// Pointer variable equality is determined based on the equality of the
// referenced values (as opposed to the memory addresses).
func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if err := validateEqualArgs(expected, actual); err != nil {
return Fail(t, fmt.Sprintf("Invalid operation: %#v != %#v (%s)",
expected, actual, err), msgAndArgs...)
}
if ObjectsAreEqual(expected, actual) {
return Fail(t, fmt.Sprintf("Should not be: %s\n", truncatingFormat("%#v", actual)), msgAndArgs...)
}
return true
}
// NotEqualValues asserts that two objects are not equal even when converted to the same type
//
// assert.NotEqualValues(t, obj1, obj2)
func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if ObjectsAreEqualValues(expected, actual) {
return Fail(t, fmt.Sprintf("Should not be: %s\n", truncatingFormat("%#v", actual)), msgAndArgs...)
}
return true
}
// containsElement try loop over the list check if the list includes the element.
// return (false, false) if impossible.
// return (true, false) if element was not found.
// return (true, true) if element was found.
func containsElement(list interface{}, element interface{}) (ok, found bool) {
listValue := reflect.ValueOf(list)
listType := reflect.TypeOf(list)
if listType == nil {
return false, false
}
listKind := listType.Kind()
defer func() {
if e := recover(); e != nil {
ok = false
found = false
}
}()
if listKind == reflect.String {
elementValue := reflect.ValueOf(element)
return true, strings.Contains(listValue.String(), elementValue.String())
}
if listKind == reflect.Map {
mapKeys := listValue.MapKeys()
for i := 0; i < len(mapKeys); i++ {
if ObjectsAreEqual(mapKeys[i].Interface(), element) {
return true, true
}
}
return true, false
}
for i := 0; i < listValue.Len(); i++ {
if ObjectsAreEqual(listValue.Index(i).Interface(), element) {
return true, true
}
}
return true, false
}
// Contains asserts that the specified string, list(array, slice...) or map contains the
// specified substring or element.
//
// assert.Contains(t, "Hello World", "World")
// assert.Contains(t, ["Hello", "World"], "World")
// assert.Contains(t, {"Hello": "World"}, "Hello")
func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
ok, found := containsElement(s, contains)
if !ok {
return Fail(t, fmt.Sprintf("%s could not be applied builtin len()", truncatingFormat("%#v", s)), msgAndArgs...)
}
if !found {
return Fail(t, fmt.Sprintf("%s does not contain %#v", truncatingFormat("%#v", s), contains), msgAndArgs...)
}
return true
}
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
// specified substring or element.
//
// assert.NotContains(t, "Hello World", "Earth")
// assert.NotContains(t, ["Hello", "World"], "Earth")
// assert.NotContains(t, {"Hello": "World"}, "Earth")
func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
ok, found := containsElement(s, contains)
if !ok {
return Fail(t, fmt.Sprintf("%s could not be applied builtin len()", truncatingFormat("%#v", s)), msgAndArgs...)
}
if found {
return Fail(t, fmt.Sprintf("%s should not contain %#v", truncatingFormat("%#v", s), contains), msgAndArgs...)
}
return true
}
// Subset asserts that the list (array, slice, or map) contains all elements
// given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// assert.Subset(t, [1, 2, 3], [1, 2])
// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1})
// assert.Subset(t, [1, 2, 3], {1: "one", 2: "two"})
// assert.Subset(t, {"x": 1, "y": 2}, ["x"])
func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if subset == nil {
return true // we consider nil to be equal to the nil set
}
listKind := reflect.TypeOf(list).Kind()
if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map {
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...)
}
subsetKind := reflect.TypeOf(subset).Kind()
if subsetKind != reflect.Array && subsetKind != reflect.Slice && subsetKind != reflect.Map {
return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...)
}
if subsetKind == reflect.Map && listKind == reflect.Map {
subsetMap := reflect.ValueOf(subset)
actualMap := reflect.ValueOf(list)
for _, k := range subsetMap.MapKeys() {
ev := subsetMap.MapIndex(k)
av := actualMap.MapIndex(k)
if !av.IsValid() {
return Fail(t, fmt.Sprintf("%s does not contain %s", truncatingFormat("%#v", list), truncatingFormat("%#v", subset)), msgAndArgs...)
}
if !ObjectsAreEqual(ev.Interface(), av.Interface()) {
return Fail(t, fmt.Sprintf("%s does not contain %s", truncatingFormat("%#v", list), truncatingFormat("%#v", subset)), msgAndArgs...)
}
}
return true
}
subsetList := reflect.ValueOf(subset)
if subsetKind == reflect.Map {
keys := make([]interface{}, subsetList.Len())
for idx, key := range subsetList.MapKeys() {
keys[idx] = key.Interface()
}
subsetList = reflect.ValueOf(keys)
}
for i := 0; i < subsetList.Len(); i++ {
element := subsetList.Index(i).Interface()
ok, found := containsElement(list, element)
if !ok {
return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...)
}
if !found {
return Fail(t, fmt.Sprintf("%s does not contain %#v", truncatingFormat("%#v", list), element), msgAndArgs...)
}
}
return true
}
// NotSubset asserts that the list (array, slice, or map) does NOT contain all
// elements given in the subset (array, slice, or map).
// Map elements are key-value pairs unless compared with an array or slice where
// only the map key is evaluated.
//
// assert.NotSubset(t, [1, 3, 4], [1, 2])
// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3})
// assert.NotSubset(t, [1, 3, 4], {1: "one", 2: "two"})
// assert.NotSubset(t, {"x": 1, "y": 2}, ["z"])
func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if subset == nil {
return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...)
}
listKind :=
gitextract_0dnewmdf/
├── .ci.gofmt.sh
├── .ci.gogenerate.sh
├── .ci.govet.sh
├── .ci.readme.fmt.sh
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── dependabot.yml
│ ├── pull_request_template.md
│ └── workflows/
│ ├── main.yml
│ └── release.yml
├── .gitignore
├── .mdsf.json
├── CONTRIBUTING.md
├── EMERITUS.md
├── LICENSE
├── MAINTAINERS.md
├── README.md
├── assert/
│ ├── assertion_compare.go
│ ├── assertion_compare_test.go
│ ├── assertion_format.go
│ ├── assertion_format.go.tmpl
│ ├── assertion_forward.go
│ ├── assertion_forward.go.tmpl
│ ├── assertion_order.go
│ ├── assertion_order_test.go
│ ├── assertions.go
│ ├── assertions_test.go
│ ├── doc.go
│ ├── errors.go
│ ├── forward_assertions.go
│ ├── forward_assertions_test.go
│ ├── http_assertions.go
│ ├── http_assertions_test.go
│ ├── internal/
│ │ └── unsafetests/
│ │ ├── doc.go
│ │ └── unsafetests_test.go
│ └── yaml/
│ ├── yaml_custom.go
│ ├── yaml_default.go
│ └── yaml_fail.go
├── doc.go
├── go.mod
├── go.sum
├── http/
│ ├── doc.go
│ ├── test_response_writer.go
│ └── test_round_tripper.go
├── internal/
│ ├── difflib/
│ │ ├── LICENSE
│ │ ├── difflib.go
│ │ └── difflib_test.go
│ └── spew/
│ ├── LICENSE
│ ├── README.md
│ ├── bypass.go
│ ├── bypasssafe.go
│ ├── common.go
│ ├── common_test.go
│ ├── config.go
│ ├── doc.go
│ ├── dump.go
│ ├── dump_test.go
│ ├── dumpcgo_test.go
│ ├── dumpnocgo_test.go
│ ├── format.go
│ ├── format_test.go
│ ├── internal_test.go
│ ├── internalunsafe_test.go
│ ├── spew.go
│ ├── spew_test.go
│ └── testdata/
│ └── dumpcgo.go
├── mock/
│ ├── doc.go
│ ├── mock.go
│ └── mock_test.go
├── package_test.go
├── require/
│ ├── doc.go
│ ├── forward_requirements.go
│ ├── forward_requirements_test.go
│ ├── require.go
│ ├── require.go.tmpl
│ ├── require_forward.go
│ ├── require_forward.go.tmpl
│ ├── requirements.go
│ └── requirements_test.go
└── suite/
├── doc.go
├── interfaces.go
├── stats.go
├── stats_test.go
├── suite.go
└── suite_test.go
SYMBOL INDEX (1653 symbols across 49 files)
FILE: assert/assertion_compare.go
type compareResult (line 13) | type compareResult
constant compareLess (line 16) | compareLess compareResult = iota - 1
constant compareEqual (line 17) | compareEqual
constant compareGreater (line 18) | compareGreater
function compare (line 45) | func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, ...
function Greater (line 389) | func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...i...
function GreaterOrEqual (line 403) | func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndAr...
function Less (line 416) | func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inte...
function LessOrEqual (line 430) | func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...
function Positive (line 442) | func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
function Negative (line 455) | func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
function compareTwoValues (line 464) | func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowe...
function containsValue (line 487) | func containsValue(values []compareResult, value compareResult) bool {
FILE: assert/assertion_compare_test.go
function TestCompare (line 12) | func TestCompare(t *testing.T) {
type outputT (line 99) | type outputT struct
method Errorf (line 105) | func (t *outputT) Errorf(format string, args ...interface{}) {
method Helper (line 110) | func (t *outputT) Helper() {
function callerName (line 119) | func callerName(skip int) string {
function TestGreater (line 131) | func TestGreater(t *testing.T) {
function TestGreaterOrEqual (line 177) | func TestGreaterOrEqual(t *testing.T) {
function TestLess (line 223) | func TestLess(t *testing.T) {
function TestLessOrEqual (line 269) | func TestLessOrEqual(t *testing.T) {
function TestPositive (line 315) | func TestPositive(t *testing.T) {
function TestNegative (line 356) | func TestNegative(t *testing.T) {
function Test_compareTwoValuesDifferentValuesTypes (line 397) | func Test_compareTwoValuesDifferentValuesTypes(t *testing.T) {
function Test_compareTwoValuesNotComparableValues (line 417) | func Test_compareTwoValuesNotComparableValues(t *testing.T) {
function Test_compareTwoValuesCorrectCompareResult (line 438) | func Test_compareTwoValuesCorrectCompareResult(t *testing.T) {
function Test_containsValue (line 460) | func Test_containsValue(t *testing.T) {
function TestComparingMsgAndArgsForwarding (line 478) | func TestComparingMsgAndArgsForwarding(t *testing.T) {
FILE: assert/assertion_format.go
function Conditionf (line 12) | func Conditionf(t TestingT, comp Comparison, msg string, args ...interfa...
function Containsf (line 25) | func Containsf(t TestingT, s interface{}, contains interface{}, msg stri...
function DirExistsf (line 34) | func DirExistsf(t TestingT, path string, msg string, args ...interface{}...
function ElementsMatchf (line 46) | func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, ms...
function Emptyf (line 66) | func Emptyf(t TestingT, object interface{}, msg string, args ...interfac...
function Equalf (line 80) | func Equalf(t TestingT, expected interface{}, actual interface{}, msg st...
function EqualErrorf (line 92) | func EqualErrorf(t TestingT, theError error, errString string, msg strin...
function EqualExportedValuesf (line 109) | func EqualExportedValuesf(t TestingT, expected interface{}, actual inter...
function EqualValuesf (line 120) | func EqualValuesf(t TestingT, expected interface{}, actual interface{}, ...
function Errorf (line 131) | func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
function ErrorAsf (line 140) | func ErrorAsf(t TestingT, err error, target interface{}, msg string, arg...
function ErrorContainsf (line 152) | func ErrorContainsf(t TestingT, theError error, contains string, msg str...
function ErrorIsf (line 161) | func ErrorIsf(t TestingT, err error, target error, msg string, args ...i...
function Eventuallyf (line 172) | func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duratio...
function EventuallyWithTf (line 197) | func EventuallyWithTf(t TestingT, condition func(collect *CollectT), wai...
function Exactlyf (line 207) | func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg ...
function Failf (line 215) | func Failf(t TestingT, failureMessage string, msg string, args ...interf...
function FailNowf (line 223) | func FailNowf(t TestingT, failureMessage string, msg string, args ...int...
function Falsef (line 233) | func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
function FileExistsf (line 242) | func FileExistsf(t TestingT, path string, msg string, args ...interface{...
function Greaterf (line 254) | func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, ar...
function GreaterOrEqualf (line 267) | func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg str...
function HTTPBodyContainsf (line 280) | func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method stri...
function HTTPBodyNotContainsf (line 293) | func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method s...
function HTTPErrorf (line 305) | func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url...
function HTTPRedirectf (line 317) | func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, ...
function HTTPStatusCodef (line 329) | func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string...
function HTTPSuccessf (line 341) | func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, u...
function Implementsf (line 351) | func Implementsf(t TestingT, interfaceObject interface{}, object interfa...
function InDeltaf (line 361) | func InDeltaf(t TestingT, expected interface{}, actual interface{}, delt...
function InDeltaMapValuesf (line 369) | func InDeltaMapValuesf(t TestingT, expected interface{}, actual interfac...
function InDeltaSlicef (line 377) | func InDeltaSlicef(t TestingT, expected interface{}, actual interface{},...
function InEpsilonf (line 385) | func InEpsilonf(t TestingT, expected interface{}, actual interface{}, ep...
function InEpsilonSlicef (line 393) | func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{...
function IsDecreasingf (line 405) | func IsDecreasingf(t TestingT, object interface{}, msg string, args ...i...
function IsIncreasingf (line 417) | func IsIncreasingf(t TestingT, object interface{}, msg string, args ...i...
function IsNonDecreasingf (line 429) | func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ....
function IsNonIncreasingf (line 441) | func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ....
function IsNotTypef (line 451) | func IsNotTypef(t TestingT, theType interface{}, object interface{}, msg...
function IsTypef (line 461) | func IsTypef(t TestingT, expectedType interface{}, object interface{}, m...
function JSONEqf (line 471) | func JSONEqf(t TestingT, expected string, actual string, msg string, arg...
function Lenf (line 482) | func Lenf(t TestingT, object interface{}, length int, msg string, args ....
function Lessf (line 494) | func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...
function LessOrEqualf (line 507) | func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string...
function Negativef (line 518) | func Negativef(t TestingT, e interface{}, msg string, args ...interface{...
function Neverf (line 529) | func Neverf(t TestingT, condition func() bool, waitFor time.Duration, ti...
function Nilf (line 539) | func Nilf(t TestingT, object interface{}, msg string, args ...interface{...
function NoDirExistsf (line 548) | func NoDirExistsf(t TestingT, path string, msg string, args ...interface...
function NoErrorf (line 561) | func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bo...
function NoFileExistsf (line 570) | func NoFileExistsf(t TestingT, path string, msg string, args ...interfac...
function NotContainsf (line 583) | func NotContainsf(t TestingT, s interface{}, contains interface{}, msg s...
function NotElementsMatchf (line 600) | func NotElementsMatchf(t TestingT, listA interface{}, listB interface{},...
function NotEmptyf (line 612) | func NotEmptyf(t TestingT, object interface{}, msg string, args ...inter...
function NotEqualf (line 625) | func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg...
function NotEqualValuesf (line 635) | func NotEqualValuesf(t TestingT, expected interface{}, actual interface{...
function NotErrorAsf (line 644) | func NotErrorAsf(t TestingT, err error, target interface{}, msg string, ...
function NotErrorIsf (line 653) | func NotErrorIsf(t TestingT, err error, target error, msg string, args ....
function NotImplementsf (line 663) | func NotImplementsf(t TestingT, interfaceObject interface{}, object inte...
function NotNilf (line 673) | func NotNilf(t TestingT, object interface{}, msg string, args ...interfa...
function NotPanicsf (line 683) | func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interfa...
function NotRegexpf (line 694) | func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string,...
function NotSamef (line 707) | func NotSamef(t TestingT, expected interface{}, actual interface{}, msg ...
function NotSubsetf (line 723) | func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg st...
function NotZerof (line 731) | func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}...
function Panicsf (line 741) | func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{...
function PanicsWithErrorf (line 753) | func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg...
function PanicsWithValuef (line 764) | func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc,...
function Positivef (line 775) | func Positivef(t TestingT, e interface{}, msg string, args ...interface{...
function Regexpf (line 786) | func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, ar...
function Samef (line 799) | func Samef(t TestingT, expected interface{}, actual interface{}, msg str...
function Subsetf (line 815) | func Subsetf(t TestingT, list interface{}, subset interface{}, msg strin...
function Truef (line 825) | func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
function WithinDurationf (line 835) | func WithinDurationf(t TestingT, expected time.Time, actual time.Time, d...
function WithinRangef (line 845) | func WithinRangef(t TestingT, actual time.Time, start time.Time, end tim...
function YAMLEqf (line 865) | func YAMLEqf(t TestingT, expected string, actual string, msg string, arg...
function Zerof (line 873) | func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) b...
FILE: assert/assertion_forward.go
method Condition (line 12) | func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{...
method Conditionf (line 20) | func (a *Assertions) Conditionf(comp Comparison, msg string, args ...int...
method Contains (line 33) | func (a *Assertions) Contains(s interface{}, contains interface{}, msgAn...
method Containsf (line 46) | func (a *Assertions) Containsf(s interface{}, contains interface{}, msg ...
method DirExists (line 55) | func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) b...
method DirExistsf (line 64) | func (a *Assertions) DirExistsf(path string, msg string, args ...interfa...
method ElementsMatch (line 76) | func (a *Assertions) ElementsMatch(listA interface{}, listB interface{},...
method ElementsMatchf (line 88) | func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}...
method Empty (line 108) | func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}...
method Emptyf (line 128) | func (a *Assertions) Emptyf(object interface{}, msg string, args ...inte...
method Equal (line 142) | func (a *Assertions) Equal(expected interface{}, actual interface{}, msg...
method EqualError (line 154) | func (a *Assertions) EqualError(theError error, errString string, msgAnd...
method EqualErrorf (line 166) | func (a *Assertions) EqualErrorf(theError error, errString string, msg s...
method EqualExportedValues (line 183) | func (a *Assertions) EqualExportedValues(expected interface{}, actual in...
method EqualExportedValuesf (line 200) | func (a *Assertions) EqualExportedValuesf(expected interface{}, actual i...
method EqualValues (line 211) | func (a *Assertions) EqualValues(expected interface{}, actual interface{...
method EqualValuesf (line 222) | func (a *Assertions) EqualValuesf(expected interface{}, actual interface...
method Equalf (line 236) | func (a *Assertions) Equalf(expected interface{}, actual interface{}, ms...
method Error (line 247) | func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
method ErrorAs (line 256) | func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ....
method ErrorAsf (line 265) | func (a *Assertions) ErrorAsf(err error, target interface{}, msg string,...
method ErrorContains (line 277) | func (a *Assertions) ErrorContains(theError error, contains string, msgA...
method ErrorContainsf (line 289) | func (a *Assertions) ErrorContainsf(theError error, contains string, msg...
method ErrorIs (line 298) | func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...inte...
method ErrorIsf (line 307) | func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...
method Errorf (line 318) | func (a *Assertions) Errorf(err error, msg string, args ...interface{}) ...
method Eventually (line 329) | func (a *Assertions) Eventually(condition func() bool, waitFor time.Dura...
method EventuallyWithT (line 354) | func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), ...
method EventuallyWithTf (line 379) | func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT),...
method Eventuallyf (line 390) | func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Dur...
method Exactly (line 400) | func (a *Assertions) Exactly(expected interface{}, actual interface{}, m...
method Exactlyf (line 410) | func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, ...
method Fail (line 418) | func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface...
method FailNow (line 426) | func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interf...
method FailNowf (line 434) | func (a *Assertions) FailNowf(failureMessage string, msg string, args .....
method Failf (line 442) | func (a *Assertions) Failf(failureMessage string, msg string, args ...in...
method False (line 452) | func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
method Falsef (line 462) | func (a *Assertions) Falsef(value bool, msg string, args ...interface{})...
method FileExists (line 471) | func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) ...
method FileExistsf (line 480) | func (a *Assertions) FileExistsf(path string, msg string, args ...interf...
method Greater (line 492) | func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...
method GreaterOrEqual (line 505) | func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgA...
method GreaterOrEqualf (line 518) | func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg...
method Greaterf (line 530) | func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string...
method HTTPBodyContains (line 543) | func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method s...
method HTTPBodyContainsf (line 556) | func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method ...
method HTTPBodyNotContains (line 569) | func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, metho...
method HTTPBodyNotContainsf (line 582) | func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, meth...
method HTTPError (line 594) | func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, ...
method HTTPErrorf (line 606) | func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string,...
method HTTPRedirect (line 618) | func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method strin...
method HTTPRedirectf (line 630) | func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method stri...
method HTTPStatusCode (line 642) | func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method str...
method HTTPStatusCodef (line 654) | func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method st...
method HTTPSuccess (line 666) | func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string...
method HTTPSuccessf (line 678) | func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method strin...
method Implements (line 688) | func (a *Assertions) Implements(interfaceObject interface{}, object inte...
method Implementsf (line 698) | func (a *Assertions) Implementsf(interfaceObject interface{}, object int...
method InDelta (line 708) | func (a *Assertions) InDelta(expected interface{}, actual interface{}, d...
method InDeltaMapValues (line 716) | func (a *Assertions) InDeltaMapValues(expected interface{}, actual inter...
method InDeltaMapValuesf (line 724) | func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual inte...
method InDeltaSlice (line 732) | func (a *Assertions) InDeltaSlice(expected interface{}, actual interface...
method InDeltaSlicef (line 740) | func (a *Assertions) InDeltaSlicef(expected interface{}, actual interfac...
method InDeltaf (line 750) | func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, ...
method InEpsilon (line 758) | func (a *Assertions) InEpsilon(expected interface{}, actual interface{},...
method InEpsilonSlice (line 766) | func (a *Assertions) InEpsilonSlice(expected interface{}, actual interfa...
method InEpsilonSlicef (line 774) | func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interf...
method InEpsilonf (line 782) | func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}...
method IsDecreasing (line 794) | func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...inte...
method IsDecreasingf (line 806) | func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...
method IsIncreasing (line 818) | func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...inte...
method IsIncreasingf (line 830) | func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...
method IsNonDecreasing (line 842) | func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...i...
method IsNonDecreasingf (line 854) | func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, ar...
method IsNonIncreasing (line 866) | func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...i...
method IsNonIncreasingf (line 878) | func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, ar...
method IsNotType (line 888) | func (a *Assertions) IsNotType(theType interface{}, object interface{}, ...
method IsNotTypef (line 898) | func (a *Assertions) IsNotTypef(theType interface{}, object interface{},...
method IsType (line 908) | func (a *Assertions) IsType(expectedType interface{}, object interface{}...
method IsTypef (line 918) | func (a *Assertions) IsTypef(expectedType interface{}, object interface{...
method JSONEq (line 928) | func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ....
method JSONEqf (line 938) | func (a *Assertions) JSONEqf(expected string, actual string, msg string,...
method Len (line 949) | func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...i...
method Lenf (line 960) | func (a *Assertions) Lenf(object interface{}, length int, msg string, ar...
method Less (line 972) | func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ......
method LessOrEqual (line 985) | func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndA...
method LessOrEqualf (line 998) | func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg st...
method Lessf (line 1010) | func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, a...
method Negative (line 1021) | func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) ...
method Negativef (line 1032) | func (a *Assertions) Negativef(e interface{}, msg string, args ...interf...
method Never (line 1043) | func (a *Assertions) Never(condition func() bool, waitFor time.Duration,...
method Neverf (line 1054) | func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration...
method Nil (line 1064) | func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) ...
method Nilf (line 1074) | func (a *Assertions) Nilf(object interface{}, msg string, args ...interf...
method NoDirExists (line 1083) | func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{})...
method NoDirExistsf (line 1092) | func (a *Assertions) NoDirExistsf(path string, msg string, args ...inter...
method NoError (line 1105) | func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
method NoErrorf (line 1118) | func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}...
method NoFileExists (line 1127) | func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}...
method NoFileExistsf (line 1136) | func (a *Assertions) NoFileExistsf(path string, msg string, args ...inte...
method NotContains (line 1149) | func (a *Assertions) NotContains(s interface{}, contains interface{}, ms...
method NotContainsf (line 1162) | func (a *Assertions) NotContainsf(s interface{}, contains interface{}, m...
method NotElementsMatch (line 1179) | func (a *Assertions) NotElementsMatch(listA interface{}, listB interface...
method NotElementsMatchf (line 1196) | func (a *Assertions) NotElementsMatchf(listA interface{}, listB interfac...
method NotEmpty (line 1208) | func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interfac...
method NotEmptyf (line 1220) | func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...i...
method NotEqual (line 1233) | func (a *Assertions) NotEqual(expected interface{}, actual interface{}, ...
method NotEqualValues (line 1243) | func (a *Assertions) NotEqualValues(expected interface{}, actual interfa...
method NotEqualValuesf (line 1253) | func (a *Assertions) NotEqualValuesf(expected interface{}, actual interf...
method NotEqualf (line 1266) | func (a *Assertions) NotEqualf(expected interface{}, actual interface{},...
method NotErrorAs (line 1275) | func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArg...
method NotErrorAsf (line 1284) | func (a *Assertions) NotErrorAsf(err error, target interface{}, msg stri...
method NotErrorIs (line 1293) | func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...i...
method NotErrorIsf (line 1302) | func (a *Assertions) NotErrorIsf(err error, target error, msg string, ar...
method NotImplements (line 1312) | func (a *Assertions) NotImplements(interfaceObject interface{}, object i...
method NotImplementsf (line 1322) | func (a *Assertions) NotImplementsf(interfaceObject interface{}, object ...
method NotNil (line 1332) | func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{...
method NotNilf (line 1342) | func (a *Assertions) NotNilf(object interface{}, msg string, args ...int...
method NotPanics (line 1352) | func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{...
method NotPanicsf (line 1362) | func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...int...
method NotRegexp (line 1373) | func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndAr...
method NotRegexpf (line 1384) | func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg str...
method NotSame (line 1397) | func (a *Assertions) NotSame(expected interface{}, actual interface{}, m...
method NotSamef (line 1410) | func (a *Assertions) NotSamef(expected interface{}, actual interface{}, ...
method NotSubset (line 1426) | func (a *Assertions) NotSubset(list interface{}, subset interface{}, msg...
method NotSubsetf (line 1442) | func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, ms...
method NotZero (line 1450) | func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) b...
method NotZerof (line 1458) | func (a *Assertions) NotZerof(i interface{}, msg string, args ...interfa...
method Panics (line 1468) | func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) ...
method PanicsWithError (line 1480) | func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, ...
method PanicsWithErrorf (line 1492) | func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc,...
method PanicsWithValue (line 1503) | func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFu...
method PanicsWithValuef (line 1514) | func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestF...
method Panicsf (line 1524) | func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interf...
method Positive (line 1535) | func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) ...
method Positivef (line 1546) | func (a *Assertions) Positivef(e interface{}, msg string, args ...interf...
method Regexp (line 1557) | func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...
method Regexpf (line 1568) | func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string...
method Same (line 1581) | func (a *Assertions) Same(expected interface{}, actual interface{}, msgA...
method Samef (line 1594) | func (a *Assertions) Samef(expected interface{}, actual interface{}, msg...
method Subset (line 1610) | func (a *Assertions) Subset(list interface{}, subset interface{}, msgAnd...
method Subsetf (line 1626) | func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg s...
method True (line 1636) | func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
method Truef (line 1646) | func (a *Assertions) Truef(value bool, msg string, args ...interface{}) ...
method WithinDuration (line 1656) | func (a *Assertions) WithinDuration(expected time.Time, actual time.Time...
method WithinDurationf (line 1666) | func (a *Assertions) WithinDurationf(expected time.Time, actual time.Tim...
method WithinRange (line 1676) | func (a *Assertions) WithinRange(actual time.Time, start time.Time, end ...
method WithinRangef (line 1686) | func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end...
method YAMLEq (line 1706) | func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ....
method YAMLEqf (line 1726) | func (a *Assertions) YAMLEqf(expected string, actual string, msg string,...
method Zero (line 1734) | func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
method Zerof (line 1742) | func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{...
FILE: assert/assertion_order.go
function isOrdered (line 9) | func isOrdered(t TestingT, object interface{}, allowedComparesResults []...
function IsIncreasing (line 52) | func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interfac...
function IsNonIncreasing (line 64) | func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...inter...
function IsDecreasing (line 76) | func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interfac...
function IsNonDecreasing (line 88) | func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...inter...
FILE: assert/assertion_order_test.go
function TestIsIncreasing (line 9) | func TestIsIncreasing(t *testing.T) {
function TestIsNonIncreasing (line 59) | func TestIsNonIncreasing(t *testing.T) {
function TestIsDecreasing (line 109) | func TestIsDecreasing(t *testing.T) {
function TestIsNonDecreasing (line 159) | func TestIsNonDecreasing(t *testing.T) {
function TestOrderingMsgAndArgsForwarding (line 209) | func TestOrderingMsgAndArgsForwarding(t *testing.T) {
FILE: assert/assertions.go
type TestingT (line 29) | type TestingT interface
type ComparisonAssertionFunc (line 35) | type ComparisonAssertionFunc
type ValueAssertionFunc (line 39) | type ValueAssertionFunc
type BoolAssertionFunc (line 43) | type BoolAssertionFunc
type ErrorAssertionFunc (line 47) | type ErrorAssertionFunc
type Comparison (line 54) | type Comparison
function ObjectsAreEqual (line 63) | func ObjectsAreEqual(expected, actual interface{}) bool {
function copyExportedFields (line 85) | func copyExportedFields(expected interface{}) interface{} {
function ObjectsExportedFieldsAreEqual (line 155) | func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool {
function ObjectsAreEqualValues (line 163) | func ObjectsAreEqualValues(expected, actual interface{}) bool {
function isNumericType (line 200) | func isNumericType(t reflect.Type) bool {
function CallerInfo (line 211) | func CallerInfo() []string {
function isTest (line 292) | func isTest(name, prefix string) bool {
function messageFromMsgAndArgs (line 303) | func messageFromMsgAndArgs(msgAndArgs ...interface{}) string {
function indentMessageLines (line 324) | func indentMessageLines(message string, longestLabelLen int) string {
type failNower (line 341) | type failNower interface
function FailNow (line 346) | func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{...
function Fail (line 367) | func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) ...
type labeledContent (line 393) | type labeledContent struct
function labeledOutput (line 407) | func labeledOutput(content ...labeledContent) string {
function Implements (line 424) | func Implements(t TestingT, interfaceObject interface{}, object interfac...
function NotImplements (line 443) | func NotImplements(t TestingT, interfaceObject interface{}, object inter...
function isType (line 459) | func isType(expectedType, object interface{}) bool {
function IsType (line 466) | func IsType(t TestingT, expectedType, object interface{}, msgAndArgs ......
function IsNotType (line 479) | func IsNotType(t TestingT, theType, object interface{}, msgAndArgs ...in...
function Equal (line 496) | func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...inter...
function validateEqualArgs (line 518) | func validateEqualArgs(expected, actual interface{}) error {
function Same (line 535) | func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interf...
function NotSame (line 561) | func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...int...
function samePointers (line 584) | func samePointers(first, second interface{}) (same bool, ok bool) {
function formatUnequalValues (line 605) | func formatUnequalValues(expected, actual interface{}) (e string, a stri...
function truncatingFormat (line 621) | func truncatingFormat(format string, data interface{}) string {
function EqualValues (line 635) | func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs .....
function EqualExportedValues (line 661) | func EqualExportedValues(t TestingT, expected, actual interface{}, msgAn...
function Exactly (line 690) | func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...int...
function NotNil (line 708) | func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) b...
function isNil (line 719) | func isNil(object interface{}) bool {
function Nil (line 740) | func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
function isEmpty (line 751) | func isEmpty(object interface{}) bool {
function isEmptyValue (line 761) | func isEmptyValue(objValue reflect.Value) bool {
function Empty (line 791) | func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bo...
function NotEmpty (line 808) | func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{})...
function getLen (line 822) | func getLen(x interface{}) (length int, ok bool) {
function Len (line 834) | func Len(t TestingT, object interface{}, length int, msgAndArgs ...inter...
function True (line 852) | func True(t TestingT, value bool, msgAndArgs ...interface{}) bool {
function False (line 866) | func False(t TestingT, value bool, msgAndArgs ...interface{}) bool {
function NotEqual (line 883) | func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...in...
function NotEqualValues (line 902) | func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs...
function containsElement (line 918) | func containsElement(list interface{}, element interface{}) (ok, found b...
function Contains (line 961) | func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interfa...
function NotContains (line 983) | func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...inte...
function Subset (line 1008) | func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interfac...
function NotSubset (line 1076) | func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...inter...
function ElementsMatch (line 1140) | func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...i...
function isList (line 1162) | func isList(t TestingT, list interface{}, msgAndArgs ...interface{}) (ok...
function diffLists (line 1174) | func diffLists(listA, listB interface{}) (extraA, extraB []interface{}) {
function formatListDiff (line 1211) | func formatListDiff(listA, listB interface{}, extraA, extraB []interface...
function NotElementsMatch (line 1241) | func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ....
function Condition (line 1265) | func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) b...
type PanicTestFunc (line 1278) | type PanicTestFunc
function didPanic (line 1281) | func didPanic(f PanicTestFunc) (didPanic bool, message interface{}, stac...
function Panics (line 1301) | func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool {
function PanicsWithValue (line 1317) | func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, ...
function PanicsWithError (line 1338) | func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgA...
function NotPanics (line 1364) | func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) b...
function WithinDuration (line 1379) | func WithinDuration(t TestingT, expected, actual time.Time, delta time.D...
function WithinRange (line 1395) | func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs .....
function toFloat (line 1413) | func toFloat(x interface{}) (float64, bool) {
function InDelta (line 1454) | func InDelta(t TestingT, expected, actual interface{}, delta float64, ms...
function InDeltaSlice (line 1487) | func InDeltaSlice(t TestingT, expected, actual interface{}, delta float6...
function InDeltaMapValues (line 1511) | func InDeltaMapValues(t TestingT, expected, actual interface{}, delta fl...
function calcRelativeError (line 1554) | func calcRelativeError(expected, actual interface{}) (float64, error) {
function InEpsilon (line 1577) | func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64...
function InEpsilonSlice (line 1600) | func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon fl...
function NoError (line 1640) | func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool {
function Error (line 1655) | func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
function EqualError (line 1671) | func EqualError(t TestingT, theError error, errString string, msgAndArgs...
function ErrorContains (line 1694) | func ErrorContains(t TestingT, theError error, contains string, msgAndAr...
function matchRegexp (line 1711) | func matchRegexp(rx interface{}, str interface{}) bool {
function Regexp (line 1733) | func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...i...
function NotRegexp (line 1751) | func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ....
function Zero (line 1765) | func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
function NotZero (line 1776) | func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool {
function FileExists (line 1788) | func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
function NoFileExists (line 1807) | func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) bo...
function DirExists (line 1823) | func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
function NoDirExists (line 1842) | func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
function JSONEq (line 1862) | func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...in...
function YAMLEq (line 1897) | func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...in...
function typeAndKind (line 1919) | func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) {
function diff (line 1932) | func diff(expected interface{}, actual interface{}) string {
function isFunction (line 1975) | func isFunction(arg interface{}) bool {
function Eventually (line 2007) | func Eventually(t TestingT, condition func() bool, waitFor time.Duration...
type CollectT (line 2043) | type CollectT struct
method Helper (line 2051) | func (CollectT) Helper() {}
method Errorf (line 2054) | func (c *CollectT) Errorf(format string, args ...interface{}) {
method FailNow (line 2059) | func (c *CollectT) FailNow() {
method Reset (line 2065) | func (*CollectT) Reset() {
method Copy (line 2070) | func (*CollectT) Copy(TestingT) {
method fail (line 2074) | func (c *CollectT) fail() {
method failed (line 2080) | func (c *CollectT) failed() bool {
function EventuallyWithT (line 2102) | func EventuallyWithT(t TestingT, condition func(collect *CollectT), wait...
function Never (line 2154) | func Never(t TestingT, condition func() bool, waitFor time.Duration, tic...
function ErrorIs (line 2191) | func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) b...
function NotErrorIs (line 2217) | func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}...
function ErrorAs (line 2240) | func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...in...
function NotErrorAs (line 2264) | func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs .....
function unwrapAll (line 2280) | func unwrapAll(err error) (errs []error) {
function buildErrorChainString (line 2297) | func buildErrorChainString(err error, withType bool) string {
FILE: assert/assertions_test.go
type AssertionTesterInterface (line 89) | type AssertionTesterInterface interface
type AssertionTesterConformingObject (line 94) | type AssertionTesterConformingObject struct
method TestMethod (line 96) | func (a *AssertionTesterConformingObject) TestMethod() {
type AssertionTesterNonConformingObject (line 100) | type AssertionTesterNonConformingObject struct
function TestObjectsAreEqual (line 102) | func TestObjectsAreEqual(t *testing.T) {
function TestObjectsAreEqualValues (line 139) | func TestObjectsAreEqualValues(t *testing.T) {
type Nested (line 177) | type Nested struct
type S (line 182) | type S struct
type S2 (line 189) | type S2 struct
type S3 (line 193) | type S3 struct
type S4 (line 198) | type S4 struct
type S5 (line 202) | type S5 struct
type S6 (line 206) | type S6 struct
function TestObjectsExportedFieldsAreEqual (line 211) | func TestObjectsExportedFieldsAreEqual(t *testing.T) {
function TestCopyExportedFields (line 286) | func TestCopyExportedFields(t *testing.T) {
function TestEqualExportedValues (line 375) | func TestEqualExportedValues(t *testing.T) {
function TestImplements (line 530) | func TestImplements(t *testing.T) {
function TestNotImplements (line 546) | func TestNotImplements(t *testing.T) {
function TestIsType (line 562) | func TestIsType(t *testing.T) {
function TestNotIsType (line 575) | func TestNotIsType(t *testing.T) {
function TestEqual (line 588) | func TestEqual(t *testing.T) {
function ptr (line 631) | func ptr(i int) *int {
function TestSame (line 635) | func TestSame(t *testing.T) {
function TestNotSame (line 671) | func TestNotSame(t *testing.T) {
function Test_samePointers (line 691) | func Test_samePointers(t *testing.T) {
type bufferT (line 760) | type bufferT struct
method Helper (line 765) | func (bufferT) Helper() {}
method Errorf (line 767) | func (t *bufferT) Errorf(format string, args ...interface{}) {
function TestStringEqual (line 803) | func TestStringEqual(t *testing.T) {
function TestEqualFormatting (line 820) | func TestEqualFormatting(t *testing.T) {
function TestFormatUnequalValues (line 840) | func TestFormatUnequalValues(t *testing.T) {
function TestNotNil (line 868) | func TestNotNil(t *testing.T) {
function TestNil (line 884) | func TestNil(t *testing.T) {
function TestTrue (line 900) | func TestTrue(t *testing.T) {
function TestFalse (line 913) | func TestFalse(t *testing.T) {
function TestExactly (line 926) | func TestExactly(t *testing.T) {
function TestNotEqual (line 957) | func TestNotEqual(t *testing.T) {
function TestEqualValuesAndNotEqualValues (line 997) | func TestEqualValuesAndNotEqualValues(t *testing.T) {
function TestContainsNotContains (line 1053) | func TestContainsNotContains(t *testing.T) {
function TestContainsNotContainsFailMessage (line 1118) | func TestContainsNotContainsFailMessage(t *testing.T) {
function TestContainsNotContainsOnNilValue (line 1176) | func TestContainsNotContainsOnNilValue(t *testing.T) {
function TestSubsetNotSubset (line 1194) | func TestSubsetNotSubset(t *testing.T) {
function TestNotSubsetNil (line 1281) | func TestNotSubsetNil(t *testing.T) {
function Test_containsElement (line 1291) | func Test_containsElement(t *testing.T) {
function TestElementsMatch (line 1343) | func TestElementsMatch(t *testing.T) {
function TestDiffLists (line 1386) | func TestDiffLists(t *testing.T) {
function TestNotElementsMatch (line 1472) | func TestNotElementsMatch(t *testing.T) {
function TestCondition (line 1520) | func TestCondition(t *testing.T) {
function TestDidPanic (line 1534) | func TestDidPanic(t *testing.T) {
function TestPanics (line 1557) | func TestPanics(t *testing.T) {
function TestPanicsWithValue (line 1574) | func TestPanicsWithValue(t *testing.T) {
function TestPanicsWithError (line 1603) | func TestPanicsWithError(t *testing.T) {
type PanicsWithErrorWrapper (line 1636) | type PanicsWithErrorWrapper struct
method Error (line 1641) | func (e PanicsWithErrorWrapper) Error() string {
function TestNotPanics (line 1645) | func TestNotPanics(t *testing.T) {
function TestNoError (line 1662) | func TestNoError(t *testing.T) {
type customError (line 1690) | type customError struct
method Error (line 1692) | func (*customError) Error() string { return "fail" }
function TestError (line 1694) | func TestError(t *testing.T) {
function TestEqualError (line 1725) | func TestEqualError(t *testing.T) {
function TestErrorContains (line 1743) | func TestErrorContains(t *testing.T) {
function Test_isEmpty (line 1763) | func Test_isEmpty(t *testing.T) {
function Benchmark_isEmpty (line 1886) | func Benchmark_isEmpty(b *testing.B) {
function TestEmpty (line 1899) | func TestEmpty(t *testing.T) {
function TestNotEmpty (line 2081) | func TestNotEmpty(t *testing.T) {
function Test_getLen (line 2167) | func Test_getLen(t *testing.T) {
function TestLen (line 2214) | func TestLen(t *testing.T) {
function TestWithinDuration (line 2262) | func TestWithinDuration(t *testing.T) {
function TestWithinRange (line 2282) | func TestWithinRange(t *testing.T) {
function TestInDelta (line 2302) | func TestInDelta(t *testing.T) {
function TestInDeltaSlice (line 2342) | func TestInDeltaSlice(t *testing.T) {
function TestInDeltaMapValues (line 2365) | func TestInDeltaMapValues(t *testing.T) {
function TestInEpsilon (line 2445) | func TestInEpsilon(t *testing.T) {
function TestInEpsilonSlice (line 2501) | func TestInEpsilonSlice(t *testing.T) {
function TestRegexp (line 2519) | func TestRegexp(t *testing.T) {
function testAutogeneratedFunction (line 2560) | func testAutogeneratedFunction() {
function TestCallerInfoWithAutogeneratedFunctions (line 2574) | func TestCallerInfoWithAutogeneratedFunctions(t *testing.T) {
function TestZero (line 2582) | func TestZero(t *testing.T) {
function TestNotZero (line 2596) | func TestNotZero(t *testing.T) {
function TestFileExists (line 2610) | func TestFileExists(t *testing.T) {
function TestNoFileExists (line 2631) | func TestNoFileExists(t *testing.T) {
function getTempSymlinkPath (line 2652) | func getTempSymlinkPath(t *testing.T, file string) string {
function TestDirExists (line 2663) | func TestDirExists(t *testing.T) {
function TestNoDirExists (line 2684) | func TestNoDirExists(t *testing.T) {
function TestJSONEq_EqualSONString (line 2705) | func TestJSONEq_EqualSONString(t *testing.T) {
function TestJSONEq_EquivalentButNotEqual (line 2712) | func TestJSONEq_EquivalentButNotEqual(t *testing.T) {
function TestJSONEq_HashOfArraysAndHashes (line 2719) | func TestJSONEq_HashOfArraysAndHashes(t *testing.T) {
function TestJSONEq_Array (line 2727) | func TestJSONEq_Array(t *testing.T) {
function TestJSONEq_HashAndArrayNotEquivalent (line 2734) | func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) {
function TestJSONEq_HashesNotEquivalent (line 2741) | func TestJSONEq_HashesNotEquivalent(t *testing.T) {
function TestJSONEq_ActualIsNotJSON (line 2748) | func TestJSONEq_ActualIsNotJSON(t *testing.T) {
function TestJSONEq_ExpectedIsNotJSON (line 2755) | func TestJSONEq_ExpectedIsNotJSON(t *testing.T) {
function TestJSONEq_ExpectedAndActualNotJSON (line 2762) | func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) {
function TestJSONEq_ArraysOfDifferentOrder (line 2769) | func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) {
function TestYAMLEq_EqualYAMLString (line 2776) | func TestYAMLEq_EqualYAMLString(t *testing.T) {
function TestYAMLEq_EquivalentButNotEqual (line 2783) | func TestYAMLEq_EquivalentButNotEqual(t *testing.T) {
function TestYAMLEq_HashOfArraysAndHashes (line 2790) | func TestYAMLEq_HashOfArraysAndHashes(t *testing.T) {
function TestYAMLEq_Array (line 2822) | func TestYAMLEq_Array(t *testing.T) {
function TestYAMLEq_HashAndArrayNotEquivalent (line 2829) | func TestYAMLEq_HashAndArrayNotEquivalent(t *testing.T) {
function TestYAMLEq_HashesNotEquivalent (line 2836) | func TestYAMLEq_HashesNotEquivalent(t *testing.T) {
function TestYAMLEq_ActualIsSimpleString (line 2843) | func TestYAMLEq_ActualIsSimpleString(t *testing.T) {
function TestYAMLEq_ExpectedIsSimpleString (line 2850) | func TestYAMLEq_ExpectedIsSimpleString(t *testing.T) {
function TestYAMLEq_ExpectedAndActualSimpleString (line 2857) | func TestYAMLEq_ExpectedAndActualSimpleString(t *testing.T) {
function TestYAMLEq_ArraysOfDifferentOrder (line 2864) | func TestYAMLEq_ArraysOfDifferentOrder(t *testing.T) {
function TestYAMLEq_OnlyFirstDocument (line 2871) | func TestYAMLEq_OnlyFirstDocument(t *testing.T) {
function TestYAMLEq_InvalidIdenticalYAML (line 2889) | func TestYAMLEq_InvalidIdenticalYAML(t *testing.T) {
type diffTestingStruct (line 2896) | type diffTestingStruct struct
method String (line 2901) | func (d *diffTestingStruct) String() string {
function TestDiff (line 2905) | func TestDiff(t *testing.T) {
function TestTimeEqualityErrorFormatting (line 3041) | func TestTimeEqualityErrorFormatting(t *testing.T) {
function TestDiffEmptyCases (line 3052) | func TestDiffEmptyCases(t *testing.T) {
function TestDiffRace (line 3064) | func TestDiffRace(t *testing.T) {
type mockTestingT (line 3097) | type mockTestingT struct
method Helper (line 3103) | func (mockTestingT) Helper() {}
method errorString (line 3105) | func (m *mockTestingT) errorString() string {
method Errorf (line 3109) | func (m *mockTestingT) Errorf(format string, args ...interface{}) {
method Failed (line 3114) | func (m *mockTestingT) Failed() bool {
function TestFailNowWithPlainTestingT (line 3118) | func TestFailNowWithPlainTestingT(t *testing.T) {
type mockFailNowTestingT (line 3128) | type mockFailNowTestingT struct
method Helper (line 3131) | func (mockFailNowTestingT) Helper() {}
method Errorf (line 3133) | func (m *mockFailNowTestingT) Errorf(format string, args ...interface{...
method FailNow (line 3135) | func (m *mockFailNowTestingT) FailNow() {}
function TestFailNowWithFullTestingT (line 3137) | func TestFailNowWithFullTestingT(t *testing.T) {
function TestBytesEqual (line 3147) | func TestBytesEqual(t *testing.T) {
function BenchmarkBytesEqual (line 3162) | func BenchmarkBytesEqual(b *testing.B) {
function BenchmarkNotNil (line 3178) | func BenchmarkNotNil(b *testing.B) {
function ExampleComparisonAssertionFunc (line 3184) | func ExampleComparisonAssertionFunc() {
function TestComparisonAssertionFunc (line 3214) | func TestComparisonAssertionFunc(t *testing.T) {
function ExampleValueAssertionFunc (line 3249) | func ExampleValueAssertionFunc() {
function TestValueAssertionFunc (line 3277) | func TestValueAssertionFunc(t *testing.T) {
function ExampleBoolAssertionFunc (line 3300) | func ExampleBoolAssertionFunc() {
function TestBoolAssertionFunc (line 3325) | func TestBoolAssertionFunc(t *testing.T) {
function ExampleErrorAssertionFunc (line 3344) | func ExampleErrorAssertionFunc() {
function TestErrorAssertionFunc (line 3370) | func TestErrorAssertionFunc(t *testing.T) {
function ExamplePanicAssertionFunc (line 3389) | func ExamplePanicAssertionFunc() {
function TestPanicAssertionFunc (line 3408) | func TestPanicAssertionFunc(t *testing.T) {
function TestEventuallyFalse (line 3427) | func TestEventuallyFalse(t *testing.T) {
function TestEventuallyTrue (line 3439) | func TestEventuallyTrue(t *testing.T) {
type errorsCapturingT (line 3454) | type errorsCapturingT struct
method Helper (line 3459) | func (errorsCapturingT) Helper() {}
method Errorf (line 3461) | func (t *errorsCapturingT) Errorf(format string, args ...interface{}) {
function TestEventuallyWithTFalse (line 3465) | func TestEventuallyWithTFalse(t *testing.T) {
function TestEventuallyWithTTrue (line 3478) | func TestEventuallyWithTTrue(t *testing.T) {
function TestEventuallyWithT_ConcurrencySafe (line 3494) | func TestEventuallyWithT_ConcurrencySafe(t *testing.T) {
function TestEventuallyWithT_ReturnsTheLatestFinishedConditionErrors (line 3508) | func TestEventuallyWithT_ReturnsTheLatestFinishedConditionErrors(t *test...
function TestEventuallyWithTFailNow (line 3533) | func TestEventuallyWithTFailNow(t *testing.T) {
function TestEventuallyTimeout (line 3548) | func TestEventuallyTimeout(t *testing.T) {
function TestEventuallySucceedQuickly (line 3571) | func TestEventuallySucceedQuickly(t *testing.T) {
function TestEventuallyWithTSucceedQuickly (line 3583) | func TestEventuallyWithTSucceedQuickly(t *testing.T) {
function TestNeverFalse (line 3595) | func TestNeverFalse(t *testing.T) {
function TestNeverTrue (line 3606) | func TestNeverTrue(t *testing.T) {
function TestNeverFailQuickly (line 3626) | func TestNeverFailQuickly(t *testing.T) {
function Test_validateEqualArgs (line 3637) | func Test_validateEqualArgs(t *testing.T) {
function Test_truncatingFormat (line 3653) | func Test_truncatingFormat(t *testing.T) {
function parseLabeledOutput (line 3671) | func parseLabeledOutput(output string) []labeledContent {
type captureTestingT (line 3706) | type captureTestingT struct
method Helper (line 3712) | func (captureTestingT) Helper() {}
method Errorf (line 3714) | func (ctt *captureTestingT) Errorf(format string, args ...interface{}) {
method checkResultAndErrMsg (line 3719) | func (ctt *captureTestingT) checkResultAndErrMsg(t *testing.T, expecte...
function TestErrorIs (line 3751) | func TestErrorIs(t *testing.T) {
function TestNotErrorIs (line 3820) | func TestNotErrorIs(t *testing.T) {
function TestErrorAs (line 3888) | func TestErrorAs(t *testing.T) {
function TestNotErrorAs (line 3936) | func TestNotErrorAs(t *testing.T) {
function TestLenWithSliceTooLongToPrint (line 3973) | func TestLenWithSliceTooLongToPrint(t *testing.T) {
function TestContainsWithSliceTooLongToPrint (line 3984) | func TestContainsWithSliceTooLongToPrint(t *testing.T) {
function TestNotContainsWithSliceTooLongToPrint (line 3995) | func TestNotContainsWithSliceTooLongToPrint(t *testing.T) {
function TestSubsetWithSliceTooLongToPrint (line 4006) | func TestSubsetWithSliceTooLongToPrint(t *testing.T) {
function TestSubsetWithMapTooLongToPrint (line 4017) | func TestSubsetWithMapTooLongToPrint(t *testing.T) {
function TestNotSubsetWithSliceTooLongToPrint (line 4028) | func TestNotSubsetWithSliceTooLongToPrint(t *testing.T) {
function TestNotSubsetWithMapTooLongToPrint (line 4039) | func TestNotSubsetWithMapTooLongToPrint(t *testing.T) {
function TestSameWithSliceTooLongToPrint (line 4050) | func TestSameWithSliceTooLongToPrint(t *testing.T) {
function TestNotSameWithSliceTooLongToPrint (line 4058) | func TestNotSameWithSliceTooLongToPrint(t *testing.T) {
function TestNilWithSliceTooLongToPrint (line 4066) | func TestNilWithSliceTooLongToPrint(t *testing.T) {
function TestEmptyWithSliceTooLongToPrint (line 4077) | func TestEmptyWithSliceTooLongToPrint(t *testing.T) {
function TestNotEqualWithSliceTooLongToPrint (line 4088) | func TestNotEqualWithSliceTooLongToPrint(t *testing.T) {
function TestNotEqualValuesWithSliceTooLongToPrint (line 4099) | func TestNotEqualValuesWithSliceTooLongToPrint(t *testing.T) {
function TestNoErrorWithErrorTooLongToPrint (line 4110) | func TestNoErrorWithErrorTooLongToPrint(t *testing.T) {
function TestEqualErrorWithErrorTooLongToPrint (line 4122) | func TestEqualErrorWithErrorTooLongToPrint(t *testing.T) {
function TestErrorContainsWithErrorTooLongToPrint (line 4135) | func TestErrorContainsWithErrorTooLongToPrint(t *testing.T) {
function TestZeroWithSliceTooLongToPrint (line 4146) | func TestZeroWithSliceTooLongToPrint(t *testing.T) {
function TestErrorIsWithErrorTooLongToPrint (line 4157) | func TestErrorIsWithErrorTooLongToPrint(t *testing.T) {
function TestNotErrorIsWithErrorTooLongToPrint (line 4170) | func TestNotErrorIsWithErrorTooLongToPrint(t *testing.T) {
function TestErrorAsWithErrorTooLongToPrint (line 4184) | func TestErrorAsWithErrorTooLongToPrint(t *testing.T) {
function TestNotErrorAsWithErrorTooLongToPrint (line 4199) | func TestNotErrorAsWithErrorTooLongToPrint(t *testing.T) {
FILE: assert/forward_assertions.go
type Assertions (line 5) | type Assertions struct
function New (line 10) | func New(t TestingT) *Assertions {
FILE: assert/forward_assertions_test.go
function TestImplementsWrapper (line 10) | func TestImplementsWrapper(t *testing.T) {
function TestIsTypeWrapper (line 23) | func TestIsTypeWrapper(t *testing.T) {
function TestEqualWrapper (line 37) | func TestEqualWrapper(t *testing.T) {
function TestEqualValuesWrapper (line 59) | func TestEqualValuesWrapper(t *testing.T) {
function TestNotNilWrapper (line 69) | func TestNotNilWrapper(t *testing.T) {
function TestNilWrapper (line 83) | func TestNilWrapper(t *testing.T) {
function TestTrueWrapper (line 97) | func TestTrueWrapper(t *testing.T) {
function TestFalseWrapper (line 111) | func TestFalseWrapper(t *testing.T) {
function TestExactlyWrapper (line 125) | func TestExactlyWrapper(t *testing.T) {
function TestNotEqualWrapper (line 154) | func TestNotEqualWrapper(t *testing.T) {
function TestNotEqualValuesWrapper (line 176) | func TestNotEqualValuesWrapper(t *testing.T) {
function TestContainsWrapper (line 201) | func TestContainsWrapper(t *testing.T) {
function TestNotContainsWrapper (line 223) | func TestNotContainsWrapper(t *testing.T) {
function TestConditionWrapper (line 245) | func TestConditionWrapper(t *testing.T) {
function TestDidPanicWrapper (line 260) | func TestDidPanicWrapper(t *testing.T) {
function TestPanicsWrapper (line 276) | func TestPanicsWrapper(t *testing.T) {
function TestNotPanicsWrapper (line 294) | func TestNotPanicsWrapper(t *testing.T) {
function TestNoErrorWrapper (line 312) | func TestNoErrorWrapper(t *testing.T) {
function TestErrorWrapper (line 330) | func TestErrorWrapper(t *testing.T) {
function TestErrorContainsWrapper (line 348) | func TestErrorContainsWrapper(t *testing.T) {
function TestEqualErrorWrapper (line 369) | func TestEqualErrorWrapper(t *testing.T) {
function TestEmptyWrapper (line 388) | func TestEmptyWrapper(t *testing.T) {
function TestNotEmptyWrapper (line 408) | func TestNotEmptyWrapper(t *testing.T) {
function TestLenWrapper (line 428) | func TestLenWrapper(t *testing.T) {
function TestWithinDurationWrapper (line 470) | func TestWithinDurationWrapper(t *testing.T) {
function TestInDeltaWrapper (line 491) | func TestInDeltaWrapper(t *testing.T) {
function TestInEpsilonWrapper (line 527) | func TestInEpsilonWrapper(t *testing.T) {
function TestRegexpWrapper (line 567) | func TestRegexpWrapper(t *testing.T) {
function TestZeroWrapper (line 603) | func TestZeroWrapper(t *testing.T) {
function TestNotZeroWrapper (line 618) | func TestNotZeroWrapper(t *testing.T) {
function TestJSONEqWrapper_EqualSONString (line 633) | func TestJSONEqWrapper_EqualSONString(t *testing.T) {
function TestJSONEqWrapper_EquivalentButNotEqual (line 643) | func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) {
function TestJSONEqWrapper_HashOfArraysAndHashes (line 653) | func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) {
function TestJSONEqWrapper_Array (line 663) | func TestJSONEqWrapper_Array(t *testing.T) {
function TestJSONEqWrapper_HashAndArrayNotEquivalent (line 673) | func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
function TestJSONEqWrapper_HashesNotEquivalent (line 682) | func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) {
function TestJSONEqWrapper_ActualIsNotJSON (line 691) | func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) {
function TestJSONEqWrapper_ExpectedIsNotJSON (line 700) | func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) {
function TestJSONEqWrapper_ExpectedAndActualNotJSON (line 709) | func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) {
function TestJSONEqWrapper_ArraysOfDifferentOrder (line 718) | func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
function TestYAMLEqWrapper_EqualYAMLString (line 727) | func TestYAMLEqWrapper_EqualYAMLString(t *testing.T) {
function TestYAMLEqWrapper_EquivalentButNotEqual (line 737) | func TestYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) {
function TestYAMLEqWrapper_HashOfArraysAndHashes (line 747) | func TestYAMLEqWrapper_HashOfArraysAndHashes(t *testing.T) {
function TestYAMLEqWrapper_Array (line 781) | func TestYAMLEqWrapper_Array(t *testing.T) {
function TestYAMLEqWrapper_HashAndArrayNotEquivalent (line 791) | func TestYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
function TestYAMLEqWrapper_HashesNotEquivalent (line 800) | func TestYAMLEqWrapper_HashesNotEquivalent(t *testing.T) {
function TestYAMLEqWrapper_ActualIsSimpleString (line 809) | func TestYAMLEqWrapper_ActualIsSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ExpectedIsSimpleString (line 818) | func TestYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ExpectedAndActualSimpleString (line 827) | func TestYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ArraysOfDifferentOrder (line 836) | func TestYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
FILE: assert/http_assertions.go
function httpCode (line 13) | func httpCode(handler http.HandlerFunc, method, url string, values url.V...
function HTTPSuccess (line 29) | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url strin...
function HTTPRedirect (line 51) | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url stri...
function HTTPError (line 73) | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string,...
function HTTPStatusCode (line 95) | func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url st...
function HTTPBody (line 114) | func HTTPBody(handler http.HandlerFunc, method, url string, values url.V...
function HTTPBodyContains (line 133) | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url ...
function HTTPBodyNotContains (line 153) | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, u...
FILE: assert/http_assertions_test.go
function httpOK (line 11) | func httpOK(w http.ResponseWriter, r *http.Request) {
function httpReadBody (line 15) | func httpReadBody(w http.ResponseWriter, r *http.Request) {
function httpRedirect (line 21) | func httpRedirect(w http.ResponseWriter, r *http.Request) {
function httpError (line 25) | func httpError(w http.ResponseWriter, r *http.Request) {
function httpStatusCode (line 29) | func httpStatusCode(w http.ResponseWriter, r *http.Request) {
function TestHTTPSuccess (line 33) | func TestHTTPSuccess(t *testing.T) {
function TestHTTPRedirect (line 63) | func TestHTTPRedirect(t *testing.T) {
function TestHTTPError (line 89) | func TestHTTPError(t *testing.T) {
function TestHTTPStatusCode (line 115) | func TestHTTPStatusCode(t *testing.T) {
function TestHTTPStatusesWrapper (line 141) | func TestHTTPStatusesWrapper(t *testing.T) {
function httpHelloName (line 160) | func httpHelloName(w http.ResponseWriter, r *http.Request) {
function TestHTTPRequestWithNoParams (line 165) | func TestHTTPRequestWithNoParams(t *testing.T) {
function TestHTTPRequestWithParams (line 180) | func TestHTTPRequestWithParams(t *testing.T) {
function TestHttpBody (line 198) | func TestHttpBody(t *testing.T) {
function TestHttpBodyWrappers (line 219) | func TestHttpBodyWrappers(t *testing.T) {
FILE: assert/internal/unsafetests/unsafetests_test.go
type ignoreTestingT (line 11) | type ignoreTestingT struct
method Helper (line 15) | func (ignoreTestingT) Helper() {}
method Errorf (line 17) | func (ignoreTestingT) Errorf(format string, args ...interface{}) {
function TestUnsafePointers (line 23) | func TestUnsafePointers(t *testing.T) {
FILE: assert/yaml/yaml_default.go
function Unmarshal (line 34) | func Unmarshal(in []byte, out interface{}) error {
FILE: assert/yaml/yaml_fail.go
function Unmarshal (line 15) | func Unmarshal([]byte, interface{}) error {
FILE: http/test_response_writer.go
type TestResponseWriter (line 8) | type TestResponseWriter struct
method Header (line 21) | func (rw *TestResponseWriter) Header() http.Header {
method Write (line 31) | func (rw *TestResponseWriter) Write(bytes []byte) (int, error) {
method WriteHeader (line 47) | func (rw *TestResponseWriter) WriteHeader(i int) {
FILE: http/test_round_tripper.go
type TestRoundTripper (line 10) | type TestRoundTripper struct
method RoundTrip (line 15) | func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Respons...
FILE: internal/difflib/difflib.go
function min (line 29) | func min(a, b int) int {
function max (line 36) | func max(a, b int) int {
type Match (line 43) | type Match struct
type OpCode (line 49) | type OpCode struct
type SequenceMatcher (line 83) | type SequenceMatcher struct
method SetSeqs (line 103) | func (m *SequenceMatcher) SetSeqs(a, b []string) {
method SetSeq1 (line 117) | func (m *SequenceMatcher) SetSeq1(a []string) {
method SetSeq2 (line 128) | func (m *SequenceMatcher) SetSeq2(b []string) {
method chainB (line 139) | func (m *SequenceMatcher) chainB() {
method isBJunk (line 180) | func (m *SequenceMatcher) isBJunk(s string) bool {
method findLongestMatch (line 212) | func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Mat...
method GetMatchingBlocks (line 296) | func (m *SequenceMatcher) GetMatchingBlocks() []Match {
method GetOpCodes (line 364) | func (m *SequenceMatcher) GetOpCodes() []OpCode {
method GetGroupedOpCodes (line 404) | func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
function NewMatcher (line 96) | func NewMatcher(a, b []string) *SequenceMatcher {
function formatRangeUnified (line 446) | func formatRangeUnified(start, stop int) string {
type UnifiedDiff (line 460) | type UnifiedDiff struct
function WriteUnifiedDiff (line 490) | func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
function GetUnifiedDiffString (line 566) | func GetUnifiedDiffString(diff UnifiedDiff) (string, error) {
function formatRangeContext (line 573) | func formatRangeContext(start, stop int) string {
function SplitLines (line 588) | func SplitLines(s string) []string {
FILE: internal/difflib/difflib_test.go
function assertAlmostEqual (line 12) | func assertAlmostEqual(t *testing.T, a, b float64, places int) {
function assertEqual (line 18) | func assertEqual(t *testing.T, a, b interface{}) {
function splitChars (line 24) | func splitChars(s string) []string {
function TestGetOptCodes (line 33) | func TestGetOptCodes(t *testing.T) {
function TestGroupedOpCodes (line 54) | func TestGroupedOpCodes(t *testing.T) {
function rep (line 98) | func rep(s string, count int) string {
function TestWithAsciiOneInsert (line 102) | func TestWithAsciiOneInsert(t *testing.T) {
function TestWithAsciiOnDelete (line 116) | func TestWithAsciiOnDelete(t *testing.T) {
function TestSFBugsComparingEmptyLists (line 123) | func TestSFBugsComparingEmptyLists(t *testing.T) {
function TestOutputFormatRangeFormatUnified (line 136) | func TestOutputFormatRangeFormatUnified(t *testing.T) {
function TestOutputFormatRangeFormatContext (line 153) | func TestOutputFormatRangeFormatContext(t *testing.T) {
function TestOutputFormatTabDelimiter (line 177) | func TestOutputFormatTabDelimiter(t *testing.T) {
function TestOutputFormatNoTrailingTabOnEmptyFiledate (line 195) | func TestOutputFormatNoTrailingTabOnEmptyFiledate(t *testing.T) {
function TestOmitFilenames (line 208) | func TestOmitFilenames(t *testing.T) {
function TestSplitLines (line 227) | func TestSplitLines(t *testing.T) {
function benchmarkSplitLines (line 241) | func benchmarkSplitLines(b *testing.B, count int) {
function BenchmarkSplitLines100 (line 252) | func BenchmarkSplitLines100(b *testing.B) {
function BenchmarkSplitLines10000 (line 256) | func BenchmarkSplitLines10000(b *testing.B) {
FILE: internal/spew/bypass.go
constant UnsafeDisabled (line 34) | UnsafeDisabled = false
constant ptrSize (line 37) | ptrSize = unsafe.Sizeof((*byte)(nil))
type flag (line 40) | type flag
constant flagKindMask (line 55) | flagKindMask = flag(0x1f)
function flagField (line 81) | func flagField(v *reflect.Value) *flag {
function unsafeReflectValue (line 94) | func unsafeReflectValue(v reflect.Value) reflect.Value {
function init (line 106) | func init() {
FILE: internal/spew/bypasssafe.go
constant UnsafeDisabled (line 29) | UnsafeDisabled = true
function unsafeReflectValue (line 37) | func unsafeReflectValue(v reflect.Value) reflect.Value {
FILE: internal/spew/common.go
function catchPanic (line 72) | func catchPanic(w io.Writer, v reflect.Value) {
function handleMethods (line 85) | func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handl...
function printBool (line 144) | func printBool(w io.Writer, val bool) {
function printInt (line 153) | func printInt(w io.Writer, val int64, base int) {
function printUint (line 158) | func printUint(w io.Writer, val uint64, base int) {
function printFloat (line 164) | func printFloat(w io.Writer, val float64, precision int) {
function printComplex (line 170) | func printComplex(w io.Writer, c complex128, floatPrecision int) {
function printHexPtr (line 185) | func printHexPtr(w io.Writer, p uintptr) {
type valuesSorter (line 219) | type valuesSorter struct
method Len (line 279) | func (s *valuesSorter) Len() int {
method Swap (line 285) | func (s *valuesSorter) Swap(i, j int) {
method Less (line 326) | func (s *valuesSorter) Less(i, j int) bool {
function newValuesSorter (line 228) | func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Inter...
function canSortSimply (line 256) | func canSortSimply(kind reflect.Kind) bool {
function valueSortLess (line 295) | func valueSortLess(a, b reflect.Value) bool {
function sortValues (line 336) | func sortValues(values []reflect.Value, cs *ConfigState) {
FILE: internal/spew/common_test.go
type stringer (line 28) | type stringer
method String (line 32) | func (s stringer) String() string {
type pstringer (line 37) | type pstringer
method String (line 41) | func (s *pstringer) String() string {
type xref1 (line 47) | type xref1 struct
type xref2 (line 50) | type xref2 struct
type indirCir1 (line 56) | type indirCir1 struct
type indirCir2 (line 59) | type indirCir2 struct
type indirCir3 (line 62) | type indirCir3 struct
type embed (line 67) | type embed struct
type embedwrap (line 72) | type embedwrap struct
type panicer (line 79) | type panicer
method String (line 81) | func (p panicer) String() string {
type customError (line 86) | type customError
method Error (line 88) | func (e customError) Error() string {
function stringizeWants (line 94) | func stringizeWants(wants []string) string {
function testFailed (line 108) | func testFailed(result string, wants []string) bool {
type sortableStruct (line 117) | type sortableStruct struct
method String (line 121) | func (ss sortableStruct) String() string {
type unsortableStruct (line 125) | type unsortableStruct struct
type sortTestCase (line 129) | type sortTestCase struct
function helpTestSortValues (line 134) | func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *t...
function TestSortValues (line 159) | func TestSortValues(t *testing.T) {
function TestSortValuesWithMethods (line 233) | func TestSortValuesWithMethods(t *testing.T) {
function TestSortValuesWithSpew (line 268) | func TestSortValuesWithSpew(t *testing.T) {
FILE: internal/spew/config.go
type ConfigState (line 37) | type ConfigState struct
method Errorf (line 115) | func (c *ConfigState) Errorf(format string, a ...interface{}) (err err...
method Fprint (line 127) | func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, er...
method Fprintf (line 139) | func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interfa...
method Fprintln (line 150) | func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, ...
method Print (line 162) | func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
method Printf (line 174) | func (c *ConfigState) Printf(format string, a ...interface{}) (n int, ...
method Println (line 186) | func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
method Sprint (line 197) | func (c *ConfigState) Sprint(a ...interface{}) string {
method Sprintf (line 208) | func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
method Sprintln (line 219) | func (c *ConfigState) Sprintln(a ...interface{}) string {
method NewFormatter (line 240) | func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
method Fdump (line 246) | func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
method Dump (line 273) | func (c *ConfigState) Dump(a ...interface{}) {
method Sdump (line 279) | func (c *ConfigState) Sdump(a ...interface{}) string {
method convertArgs (line 288) | func (c *ConfigState) convertArgs(args []interface{}) (formatters []in...
function NewDefaultConfig (line 304) | func NewDefaultConfig() *ConfigState {
FILE: internal/spew/dump.go
type dumpState (line 51) | type dumpState struct
method indent (line 62) | func (d *dumpState) indent() {
method unpackValue (line 73) | func (d *dumpState) unpackValue(v reflect.Value) reflect.Value {
method dumpPtr (line 81) | func (d *dumpState) dumpPtr(v reflect.Value) {
method dumpSlice (line 161) | func (d *dumpState) dumpSlice(v reflect.Value) {
method dump (line 251) | func (d *dumpState) dump(v reflect.Value) {
function fdump (line 453) | func fdump(cs *ConfigState, w io.Writer, a ...interface{}) {
function Fdump (line 472) | func Fdump(w io.Writer, a ...interface{}) {
function Sdump (line 478) | func Sdump(a ...interface{}) string {
function Dump (line 507) | func Dump(a ...interface{}) {
FILE: internal/spew/dump_test.go
type dumpTest (line 74) | type dumpTest struct
function addDumpTest (line 84) | func addDumpTest(in interface{}, wants ...string) {
function addIntDumpTests (line 89) | func addIntDumpTests() {
function addUintDumpTests (line 156) | func addUintDumpTests() {
function addBoolDumpTests (line 223) | func addBoolDumpTests() {
function addFloatDumpTests (line 249) | func addFloatDumpTests() {
function addComplexDumpTests (line 277) | func addComplexDumpTests() {
function addArrayDumpTests (line 305) | func addArrayDumpTests() {
function addSliceDumpTests (line 403) | func addSliceDumpTests() {
function addStringDumpTests (line 508) | func addStringDumpTests() {
function addInterfaceDumpTests (line 524) | func addInterfaceDumpTests() {
function addMapDumpTests (line 550) | func addMapDumpTests() {
function addStructDumpTests (line 651) | func addStructDumpTests() {
function addUintptrDumpTests (line 742) | func addUintptrDumpTests() {
function addUnsafePointerDumpTests (line 769) | func addUnsafePointerDumpTests() {
function addChanDumpTests (line 797) | func addChanDumpTests() {
function addFuncDumpTests (line 823) | func addFuncDumpTests() {
function addCircularDumpTests (line 866) | func addCircularDumpTests() {
function addPanicDumpTests (line 929) | func addPanicDumpTests() {
function addErrorDumpTests (line 944) | func addErrorDumpTests() {
function TestDump (line 960) | func TestDump(t *testing.T) {
function TestDumpSortedKeys (line 994) | func TestDumpSortedKeys(t *testing.T) {
FILE: internal/spew/dumpcgo_test.go
function addCgoDumpTests (line 34) | func addCgoDumpTests() {
FILE: internal/spew/dumpnocgo_test.go
function addCgoDumpTests (line 24) | func addCgoDumpTests() {
FILE: internal/spew/format.go
constant supportedFlags (line 28) | supportedFlags = "0-+# "
type formatState (line 34) | type formatState struct
method buildDefaultFormat (line 47) | func (f *formatState) buildDefaultFormat() (format string) {
method constructOrigFormat (line 65) | func (f *formatState) constructOrigFormat(verb rune) (format string) {
method unpackValue (line 94) | func (f *formatState) unpackValue(v reflect.Value) reflect.Value {
method formatPtr (line 105) | func (f *formatState) formatPtr(v reflect.Value) {
method format (line 201) | func (f *formatState) format(v reflect.Value) {
method Format (line 371) | func (f *formatState) Format(fs fmt.State, verb rune) {
function newFormatter (line 394) | func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
function NewFormatter (line 417) | func NewFormatter(v interface{}) fmt.Formatter {
FILE: internal/spew/format_test.go
type formatterTest (line 79) | type formatterTest struct
function addFormatterTest (line 90) | func addFormatterTest(format string, in interface{}, wants ...string) {
function addIntFormatterTests (line 95) | func addIntFormatterTests() {
function addUintFormatterTests (line 222) | func addUintFormatterTests() {
function addBoolFormatterTests (line 349) | func addBoolFormatterTests() {
function addFloatFormatterTests (line 396) | func addFloatFormatterTests() {
function addComplexFormatterTests (line 448) | func addComplexFormatterTests() {
function addArrayFormatterTests (line 500) | func addArrayFormatterTests() {
function addSliceFormatterTests (line 585) | func addSliceFormatterTests() {
function addStringFormatterTests (line 693) | func addStringFormatterTests() {
function addInterfaceFormatterTests (line 720) | func addInterfaceFormatterTests() {
function addMapFormatterTests (line 767) | func addMapFormatterTests() {
function addStructFormatterTests (line 886) | func addStructFormatterTests() {
function addUintptrFormatterTests (line 1036) | func addUintptrFormatterTests() {
function addUnsafePointerFormatterTests (line 1084) | func addUnsafePointerFormatterTests() {
function addChanFormatterTests (line 1132) | func addChanFormatterTests() {
function addFuncFormatterTests (line 1179) | func addFuncFormatterTests() {
function addCircularFormatterTests (line 1258) | func addCircularFormatterTests() {
function addPanicFormatterTests (line 1370) | func addPanicFormatterTests() {
function addErrorFormatterTests (line 1397) | func addErrorFormatterTests() {
function addPassthroughFormatterTests (line 1424) | func addPassthroughFormatterTests() {
function TestFormatter (line 1465) | func TestFormatter(t *testing.T) {
type testStruct (line 1500) | type testStruct struct
method String (line 1504) | func (ts testStruct) String() string {
type testStructP (line 1508) | type testStructP struct
method String (line 1512) | func (ts *testStructP) String() string {
function TestPrintSortedKeys (line 1516) | func TestPrintSortedKeys(t *testing.T) {
FILE: internal/spew/internal_test.go
type dummyFmtState (line 34) | type dummyFmtState struct
method Flag (line 38) | func (dfs *dummyFmtState) Flag(f int) bool {
method Precision (line 42) | func (dfs *dummyFmtState) Precision() (int, bool) {
method Width (line 46) | func (dfs *dummyFmtState) Width() (int, bool) {
function TestInvalidReflectValue (line 54) | func TestInvalidReflectValue(t *testing.T) {
function SortValues (line 82) | func SortValues(values []reflect.Value, cs *ConfigState) {
FILE: internal/spew/internalunsafe_test.go
function changeKind (line 40) | func changeKind(v *reflect.Value, readOnly bool) {
function TestAddedReflectValue (line 53) | func TestAddedReflectValue(t *testing.T) {
FILE: internal/spew/spew.go
function Errorf (line 32) | func Errorf(format string, a ...interface{}) (err error) {
function Fprint (line 44) | func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
function Fprintf (line 56) | func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err e...
function Fprintln (line 67) | func Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
function Print (line 79) | func Print(a ...interface{}) (n int, err error) {
function Printf (line 91) | func Printf(format string, a ...interface{}) (n int, err error) {
function Println (line 103) | func Println(a ...interface{}) (n int, err error) {
function Sprint (line 114) | func Sprint(a ...interface{}) string {
function Sprintf (line 125) | func Sprintf(format string, a ...interface{}) string {
function Sprintln (line 136) | func Sprintln(a ...interface{}) string {
function convertArgs (line 142) | func convertArgs(args []interface{}) (formatters []interface{}) {
FILE: internal/spew/spew_test.go
type spewFunc (line 31) | type spewFunc
method String (line 82) | func (f spewFunc) String() string {
constant fCSFdump (line 34) | fCSFdump spewFunc = iota
constant fCSFprint (line 35) | fCSFprint
constant fCSFprintf (line 36) | fCSFprintf
constant fCSFprintln (line 37) | fCSFprintln
constant fCSPrint (line 38) | fCSPrint
constant fCSPrintln (line 39) | fCSPrintln
constant fCSSdump (line 40) | fCSSdump
constant fCSSprint (line 41) | fCSSprint
constant fCSSprintf (line 42) | fCSSprintf
constant fCSSprintln (line 43) | fCSSprintln
constant fCSErrorf (line 44) | fCSErrorf
constant fCSNewFormatter (line 45) | fCSNewFormatter
constant fErrorf (line 46) | fErrorf
constant fFprint (line 47) | fFprint
constant fFprintln (line 48) | fFprintln
constant fPrint (line 49) | fPrint
constant fPrintln (line 50) | fPrintln
constant fSdump (line 51) | fSdump
constant fSprint (line 52) | fSprint
constant fSprintf (line 53) | fSprintf
constant fSprintln (line 54) | fSprintln
type spewTest (line 91) | type spewTest struct
function redirStdout (line 109) | func redirStdout(f func()) ([]byte, error) {
function initSpewTests (line 126) | func initSpewTests() {
function TestSpew (line 210) | func TestSpew(t *testing.T) {
FILE: internal/spew/testdata/dumpcgo.go
function GetCgoNullCharPointer (line 46) | func GetCgoNullCharPointer() interface{} {
function GetCgoCharPointer (line 52) | func GetCgoCharPointer() interface{} {
function GetCgoCharArray (line 58) | func GetCgoCharArray() (interface{}, int, int) {
function GetCgoUnsignedCharArray (line 64) | func GetCgoUnsignedCharArray() (interface{}, int, int) {
function GetCgoSignedCharArray (line 70) | func GetCgoSignedCharArray() (interface{}, int, int) {
function GetCgoUint8tArray (line 76) | func GetCgoUint8tArray() (interface{}, int, int) {
function GetCgoTypdefedUnsignedCharArray (line 82) | func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) {
FILE: mock/mock.go
type TestingT (line 25) | type TestingT interface
type Call (line 37) | type Call struct
method lock (line 97) | func (c *Call) lock() {
method unlock (line 101) | func (c *Call) unlock() {
method Return (line 108) | func (c *Call) Return(returnArguments ...interface{}) *Call {
method Panic (line 120) | func (c *Call) Panic(msg string) *Call {
method Once (line 132) | func (c *Call) Once() *Call {
method Twice (line 139) | func (c *Call) Twice() *Call {
method Times (line 147) | func (c *Call) Times(i int) *Call {
method WaitUntil (line 158) | func (c *Call) WaitUntil(w <-chan time.Time) *Call {
method After (line 168) | func (c *Call) After(d time.Duration) *Call {
method Run (line 183) | func (c *Call) Run(fn func(args Arguments)) *Call {
method Maybe (line 192) | func (c *Call) Maybe() *Call {
method On (line 207) | func (c *Call) On(methodName string, arguments ...interface{}) *Call {
method Unset (line 221) | func (c *Call) Unset() *Call {
method NotBefore (line 269) | func (c *Call) NotBefore(calls ...*Call) *Call {
function newCall (line 83) | func newCall(parent *Mock, methodName string, callerInfo []string, metho...
function InOrder (line 291) | func InOrder(calls ...*Call) {
type Mock (line 300) | type Mock struct
method String (line 323) | func (m *Mock) String() string {
method TestData (line 329) | func (m *Mock) TestData() objx.Map {
method Test (line 345) | func (m *Mock) Test(t TestingT) {
method fail (line 354) | func (m *Mock) fail(format string, args ...interface{}) {
method On (line 369) | func (m *Mock) On(methodName string, arguments ...interface{}) *Call {
method findExpectedCall (line 388) | func (m *Mock) findExpectedCall(method string, arguments ...interface{...
method findClosestCall (line 433) | func (m *Mock) findClosestCall(method string, arguments ...interface{}...
method Called (line 475) | func (m *Mock) Called(arguments ...interface{}) Arguments {
method MethodCalled (line 498) | func (m *Mock) MethodCalled(methodName string, arguments ...interface{...
method AssertExpectations (line 623) | func (m *Mock) AssertExpectations(t TestingT) bool {
method checkExpectation (line 652) | func (m *Mock) checkExpectation(call *Call) (bool, string) {
method AssertNumberOfCalls (line 663) | func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expe...
method AssertCalled (line 680) | func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ....
method AssertNotCalled (line 703) | func (m *Mock) AssertNotCalled(t TestingT, methodName string, argument...
method IsMethodCallable (line 718) | func (m *Mock) IsMethodCallable(t TestingT, methodName string, argumen...
method methodWasCalled (line 755) | func (m *Mock) methodWasCalled(methodName string, expected []interface...
method expectedCalls (line 772) | func (m *Mock) expectedCalls() []*Call {
method calls (line 776) | func (m *Mock) calls() []Call {
type matchCandidate (line 406) | type matchCandidate struct
method isBetterMatchThan (line 412) | func (c matchCandidate) isBetterMatchThan(other matchCandidate) bool {
function callString (line 454) | func callString(method string, arguments Arguments, includeArgumentValue...
type assertExpectationiser (line 594) | type assertExpectationiser interface
function AssertExpectationsForObjects (line 602) | func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}...
function isArgsEqual (line 743) | func isArgsEqual(expected Arguments, args []interface{}) bool {
type Arguments (line 785) | type Arguments
method Get (line 939) | func (args Arguments) Get(index int) interface{} {
method Is (line 947) | func (args Arguments) Is(objects ...interface{}) bool {
method Diff (line 960) | func (args Arguments) Diff(objects []interface{}) (string, int) {
method Assert (line 1066) | func (args Arguments) Assert(t TestingT, objects ...interface{}) bool {
method String (line 1090) | func (args Arguments) String(indexOrNil ...int) string {
method Int (line 1114) | func (args Arguments) Int(index int) int {
method Error (line 1125) | func (args Arguments) Error(index int) error {
method Bool (line 1140) | func (args Arguments) Bool(index int) bool {
constant Anything (line 790) | Anything = "mock.Anything"
type anythingOfTypeArgument (line 809) | type anythingOfTypeArgument
function AnythingOfType (line 819) | func AnythingOfType(t string) AnythingOfTypeArgument {
type IsTypeArgument (line 826) | type IsTypeArgument struct
function IsType (line 841) | func IsType(t interface{}) *IsTypeArgument {
type FunctionalOptionsArgument (line 847) | type FunctionalOptionsArgument struct
method String (line 852) | func (f *FunctionalOptionsArgument) String() string {
function FunctionalOptions (line 867) | func FunctionalOptions(values ...interface{}) *FunctionalOptionsArgument {
type argumentMatcher (line 875) | type argumentMatcher struct
method Matches (line 880) | func (f argumentMatcher) Matches(argument interface{}) bool {
method String (line 906) | func (f argumentMatcher) String() string {
function MatchedBy (line 922) | func MatchedBy(fn interface{}) argumentMatcher {
function safeTypeName (line 1151) | func safeTypeName(t reflect.Type) string {
function typeAndKind (line 1158) | func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) {
function diffArguments (line 1169) | func diffArguments(expected Arguments, actual Arguments) string {
function diff (line 1185) | func diff(expected interface{}, actual interface{}) string {
type tHelper (line 1224) | type tHelper interface
function assertOpts (line 1228) | func assertOpts(expected, actual interface{}) (expectedFmt, actualFmt st...
function runtimeFunc (line 1291) | func runtimeFunc(opt interface{}) *runtime.Func {
function funcName (line 1295) | func funcName(f *runtime.Func) string {
function isFuncSame (line 1307) | func isFuncSame(f1, f2 *runtime.Func) bool {
FILE: mock/mock_test.go
type ExampleInterface (line 23) | type ExampleInterface interface
type TestExampleImplementation (line 28) | type TestExampleImplementation struct
method TheExampleMethod (line 32) | func (i *TestExampleImplementation) TheExampleMethod(a, b, c int) (int...
method TheExampleMethodFunctionalOptions (line 62) | func (i *TestExampleImplementation) TheExampleMethodFunctionalOptions(...
method TheExampleMethod2 (line 72) | func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) {
method TheExampleMethod3 (line 80) | func (i *TestExampleImplementation) TheExampleMethod3(et *ExampleType)...
method TheExampleMethod4 (line 85) | func (i *TestExampleImplementation) TheExampleMethod4(v ExampleInterfa...
method TheExampleMethod5 (line 90) | func (i *TestExampleImplementation) TheExampleMethod5(ch chan struct{}...
method TheExampleMethod6 (line 95) | func (i *TestExampleImplementation) TheExampleMethod6(m map[string]boo...
method TheExampleMethod7 (line 100) | func (i *TestExampleImplementation) TheExampleMethod7(slice []bool) er...
method TheExampleMethodFunc (line 105) | func (i *TestExampleImplementation) TheExampleMethodFunc(fn func(strin...
method TheExampleMethodVariadic (line 110) | func (i *TestExampleImplementation) TheExampleMethodVariadic(a ...int)...
method TheExampleMethodVariadicInterface (line 115) | func (i *TestExampleImplementation) TheExampleMethodVariadicInterface(...
method TheExampleMethodMixedVariadic (line 120) | func (i *TestExampleImplementation) TheExampleMethodMixedVariadic(a in...
method TheExampleMethodFuncType (line 127) | func (i *TestExampleImplementation) TheExampleMethodFuncType(fn Exampl...
type options (line 37) | type options struct
type OptionFn (line 42) | type OptionFn
function OpNum (line 44) | func OpNum(n int) OptionFn {
function OpStr (line 50) | func OpStr(s string) OptionFn {
function OpBytes (line 56) | func OpBytes(b []byte) OptionFn {
function TheExampleMethodFunctionalOptionsIndirect (line 67) | func TheExampleMethodFunctionalOptionsIndirect(i *TestExampleImplementat...
type ExampleType (line 76) | type ExampleType struct
type ExampleFuncType (line 125) | type ExampleFuncType
type MockTestingT (line 133) | type MockTestingT struct
method Helper (line 138) | func (MockTestingT) Helper() {}
method Logf (line 142) | func (m *MockTestingT) Logf(string, ...interface{}) {
method Errorf (line 146) | func (m *MockTestingT) Errorf(string, ...interface{}) {
method FailNow (line 156) | func (m *MockTestingT) FailNow() {
constant mockTestingTFailNowCalled (line 140) | mockTestingTFailNowCalled = "FailNow was called"
function Test_Mock_TestData (line 167) | func Test_Mock_TestData(t *testing.T) {
function Test_Mock_On (line 179) | func Test_Mock_On(t *testing.T) {
function Test_Mock_Chained_On (line 190) | func Test_Mock_Chained_On(t *testing.T) {
function Test_Mock_On_WithArgs (line 223) | func Test_Mock_On_WithArgs(t *testing.T) {
function Test_Mock_On_WithFuncArg (line 236) | func Test_Mock_On_WithFuncArg(t *testing.T) {
function Test_Mock_On_WithIntArgMatcher (line 258) | func Test_Mock_On_WithIntArgMatcher(t *testing.T) {
function Test_Mock_On_WithArgMatcherThatPanics (line 283) | func Test_Mock_On_WithArgMatcherThatPanics(t *testing.T) {
function TestMock_WithTest (line 311) | func TestMock_WithTest(t *testing.T) {
function Test_Mock_On_WithPtrArgMatcher (line 341) | func Test_Mock_On_WithPtrArgMatcher(t *testing.T) {
function Test_Mock_On_WithFuncArgMatcher (line 363) | func Test_Mock_On_WithFuncArgMatcher(t *testing.T) {
function Test_Mock_On_WithInterfaceArgMatcher (line 389) | func Test_Mock_On_WithInterfaceArgMatcher(t *testing.T) {
function Test_Mock_On_WithChannelArgMatcher (line 401) | func Test_Mock_On_WithChannelArgMatcher(t *testing.T) {
function Test_Mock_On_WithMapArgMatcher (line 413) | func Test_Mock_On_WithMapArgMatcher(t *testing.T) {
function Test_Mock_On_WithSliceArgMatcher (line 425) | func Test_Mock_On_WithSliceArgMatcher(t *testing.T) {
function Test_Mock_On_WithVariadicFunc (line 437) | func Test_Mock_On_WithVariadicFunc(t *testing.T) {
function Test_Mock_On_WithMixedVariadicFunc (line 460) | func Test_Mock_On_WithMixedVariadicFunc(t *testing.T) {
function Test_Mock_On_WithVariadicFuncWithInterface (line 484) | func Test_Mock_On_WithVariadicFuncWithInterface(t *testing.T) {
function Test_Mock_On_WithVariadicFuncWithEmptyInterfaceArray (line 506) | func Test_Mock_On_WithVariadicFuncWithEmptyInterfaceArray(t *testing.T) {
function Test_Mock_On_WithFuncPanics (line 530) | func Test_Mock_On_WithFuncPanics(t *testing.T) {
function Test_Mock_On_WithFuncTypeArg (line 541) | func Test_Mock_On_WithFuncTypeArg(t *testing.T) {
function Test_Mock_Unset (line 561) | func Test_Mock_Unset(t *testing.T) {
function Test_Mock_Chained_UnsetOnlyUnsetsLastCall (line 591) | func Test_Mock_Chained_UnsetOnlyUnsetsLastCall(t *testing.T) {
function Test_Mock_UnsetIfAlreadyUnsetFails (line 627) | func Test_Mock_UnsetIfAlreadyUnsetFails(t *testing.T) {
function Test_Mock_UnsetByOnMethodSpec (line 648) | func Test_Mock_UnsetByOnMethodSpec(t *testing.T) {
function Test_Mock_UnsetByOnMethodSpecAmongOthers (line 671) | func Test_Mock_UnsetByOnMethodSpecAmongOthers(t *testing.T) {
function Test_Mock_Unset_WithFuncPanics (line 715) | func Test_Mock_Unset_WithFuncPanics(t *testing.T) {
function Test_Mock_Return (line 728) | func Test_Mock_Return(t *testing.T) {
function Test_Mock_Panic (line 753) | func Test_Mock_Panic(t *testing.T) {
function Test_Mock_Return_WaitUntil (line 777) | func Test_Mock_Return_WaitUntil(t *testing.T) {
function Test_Mock_Return_After (line 805) | func Test_Mock_Return_After(t *testing.T) {
function Test_Mock_Return_Run (line 832) | func Test_Mock_Return_Run(t *testing.T) {
function Test_Mock_Return_Run_Out_Of_Order (line 865) | func Test_Mock_Return_Run_Out_Of_Order(t *testing.T) {
function Test_Mock_Return_Once (line 892) | func Test_Mock_Return_Once(t *testing.T) {
function Test_Mock_Return_Twice (line 917) | func Test_Mock_Return_Twice(t *testing.T) {
function Test_Mock_Return_Times (line 943) | func Test_Mock_Return_Times(t *testing.T) {
function Test_Mock_Return_Nothing (line 969) | func Test_Mock_Return_Nothing(t *testing.T) {
function Test_Mock_Return_NotBefore_In_Order (line 990) | func Test_Mock_Return_NotBefore_In_Order(t *testing.T) {
function Test_Mock_Return_InOrder_Uses_NotBefore (line 1012) | func Test_Mock_Return_InOrder_Uses_NotBefore(t *testing.T) {
function Test_Mock_Return_NotBefore_Out_Of_Order (line 1034) | func Test_Mock_Return_NotBefore_Out_Of_Order(t *testing.T) {
function Test_Mock_Return_InOrder_Uses_NotBefore_Out_Of_Order (line 1066) | func Test_Mock_Return_InOrder_Uses_NotBefore_Out_Of_Order(t *testing.T) {
function Test_Mock_Return_NotBefore_Not_Enough_Times (line 1097) | func Test_Mock_Return_NotBefore_Not_Enough_Times(t *testing.T) {
function Test_Mock_Return_NotBefore_Different_Mock_In_Order (line 1132) | func Test_Mock_Return_NotBefore_Different_Mock_In_Order(t *testing.T) {
function Test_Mock_Return_NotBefore_Different_Mock_Out_Of_Order (line 1157) | func Test_Mock_Return_NotBefore_Different_Mock_Out_Of_Order(t *testing.T) {
function Test_Mock_Return_NotBefore_In_Order_With_Non_Dependant (line 1192) | func Test_Mock_Return_NotBefore_In_Order_With_Non_Dependant(t *testing.T) {
function Test_Mock_Return_NotBefore_Orphan_Call (line 1234) | func Test_Mock_Return_NotBefore_Orphan_Call(t *testing.T) {
function Test_Mock_findExpectedCall (line 1247) | func Test_Mock_findExpectedCall(t *testing.T) {
function Test_Mock_findExpectedCall_For_Unknown_Method (line 1267) | func Test_Mock_findExpectedCall_For_Unknown_Method(t *testing.T) {
function Test_Mock_findExpectedCall_Respects_Repeatability (line 1281) | func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) {
function Test_callString (line 1312) | func Test_callString(t *testing.T) {
function Test_Mock_Called (line 1320) | func Test_Mock_Called(t *testing.T) {
function asyncCall (line 1344) | func asyncCall(m *Mock, ch chan Arguments) {
function Test_Mock_Called_blocks (line 1348) | func Test_Mock_Called_blocks(t *testing.T) {
function Test_Mock_Called_For_Bounded_Repeatability (line 1382) | func Test_Mock_Called_For_Bounded_Repeatability(t *testing.T) {
function Test_Mock_Called_For_SetTime_Expectation (line 1424) | func Test_Mock_Called_For_SetTime_Expectation(t *testing.T) {
function Test_Mock_Called_Unexpected (line 1441) | func Test_Mock_Called_Unexpected(t *testing.T) {
function Test_AssertExpectationsForObjects_Helper (line 1453) | func Test_AssertExpectationsForObjects_Helper(t *testing.T) {
function Test_AssertExpectationsForObjects_Helper_Failed (line 1474) | func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) {
function Test_Mock_AssertExpectations (line 1494) | func Test_Mock_AssertExpectations(t *testing.T) {
function Test_Mock_AssertExpectations_Placeholder_NoArgs (line 1512) | func Test_Mock_AssertExpectations_Placeholder_NoArgs(t *testing.T) {
function Test_Mock_AssertExpectations_Placeholder (line 1531) | func Test_Mock_AssertExpectations_Placeholder(t *testing.T) {
function Test_Mock_AssertExpectations_With_Pointers (line 1555) | func Test_Mock_AssertExpectations_With_Pointers(t *testing.T) {
function Test_Mock_AssertExpectationsCustomType (line 1577) | func Test_Mock_AssertExpectationsCustomType(t *testing.T) {
function Test_Mock_AssertExpectationsFunctionalOptionsType (line 1595) | func Test_Mock_AssertExpectationsFunctionalOptionsType(t *testing.T) {
function Test_Mock_AssertExpectationsFunctionalOptionsType_Empty (line 1613) | func Test_Mock_AssertExpectationsFunctionalOptionsType_Empty(t *testing....
function Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly (line 1631) | func Test_Mock_AssertExpectationsFunctionalOptionsType_Indirectly(t *tes...
function Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Func (line 1649) | func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Func(t *test...
function Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Arg (line 1664) | func Test_Mock_AssertExpectationsFunctionalOptionsType_Diff_Arg(t *testi...
function Test_Mock_AssertExpectations_With_Repeatability (line 1679) | func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
function Test_Mock_AssertExpectations_Skipped_Test (line 1701) | func Test_Mock_AssertExpectations_Skipped_Test(t *testing.T) {
function Test_Mock_TwoCallsWithDifferentArguments (line 1712) | func Test_Mock_TwoCallsWithDifferentArguments(t *testing.T) {
function Test_Mock_AssertNumberOfCalls (line 1732) | func Test_Mock_AssertNumberOfCalls(t *testing.T) {
function Test_Mock_AssertCalled (line 1747) | func Test_Mock_AssertCalled(t *testing.T) {
function Test_Mock_AssertCalled_WithAnythingOfTypeArgument (line 1760) | func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) {
function Test_Mock_AssertCalled_WithArguments (line 1775) | func Test_Mock_AssertCalled_WithArguments(t *testing.T) {
function Test_Mock_AssertCalled_WithArguments_With_Repeatability (line 1790) | func Test_Mock_AssertCalled_WithArguments_With_Repeatability(t *testing....
function Test_Mock_AssertNotCalled (line 1808) | func Test_Mock_AssertNotCalled(t *testing.T) {
function Test_Mock_IsMethodCallable (line 1821) | func Test_Mock_IsMethodCallable(t *testing.T) {
function TestIsArgsEqual (line 1842) | func TestIsArgsEqual(t *testing.T) {
function Test_Mock_AssertOptional (line 1857) | func Test_Mock_AssertOptional(t *testing.T) {
function Test_Arguments_Get (line 1887) | func Test_Arguments_Get(t *testing.T) {
function Test_Arguments_Is (line 1898) | func Test_Arguments_Is(t *testing.T) {
function Test_Arguments_Diff (line 1908) | func Test_Arguments_Diff(t *testing.T) {
function Test_Arguments_Diff_DifferentNumberOfArgs (line 1922) | func Test_Arguments_Diff_DifferentNumberOfArgs(t *testing.T) {
function Test_Arguments_Diff_WithAnythingArgument (line 1935) | func Test_Arguments_Diff_WithAnythingArgument(t *testing.T) {
function Test_Arguments_Diff_WithAnythingArgument_InActualToo (line 1946) | func Test_Arguments_Diff_WithAnythingArgument_InActualToo(t *testing.T) {
function Test_Arguments_Diff_WithAnythingOfTypeArgument (line 1957) | func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) {
function Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing (line 1968) | func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) {
function Test_Arguments_Diff_WithIsTypeArgument (line 1981) | func Test_Arguments_Diff_WithIsTypeArgument(t *testing.T) {
function Test_Arguments_Diff_WithIsTypeArgument_Failing (line 1991) | func Test_Arguments_Diff_WithIsTypeArgument_Failing(t *testing.T) {
function Test_Arguments_Diff_WithIsTypeArgument_InterfaceType (line 2003) | func Test_Arguments_Diff_WithIsTypeArgument_InterfaceType(t *testing.T) {
function Test_Arguments_Diff_WithIsTypeArgument_InterfaceType_Failing (line 2011) | func Test_Arguments_Diff_WithIsTypeArgument_InterfaceType_Failing(t *tes...
function Test_Arguments_Diff_WithArgMatcher (line 2022) | func Test_Arguments_Diff_WithArgMatcher(t *testing.T) {
function Test_Arguments_Assert (line 2047) | func Test_Arguments_Assert(t *testing.T) {
function Test_Arguments_String_Representation (line 2056) | func Test_Arguments_String_Representation(t *testing.T) {
function Test_Arguments_String (line 2064) | func Test_Arguments_String(t *testing.T) {
function Test_Arguments_Error (line 2072) | func Test_Arguments_Error(t *testing.T) {
function Test_Arguments_Error_Nil (line 2081) | func Test_Arguments_Error_Nil(t *testing.T) {
function Test_Arguments_Int (line 2089) | func Test_Arguments_Int(t *testing.T) {
function Test_Arguments_Bool (line 2097) | func Test_Arguments_Bool(t *testing.T) {
function Test_WaitUntil_Parallel (line 2105) | func Test_WaitUntil_Parallel(t *testing.T) {
function Test_MockMethodCalled (line 2132) | func Test_MockMethodCalled(t *testing.T) {
function Test_MockMethodCalled_Panic (line 2144) | func Test_MockMethodCalled_Panic(t *testing.T) {
function Test_MockReturnAndCalledConcurrent (line 2155) | func Test_MockReturnAndCalledConcurrent(t *testing.T) {
type timer (line 2180) | type timer struct
method GetTime (line 2182) | func (s *timer) GetTime(i int) string {
method GetTimes (line 2186) | func (s *timer) GetTimes(times []int) string {
type tCustomLogger (line 2190) | type tCustomLogger struct
method Logf (line 2196) | func (tc *tCustomLogger) Logf(format string, args ...interface{}) {
method Errorf (line 2201) | func (tc *tCustomLogger) Errorf(format string, args ...interface{}) {
method FailNow (line 2205) | func (tc *tCustomLogger) FailNow() {}
function TestLoggingAssertExpectations (line 2207) | func TestLoggingAssertExpectations(t *testing.T) {
function TestAfterTotalWaitTimeWhileExecution (line 2223) | func TestAfterTotalWaitTimeWhileExecution(t *testing.T) {
function TestArgumentMatcherToPrintMismatch (line 2249) | func TestArgumentMatcherToPrintMismatch(t *testing.T) {
function TestArgumentMatcherToPrintMismatchWithReferenceType (line 2268) | func TestArgumentMatcherToPrintMismatchWithReferenceType(t *testing.T) {
function TestClosestCallMismatchedArgumentInformationShowsTheClosest (line 2287) | func TestClosestCallMismatchedArgumentInformationShowsTheClosest(t *test...
function TestClosestCallFavorsFirstMock (line 2304) | func TestClosestCallFavorsFirstMock(t *testing.T) {
function TestClosestCallUsesRepeatabilityToFindClosest (line 2322) | func TestClosestCallUsesRepeatabilityToFindClosest(t *testing.T) {
function TestClosestCallMismatchedArgumentValueInformation (line 2344) | func TestClosestCallMismatchedArgumentValueInformation(t *testing.T) {
function Test_isBetterMatchThanReturnsFalseIfCandidateCallIsNil (line 2360) | func Test_isBetterMatchThanReturnsFalseIfCandidateCallIsNil(t *testing.T) {
function Test_isBetterMatchThanReturnsTrueIfOtherCandidateCallIsNil (line 2366) | func Test_isBetterMatchThanReturnsTrueIfOtherCandidateCallIsNil(t *testi...
function Test_isBetterMatchThanReturnsFalseIfDiffCountIsGreaterThanOther (line 2372) | func Test_isBetterMatchThanReturnsFalseIfDiffCountIsGreaterThanOther(t *...
function Test_isBetterMatchThanReturnsTrueIfDiffCountIsLessThanOther (line 2378) | func Test_isBetterMatchThanReturnsTrueIfDiffCountIsLessThanOther(t *test...
function Test_isBetterMatchThanReturnsTrueIfRepeatabilityIsGreaterThanOther (line 2384) | func Test_isBetterMatchThanReturnsTrueIfRepeatabilityIsGreaterThanOther(...
function Test_isBetterMatchThanReturnsFalseIfRepeatabilityIsLessThanOrEqualToOther (line 2390) | func Test_isBetterMatchThanReturnsFalseIfRepeatabilityIsLessThanOrEqualT...
function unexpectedCallRegex (line 2396) | func unexpectedCallRegex(method, calledArg, expectedArg, diff string) st...
function ConcurrencyTestMethod (line 2403) | func ConcurrencyTestMethod(m *Mock) {
function TestConcurrentArgumentRead (line 2407) | func TestConcurrentArgumentRead(t *testing.T) {
type caller (line 2430) | type caller interface
type mockCaller (line 2434) | type mockCaller struct
method Call (line 2436) | func (m *mockCaller) Call() { m.Called() }
type user (line 2438) | type user interface
type mockUser (line 2442) | type mockUser struct
method Use (line 2444) | func (m *mockUser) Use(c caller) { m.Called(c) }
type mutatingStringer (line 2446) | type mutatingStringer struct
method String (line 2451) | func (m *mutatingStringer) String() string {
function TestIssue1785ArgumentWithMutatingStringer (line 2456) | func TestIssue1785ArgumentWithMutatingStringer(t *testing.T) {
function TestIssue1227AssertExpectationsForObjectsWithMock (line 2465) | func TestIssue1227AssertExpectationsForObjectsWithMock(t *testing.T) {
FILE: package_test.go
function TestImports (line 9) | func TestImports(t *testing.T) {
FILE: require/forward_requirements.go
type Assertions (line 5) | type Assertions struct
function New (line 10) | func New(t TestingT) *Assertions {
FILE: require/forward_requirements_test.go
function TestImplementsWrapper (line 9) | func TestImplementsWrapper(t *testing.T) {
function TestIsNotTypeWrapper (line 24) | func TestIsNotTypeWrapper(t *testing.T) {
function TestIsTypeWrapper (line 38) | func TestIsTypeWrapper(t *testing.T) {
function TestEqualWrapper (line 52) | func TestEqualWrapper(t *testing.T) {
function TestNotEqualWrapper (line 66) | func TestNotEqualWrapper(t *testing.T) {
function TestExactlyWrapper (line 80) | func TestExactlyWrapper(t *testing.T) {
function TestNotNilWrapper (line 99) | func TestNotNilWrapper(t *testing.T) {
function TestNilWrapper (line 113) | func TestNilWrapper(t *testing.T) {
function TestTrueWrapper (line 127) | func TestTrueWrapper(t *testing.T) {
function TestFalseWrapper (line 141) | func TestFalseWrapper(t *testing.T) {
function TestContainsWrapper (line 155) | func TestContainsWrapper(t *testing.T) {
function TestNotContainsWrapper (line 169) | func TestNotContainsWrapper(t *testing.T) {
function TestPanicsWrapper (line 183) | func TestPanicsWrapper(t *testing.T) {
function TestNotPanicsWrapper (line 199) | func TestNotPanicsWrapper(t *testing.T) {
function TestNoErrorWrapper (line 215) | func TestNoErrorWrapper(t *testing.T) {
function TestErrorWrapper (line 229) | func TestErrorWrapper(t *testing.T) {
function TestErrorContainsWrapper (line 243) | func TestErrorContainsWrapper(t *testing.T) {
function TestEqualErrorWrapper (line 257) | func TestEqualErrorWrapper(t *testing.T) {
function TestEmptyWrapper (line 271) | func TestEmptyWrapper(t *testing.T) {
function TestNotEmptyWrapper (line 285) | func TestNotEmptyWrapper(t *testing.T) {
function TestWithinDurationWrapper (line 299) | func TestWithinDurationWrapper(t *testing.T) {
function TestInDeltaWrapper (line 316) | func TestInDeltaWrapper(t *testing.T) {
function TestZeroWrapper (line 330) | func TestZeroWrapper(t *testing.T) {
function TestNotZeroWrapper (line 344) | func TestNotZeroWrapper(t *testing.T) {
function TestJSONEqWrapper_EqualSONString (line 358) | func TestJSONEqWrapper_EqualSONString(t *testing.T) {
function TestJSONEqWrapper_EquivalentButNotEqual (line 370) | func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) {
function TestJSONEqWrapper_HashOfArraysAndHashes (line 382) | func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) {
function TestJSONEqWrapper_Array (line 395) | func TestJSONEqWrapper_Array(t *testing.T) {
function TestJSONEqWrapper_HashAndArrayNotEquivalent (line 407) | func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
function TestJSONEqWrapper_HashesNotEquivalent (line 419) | func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) {
function TestJSONEqWrapper_ActualIsNotJSON (line 431) | func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) {
function TestJSONEqWrapper_ExpectedIsNotJSON (line 443) | func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) {
function TestJSONEqWrapper_ExpectedAndActualNotJSON (line 455) | func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) {
function TestJSONEqWrapper_ArraysOfDifferentOrder (line 467) | func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
function TestYAMLEqWrapper_EqualYAMLString (line 479) | func TestYAMLEqWrapper_EqualYAMLString(t *testing.T) {
function TestYAMLEqWrapper_EquivalentButNotEqual (line 491) | func TestYAMLEqWrapper_EquivalentButNotEqual(t *testing.T) {
function TestYAMLEqWrapper_HashOfArraysAndHashes (line 503) | func TestYAMLEqWrapper_HashOfArraysAndHashes(t *testing.T) {
function TestYAMLEqWrapper_Array (line 541) | func TestYAMLEqWrapper_Array(t *testing.T) {
function TestYAMLEqWrapper_HashAndArrayNotEquivalent (line 553) | func TestYAMLEqWrapper_HashAndArrayNotEquivalent(t *testing.T) {
function TestYAMLEqWrapper_HashesNotEquivalent (line 565) | func TestYAMLEqWrapper_HashesNotEquivalent(t *testing.T) {
function TestYAMLEqWrapper_ActualIsSimpleString (line 577) | func TestYAMLEqWrapper_ActualIsSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ExpectedIsSimpleString (line 589) | func TestYAMLEqWrapper_ExpectedIsSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ExpectedAndActualSimpleString (line 601) | func TestYAMLEqWrapper_ExpectedAndActualSimpleString(t *testing.T) {
function TestYAMLEqWrapper_ArraysOfDifferentOrder (line 613) | func TestYAMLEqWrapper_ArraysOfDifferentOrder(t *testing.T) {
FILE: require/require.go
function Condition (line 13) | func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interfa...
function Conditionf (line 24) | func Conditionf(t TestingT, comp assert.Comparison, msg string, args ......
function Contains (line 40) | func Contains(t TestingT, s interface{}, contains interface{}, msgAndArg...
function Containsf (line 56) | func Containsf(t TestingT, s interface{}, contains interface{}, msg stri...
function DirExists (line 68) | func DirExists(t TestingT, path string, msgAndArgs ...interface{}) {
function DirExistsf (line 80) | func DirExistsf(t TestingT, path string, msg string, args ...interface{}) {
function ElementsMatch (line 95) | func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msg...
function ElementsMatchf (line 110) | func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, ms...
function Empty (line 133) | func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
function Emptyf (line 156) | func Emptyf(t TestingT, object interface{}, msg string, args ...interfac...
function Equal (line 173) | func Equal(t TestingT, expected interface{}, actual interface{}, msgAndA...
function EqualError (line 188) | func EqualError(t TestingT, theError error, errString string, msgAndArgs...
function EqualErrorf (line 203) | func EqualErrorf(t TestingT, theError error, errString string, msg strin...
function EqualExportedValues (line 223) | func EqualExportedValues(t TestingT, expected interface{}, actual interf...
function EqualExportedValuesf (line 243) | func EqualExportedValuesf(t TestingT, expected interface{}, actual inter...
function EqualValues (line 257) | func EqualValues(t TestingT, expected interface{}, actual interface{}, m...
function EqualValuesf (line 271) | func EqualValuesf(t TestingT, expected interface{}, actual interface{}, ...
function Equalf (line 288) | func Equalf(t TestingT, expected interface{}, actual interface{}, msg st...
function Error (line 302) | func Error(t TestingT, err error, msgAndArgs ...interface{}) {
function ErrorAs (line 314) | func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...in...
function ErrorAsf (line 326) | func ErrorAsf(t TestingT, err error, target interface{}, msg string, arg...
function ErrorContains (line 341) | func ErrorContains(t TestingT, theError error, contains string, msgAndAr...
function ErrorContainsf (line 356) | func ErrorContainsf(t TestingT, theError error, contains string, msg str...
function ErrorIs (line 368) | func ErrorIs(t TestingT, err error, target error, msgAndArgs ...interfac...
function ErrorIsf (line 380) | func ErrorIsf(t TestingT, err error, target error, msg string, args ...i...
function Errorf (line 394) | func Errorf(t TestingT, err error, msg string, args ...interface{}) {
function Eventually (line 408) | func Eventually(t TestingT, condition func() bool, waitFor time.Duration...
function EventuallyWithT (line 436) | func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT...
function EventuallyWithTf (line 464) | func EventuallyWithTf(t TestingT, condition func(collect *assert.Collect...
function Eventuallyf (line 478) | func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duratio...
function Exactly (line 491) | func Exactly(t TestingT, expected interface{}, actual interface{}, msgAn...
function Exactlyf (line 504) | func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg ...
function Fail (line 515) | func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
function FailNow (line 526) | func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{...
function FailNowf (line 537) | func FailNowf(t TestingT, failureMessage string, msg string, args ...int...
function Failf (line 548) | func Failf(t TestingT, failureMessage string, msg string, args ...interf...
function False (line 561) | func False(t TestingT, value bool, msgAndArgs ...interface{}) {
function Falsef (line 574) | func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
function FileExists (line 586) | func FileExists(t TestingT, path string, msgAndArgs ...interface{}) {
function FileExistsf (line 598) | func FileExistsf(t TestingT, path string, msg string, args ...interface{...
function Greater (line 613) | func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...i...
function GreaterOrEqual (line 629) | func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndAr...
function GreaterOrEqualf (line 645) | func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg str...
function Greaterf (line 660) | func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, ar...
function HTTPBodyContains (line 674) | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method strin...
function HTTPBodyContainsf (line 688) | func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method stri...
function HTTPBodyNotContains (line 702) | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method st...
function HTTPBodyNotContainsf (line 716) | func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method s...
function HTTPError (line 729) | func HTTPError(t TestingT, handler http.HandlerFunc, method string, url ...
function HTTPErrorf (line 742) | func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url...
function HTTPRedirect (line 755) | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, u...
function HTTPRedirectf (line 768) | func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, ...
function HTTPStatusCode (line 781) | func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string,...
function HTTPStatusCodef (line 794) | func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string...
function HTTPSuccess (line 807) | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, ur...
function HTTPSuccessf (line 820) | func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, u...
function Implements (line 833) | func Implements(t TestingT, interfaceObject interface{}, object interfac...
function Implementsf (line 846) | func Implementsf(t TestingT, interfaceObject interface{}, object interfa...
function InDelta (line 859) | func InDelta(t TestingT, expected interface{}, actual interface{}, delta...
function InDeltaMapValues (line 870) | func InDeltaMapValues(t TestingT, expected interface{}, actual interface...
function InDeltaMapValuesf (line 881) | func InDeltaMapValuesf(t TestingT, expected interface{}, actual interfac...
function InDeltaSlice (line 892) | func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, ...
function InDeltaSlicef (line 903) | func InDeltaSlicef(t TestingT, expected interface{}, actual interface{},...
function InDeltaf (line 916) | func InDeltaf(t TestingT, expected interface{}, actual interface{}, delt...
function InEpsilon (line 927) | func InEpsilon(t TestingT, expected interface{}, actual interface{}, eps...
function InEpsilonSlice (line 938) | func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}...
function InEpsilonSlicef (line 949) | func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{...
function InEpsilonf (line 960) | func InEpsilonf(t TestingT, expected interface{}, actual interface{}, ep...
function IsDecreasing (line 975) | func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interfac...
function IsDecreasingf (line 990) | func IsDecreasingf(t TestingT, object interface{}, msg string, args ...i...
function IsIncreasing (line 1005) | func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interfac...
function IsIncreasingf (line 1020) | func IsIncreasingf(t TestingT, object interface{}, msg string, args ...i...
function IsNonDecreasing (line 1035) | func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...inter...
function IsNonDecreasingf (line 1050) | func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ....
function IsNonIncreasing (line 1065) | func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...inter...
function IsNonIncreasingf (line 1080) | func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ....
function IsNotType (line 1093) | func IsNotType(t TestingT, theType interface{}, object interface{}, msgA...
function IsNotTypef (line 1106) | func IsNotTypef(t TestingT, theType interface{}, object interface{}, msg...
function IsType (line 1119) | func IsType(t TestingT, expectedType interface{}, object interface{}, ms...
function IsTypef (line 1132) | func IsTypef(t TestingT, expectedType interface{}, object interface{}, m...
function JSONEq (line 1145) | func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...in...
function JSONEqf (line 1158) | func JSONEqf(t TestingT, expected string, actual string, msg string, arg...
function Len (line 1172) | func Len(t TestingT, object interface{}, length int, msgAndArgs ...inter...
function Lenf (line 1186) | func Lenf(t TestingT, object interface{}, length int, msg string, args ....
function Less (line 1201) | func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inte...
function LessOrEqual (line 1217) | func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...
function LessOrEqualf (line 1233) | func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string...
function Lessf (line 1248) | func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...
function Negative (line 1262) | func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) {
function Negativef (line 1276) | func Negativef(t TestingT, e interface{}, msg string, args ...interface{...
function Never (line 1290) | func Never(t TestingT, condition func() bool, waitFor time.Duration, tic...
function Neverf (line 1304) | func Neverf(t TestingT, condition func() bool, waitFor time.Duration, ti...
function Nil (line 1317) | func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
function Nilf (line 1330) | func Nilf(t TestingT, object interface{}, msg string, args ...interface{...
function NoDirExists (line 1342) | func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) {
function NoDirExistsf (line 1354) | func NoDirExistsf(t TestingT, path string, msg string, args ...interface...
function NoError (line 1369) | func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
function NoErrorf (line 1384) | func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
function NoFileExists (line 1396) | func NoFileExists(t TestingT, path string, msgAndArgs ...interface{}) {
function NoFileExistsf (line 1408) | func NoFileExistsf(t TestingT, path string, msg string, args ...interfac...
function NotContains (line 1424) | func NotContains(t TestingT, s interface{}, contains interface{}, msgAnd...
function NotContainsf (line 1440) | func NotContainsf(t TestingT, s interface{}, contains interface{}, msg s...
function NotElementsMatch (line 1460) | func NotElementsMatch(t TestingT, listA interface{}, listB interface{}, ...
function NotElementsMatchf (line 1480) | func NotElementsMatchf(t TestingT, listA interface{}, listB interface{},...
function NotEmpty (line 1494) | func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
function NotEmptyf (line 1508) | func NotEmptyf(t TestingT, object interface{}, msg string, args ...inter...
function NotEqual (line 1524) | func NotEqual(t TestingT, expected interface{}, actual interface{}, msgA...
function NotEqualValues (line 1537) | func NotEqualValues(t TestingT, expected interface{}, actual interface{}...
function NotEqualValuesf (line 1550) | func NotEqualValuesf(t TestingT, expected interface{}, actual interface{...
function NotEqualf (line 1566) | func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg...
function NotErrorAs (line 1578) | func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs .....
function NotErrorAsf (line 1590) | func NotErrorAsf(t TestingT, err error, target interface{}, msg string, ...
function NotErrorIs (line 1602) | func NotErrorIs(t TestingT, err error, target error, msgAndArgs ...inter...
function NotErrorIsf (line 1614) | func NotErrorIsf(t TestingT, err error, target error, msg string, args ....
function NotImplements (line 1627) | func NotImplements(t TestingT, interfaceObject interface{}, object inter...
function NotImplementsf (line 1640) | func NotImplementsf(t TestingT, interfaceObject interface{}, object inte...
function NotNil (line 1653) | func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
function NotNilf (line 1666) | func NotNilf(t TestingT, object interface{}, msg string, args ...interfa...
function NotPanics (line 1679) | func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interfa...
function NotPanicsf (line 1692) | func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ......
function NotRegexp (line 1706) | func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ....
function NotRegexpf (line 1720) | func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string,...
function NotSame (line 1736) | func NotSame(t TestingT, expected interface{}, actual interface{}, msgAn...
function NotSamef (line 1752) | func NotSamef(t TestingT, expected interface{}, actual interface{}, msg ...
function NotSubset (line 1771) | func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndA...
function NotSubsetf (line 1790) | func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg st...
function NotZero (line 1801) | func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
function NotZerof (line 1812) | func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
function Panics (line 1825) | func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{...
function PanicsWithError (line 1840) | func PanicsWithError(t TestingT, errString string, f assert.PanicTestFun...
function PanicsWithErrorf (line 1855) | func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFu...
function PanicsWithValue (line 1869) | func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTes...
function PanicsWithValuef (line 1883) | func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTe...
function Panicsf (line 1896) | func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...int...
function Positive (line 1910) | func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) {
function Positivef (line 1924) | func Positivef(t TestingT, e interface{}, msg string, args ...interface{...
function Regexp (line 1938) | func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...i...
function Regexpf (line 1952) | func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, ar...
function Same (line 1968) | func Same(t TestingT, expected interface{}, actual interface{}, msgAndAr...
function Samef (line 1984) | func Samef(t TestingT, expected interface{}, actual interface{}, msg str...
function Subset (line 2003) | func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs...
function Subsetf (line 2022) | func Subsetf(t TestingT, list interface{}, subset interface{}, msg strin...
function True (line 2035) | func True(t TestingT, value bool, msgAndArgs ...interface{}) {
function Truef (line 2048) | func Truef(t TestingT, value bool, msg string, args ...interface{}) {
function WithinDuration (line 2061) | func WithinDuration(t TestingT, expected time.Time, actual time.Time, de...
function WithinDurationf (line 2074) | func WithinDurationf(t TestingT, expected time.Time, actual time.Time, d...
function WithinRange (line 2087) | func WithinRange(t TestingT, actual time.Time, start time.Time, end time...
function WithinRangef (line 2100) | func WithinRangef(t TestingT, actual time.Time, start time.Time, end tim...
function YAMLEq (line 2123) | func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...in...
function YAMLEqf (line 2146) | func YAMLEqf(t TestingT, expected string, actual string, msg string, arg...
function Zero (line 2157) | func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
function Zerof (line 2168) | func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
FILE: require/require_forward.go
method Condition (line 13) | func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...int...
method Conditionf (line 21) | func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args...
method Contains (line 34) | func (a *Assertions) Contains(s interface{}, contains interface{}, msgAn...
method Containsf (line 47) | func (a *Assertions) Containsf(s interface{}, contains interface{}, msg ...
method DirExists (line 56) | func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) {
method DirExistsf (line 65) | func (a *Assertions) DirExistsf(path string, msg string, args ...interfa...
method ElementsMatch (line 77) | func (a *Assertions) ElementsMatch(listA interface{}, listB interface{},...
method ElementsMatchf (line 89) | func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}...
method Empty (line 109) | func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
method Emptyf (line 129) | func (a *Assertions) Emptyf(object interface{}, msg string, args ...inte...
method Equal (line 143) | func (a *Assertions) Equal(expected interface{}, actual interface{}, msg...
method EqualError (line 155) | func (a *Assertions) EqualError(theError error, errString string, msgAnd...
method EqualErrorf (line 167) | func (a *Assertions) EqualErrorf(theError error, errString string, msg s...
method EqualExportedValues (line 184) | func (a *Assertions) EqualExportedValues(expected interface{}, actual in...
method EqualExportedValuesf (line 201) | func (a *Assertions) EqualExportedValuesf(expected interface{}, actual i...
method EqualValues (line 212) | func (a *Assertions) EqualValues(expected interface{}, actual interface{...
method EqualValuesf (line 223) | func (a *Assertions) EqualValuesf(expected interface{}, actual interface...
method Equalf (line 237) | func (a *Assertions) Equalf(expected interface{}, actual interface{}, ms...
method Error (line 248) | func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
method ErrorAs (line 257) | func (a *Assertions) ErrorAs(err error, target interface{}, msgAndArgs ....
method ErrorAsf (line 266) | func (a *Assertions) ErrorAsf(err error, target interface{}, msg string,...
method ErrorContains (line 278) | func (a *Assertions) ErrorContains(theError error, contains string, msgA...
method ErrorContainsf (line 290) | func (a *Assertions) ErrorContainsf(theError error, contains string, msg...
method ErrorIs (line 299) | func (a *Assertions) ErrorIs(err error, target error, msgAndArgs ...inte...
method ErrorIsf (line 308) | func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...
method Errorf (line 319) | func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
method Eventually (line 330) | func (a *Assertions) Eventually(condition func() bool, waitFor time.Dura...
method EventuallyWithT (line 355) | func (a *Assertions) EventuallyWithT(condition func(collect *assert.Coll...
method EventuallyWithTf (line 380) | func (a *Assertions) EventuallyWithTf(condition func(collect *assert.Col...
method Eventuallyf (line 391) | func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Dur...
method Exactly (line 401) | func (a *Assertions) Exactly(expected interface{}, actual interface{}, m...
method Exactlyf (line 411) | func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, ...
method Fail (line 419) | func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface...
method FailNow (line 427) | func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interf...
method FailNowf (line 435) | func (a *Assertions) FailNowf(failureMessage string, msg string, args .....
method Failf (line 443) | func (a *Assertions) Failf(failureMessage string, msg string, args ...in...
method False (line 453) | func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
method Falsef (line 463) | func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
method FileExists (line 472) | func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) {
method FileExistsf (line 481) | func (a *Assertions) FileExistsf(path string, msg string, args ...interf...
method Greater (line 493) | func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...
method GreaterOrEqual (line 506) | func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgA...
method GreaterOrEqualf (line 519) | func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg...
method Greaterf (line 531) | func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string...
method HTTPBodyContains (line 542) | func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method s...
method HTTPBodyContainsf (line 553) | func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method ...
method HTTPBodyNotContains (line 564) | func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, metho...
method HTTPBodyNotContainsf (line 575) | func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, meth...
method HTTPError (line 585) | func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, ...
method HTTPErrorf (line 595) | func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string,...
method HTTPRedirect (line 605) | func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method strin...
method HTTPRedirectf (line 615) | func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method stri...
method HTTPStatusCode (line 625) | func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method str...
method HTTPStatusCodef (line 635) | func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method st...
method HTTPSuccess (line 645) | func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string...
method HTTPSuccessf (line 655) | func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method strin...
method Implements (line 665) | func (a *Assertions) Implements(interfaceObject interface{}, object inte...
method Implementsf (line 675) | func (a *Assertions) Implementsf(interfaceObject interface{}, object int...
method InDelta (line 685) | func (a *Assertions) InDelta(expected interface{}, actual interface{}, d...
method InDeltaMapValues (line 693) | func (a *Assertions) InDeltaMapValues(expected interface{}, actual inter...
method InDeltaMapValuesf (line 701) | func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual inte...
method InDeltaSlice (line 709) | func (a *Assertions) InDeltaSlice(expected interface{}, actual interface...
method InDeltaSlicef (line 717) | func (a *Assertions) InDeltaSlicef(expected interface{}, actual interfac...
method InDeltaf (line 727) | func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, ...
method InEpsilon (line 735) | func (a *Assertions) InEpsilon(expected interface{}, actual interface{},...
method InEpsilonSlice (line 743) | func (a *Assertions) InEpsilonSlice(expected interface{}, actual interfa...
method InEpsilonSlicef (line 751) | func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interf...
method InEpsilonf (line 759) | func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}...
method IsDecreasing (line 771) | func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...inte...
method IsDecreasingf (line 783) | func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...
method IsIncreasing (line 795) | func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...inte...
method IsIncreasingf (line 807) | func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...
method IsNonDecreasing (line 819) | func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...i...
method IsNonDecreasingf (line 831) | func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, ar...
method IsNonIncreasing (line 843) | func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...i...
method IsNonIncreasingf (line 855) | func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, ar...
method IsNotType (line 865) | func (a *Assertions) IsNotType(theType interface{}, object interface{}, ...
method IsNotTypef (line 875) | func (a *Assertions) IsNotTypef(theType interface{}, object interface{},...
method IsType (line 885) | func (a *Assertions) IsType(expectedType interface{}, object interface{}...
method IsTypef (line 895) | func (a *Assertions) IsTypef(expectedType interface{}, object interface{...
method JSONEq (line 905) | func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ....
method JSONEqf (line 915) | func (a *Assertions) JSONEqf(expected string, actual string, msg string,...
method Len (line 926) | func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...i...
method Lenf (line 937) | func (a *Assertions) Lenf(object interface{}, length int, msg string, ar...
method Less (line 949) | func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ......
method LessOrEqual (line 962) | func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndA...
method LessOrEqualf (line 975) | func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg st...
method Lessf (line 987) | func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, a...
method Negative (line 998) | func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) {
method Negativef (line 1009) | func (a *Assertions) Negativef(e interface{}, msg string, args ...interf...
method Never (line 1020) | func (a *Assertions) Never(condition func() bool, waitFor time.Duration,...
method Neverf (line 1031) | func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration...
method Nil (line 1041) | func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
method Nilf (line 1051) | func (a *Assertions) Nilf(object interface{}, msg string, args ...interf...
method NoDirExists (line 1060) | func (a *Assertions) NoDirExists(path string, msgAndArgs ...interface{}) {
method NoDirExistsf (line 1069) | func (a *Assertions) NoDirExistsf(path string, msg string, args ...inter...
method NoError (line 1081) | func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
method NoErrorf (line 1093) | func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
method NoFileExists (line 1102) | func (a *Assertions) NoFileExists(path string, msgAndArgs ...interface{}) {
method NoFileExistsf (line 1111) | func (a *Assertions) NoFileExistsf(path string, msg string, args ...inte...
method NotContains (line 1124) | func (a *Assertions) NotContains(s interface{}, contains interface{}, ms...
method NotContainsf (line 1137) | func (a *Assertions) NotContainsf(s interface{}, contains interface{}, m...
method NotElementsMatch (line 1154) | func (a *Assertions) NotElementsMatch(listA interface{}, listB interface...
method NotElementsMatchf (line 1171) | func (a *Assertions) NotElementsMatchf(listA interface{}, listB interfac...
method NotEmpty (line 1182) | func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interfac...
method NotEmptyf (line 1193) | func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...i...
method NotEqual (line 1206) | func (a *Assertions) NotEqual(expected interface{}, actual interface{}, ...
method NotEqualValues (line 1216) | func (a *Assertions) NotEqualValues(expected interface{}, actual interfa...
method NotEqualValuesf (line 1226) | func (a *Assertions) NotEqualValuesf(expected interface{}, actual interf...
method NotEqualf (line 1239) | func (a *Assertions) NotEqualf(expected interface{}, actual interface{},...
method NotErrorAs (line 1248) | func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArg...
method NotErrorAsf (line 1257) | func (a *Assertions) NotErrorAsf(err error, target interface{}, msg stri...
method NotErrorIs (line 1266) | func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...i...
method NotErrorIsf (line 1275) | func (a *Assertions) NotErrorIsf(err error, target error, msg string, ar...
method NotImplements (line 1285) | func (a *Assertions) NotImplements(interfaceObject interface{}, object i...
method NotImplementsf (line 1295) | func (a *Assertions) NotImplementsf(interfaceObject interface{}, object ...
method NotNil (line 1305) | func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{...
method NotNilf (line 1315) | func (a *Assertions) NotNilf(object interface{}, msg string, args ...int...
method NotPanics (line 1325) | func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...int...
method NotPanicsf (line 1335) | func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args...
method NotRegexp (line 1346) | func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndAr...
method NotRegexpf (line 1357) | func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg str...
method NotSame (line 1370) | func (a *Assertions) NotSame(expected interface{}, actual interface{}, m...
method NotSamef (line 1383) | func (a *Assertions) NotSamef(expected interface{}, actual interface{}, ...
method NotSubset (line 1399) | func (a *Assertions) NotSubset(list interface{}, subset interface{}, msg...
method NotSubsetf (line 1415) | func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, ms...
method NotZero (line 1423) | func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
method NotZerof (line 1431) | func (a *Assertions) NotZerof(i interface{}, msg string, args ...interfa...
method Panics (line 1441) | func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interf...
method PanicsWithError (line 1453) | func (a *Assertions) PanicsWithError(errString string, f assert.PanicTes...
method PanicsWithErrorf (line 1465) | func (a *Assertions) PanicsWithErrorf(errString string, f assert.PanicTe...
method PanicsWithValue (line 1476) | func (a *Assertions) PanicsWithValue(expected interface{}, f assert.Pani...
method PanicsWithValuef (line 1487) | func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.Pan...
method Panicsf (line 1497) | func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args .....
method Positive (line 1508) | func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) {
method Positivef (line 1519) | func (a *Assertions) Positivef(e interface{}, msg string, args ...interf...
method Regexp (line 1530) | func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...
method Regexpf (line 1541) | func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string...
method Same (line 1554) | func (a *Assertions) Same(expected interface{}, actual interface{}, msgA...
method Samef (line 1567) | func (a *Assertions) Samef(expected interface{}, actual interface{}, msg...
method Subset (line 1583) | func (a *Assertions) Subset(list interface{}, subset interface{}, msgAnd...
method Subsetf (line 1599) | func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg s...
method True (line 1609) | func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
method Truef (line 1619) | func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
method WithinDuration (line 1629) | func (a *Assertions) WithinDuration(expected time.Time, actual time.Time...
method WithinDurationf (line 1639) | func (a *Assertions) WithinDurationf(expected time.Time, actual time.Tim...
method WithinRange (line 1649) | func (a *Assertions) WithinRange(actual time.Time, start time.Time, end ...
method WithinRangef (line 1659) | func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end...
method YAMLEq (line 1679) | func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ....
method YAMLEqf (line 1699) | func (a *Assertions) YAMLEqf(expected string, actual string, msg string,...
method Zero (line 1707) | func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
method Zerof (line 1715) | func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{...
FILE: require/requirements.go
type TestingT (line 4) | type TestingT interface
type ComparisonAssertionFunc (line 15) | type ComparisonAssertionFunc
type ValueAssertionFunc (line 19) | type ValueAssertionFunc
type BoolAssertionFunc (line 23) | type BoolAssertionFunc
type ErrorAssertionFunc (line 27) | type ErrorAssertionFunc
FILE: require/requirements_test.go
type AssertionTesterInterface (line 13) | type AssertionTesterInterface interface
type AssertionTesterConformingObject (line 18) | type AssertionTesterConformingObject struct
method TestMethod (line 21) | func (a *AssertionTesterConformingObject) TestMethod() {
type AssertionTesterNonConformingObject (line 25) | type AssertionTesterNonConformingObject struct
type MockT (line 28) | type MockT struct
method Helper (line 33) | func (MockT) Helper() {}
method FailNow (line 35) | func (t *MockT) FailNow() {
method Errorf (line 39) | func (t *MockT) Errorf(format string, args ...interface{}) {
function TestImplements (line 43) | func TestImplements(t *testing.T) {
function TestIsType (line 55) | func TestIsType(t *testing.T) {
function TestEqual (line 67) | func TestEqual(t *testing.T) {
function TestNotEqual (line 80) | func TestNotEqual(t *testing.T) {
function TestExactly (line 91) | func TestExactly(t *testing.T) {
function TestNotNil (line 107) | func TestNotNil(t *testing.T) {
function TestNil (line 119) | func TestNil(t *testing.T) {
function TestTrue (line 131) | func TestTrue(t *testing.T) {
function TestFalse (line 143) | func TestFalse(t *testing.T) {
function TestContains (line 155) | func TestContains(t *testing.T) {
function TestNotContains (line 167) | func TestNotContains(t *testing.T) {
function TestPanics (line 179) | func TestPanics(t *testing.T) {
function TestNotPanics (line 193) | func TestNotPanics(t *testing.T) {
function TestNoError (line 207) | func TestNoError(t *testing.T) {
function TestError (line 219) | func TestError(t *testing.T) {
function TestErrorContains (line 231) | func TestErrorContains(t *testing.T) {
function TestEqualError (line 243) | func TestEqualError(t *testing.T) {
function TestEmpty (line 255) | func TestEmpty(t *testing.T) {
function TestNotEmpty (line 267) | func TestNotEmpty(t *testing.T) {
function TestWithinDuration (line 279) | func TestWithinDuration(t *testing.T) {
function TestInDelta (line 294) | func TestInDelta(t *testing.T) {
function TestZero (line 306) | func TestZero(t *testing.T) {
function TestNotZero (line 318) | func TestNotZero(t *testing.T) {
function TestJSONEq_EqualSONString (line 330) | func TestJSONEq_EqualSONString(t *testing.T) {
function TestJSONEq_EquivalentButNotEqual (line 340) | func TestJSONEq_EquivalentButNotEqual(t *testing.T) {
function TestJSONEq_HashOfArraysAndHashes (line 350) | func TestJSONEq_HashOfArraysAndHashes(t *testing.T) {
function TestJSONEq_Array (line 361) | func TestJSONEq_Array(t *testing.T) {
function TestJSONEq_HashAndArrayNotEquivalent (line 371) | func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) {
function TestJSONEq_HashesNotEquivalent (line 381) | func TestJSONEq_HashesNotEquivalent(t *testing.T) {
function TestJSONEq_ActualIsNotJSON (line 391) | func TestJSONEq_ActualIsNotJSON(t *testing.T) {
function TestJSONEq_ExpectedIsNotJSON (line 401) | func TestJSONEq_ExpectedIsNotJSON(t *testing.T) {
function TestJSONEq_ExpectedAndActualNotJSON (line 411) | func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) {
function TestJSONEq_ArraysOfDifferentOrder (line 421) | func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) {
function TestYAMLEq_EqualYAMLString (line 431) | func TestYAMLEq_EqualYAMLString(t *testing.T) {
function TestYAMLEq_EquivalentButNotEqual (line 441) | func TestYAMLEq_EquivalentButNotEqual(t *testing.T) {
function TestYAMLEq_HashOfArraysAndHashes (line 451) | func TestYAMLEq_HashOfArraysAndHashes(t *testing.T) {
function TestYAMLEq_Array (line 486) | func TestYAMLEq_Array(t *testing.T) {
function TestYAMLEq_HashAndArrayNotEquivalent (line 496) | func TestYAMLEq_HashAndArrayNotEquivalent(t *testing.T) {
function TestYAMLEq_HashesNotEquivalent (line 506) | func TestYAMLEq_HashesNotEquivalent(t *testing.T) {
function TestYAMLEq_ActualIsSimpleString (line 516) | func TestYAMLEq_ActualIsSimpleString(t *testing.T) {
function TestYAMLEq_ExpectedIsSimpleString (line 526) | func TestYAMLEq_ExpectedIsSimpleString(t *testing.T) {
function TestYAMLEq_ExpectedAndActualSimpleString (line 536) | func TestYAMLEq_ExpectedAndActualSimpleString(t *testing.T) {
function TestYAMLEq_ArraysOfDifferentOrder (line 546) | func TestYAMLEq_ArraysOfDifferentOrder(t *testing.T) {
function ExampleComparisonAssertionFunc (line 556) | func ExampleComparisonAssertionFunc() {
function TestComparisonAssertionFunc (line 586) | func TestComparisonAssertionFunc(t *testing.T) {
function ExampleValueAssertionFunc (line 621) | func ExampleValueAssertionFunc() {
function TestValueAssertionFunc (line 649) | func TestValueAssertionFunc(t *testing.T) {
function ExampleBoolAssertionFunc (line 672) | func ExampleBoolAssertionFunc() {
function TestBoolAssertionFunc (line 697) | func TestBoolAssertionFunc(t *testing.T) {
function ExampleErrorAssertionFunc (line 716) | func ExampleErrorAssertionFunc() {
function TestErrorAssertionFunc (line 742) | func TestErrorAssertionFunc(t *testing.T) {
function TestEventuallyWithTFalse (line 761) | func TestEventuallyWithTFalse(t *testing.T) {
function TestEventuallyWithTTrue (line 774) | func TestEventuallyWithTTrue(t *testing.T) {
FILE: suite/interfaces.go
type TestingSuite (line 7) | type TestingSuite interface
type SetupAllSuite (line 15) | type SetupAllSuite interface
type SetupTestSuite (line 21) | type SetupTestSuite interface
type TearDownAllSuite (line 27) | type TearDownAllSuite interface
type TearDownTestSuite (line 33) | type TearDownTestSuite interface
type BeforeTest (line 39) | type BeforeTest interface
type AfterTest (line 45) | type AfterTest interface
type WithStats (line 52) | type WithStats interface
type SetupSubTest (line 58) | type SetupSubTest interface
type TearDownSubTest (line 64) | type TearDownSubTest interface
FILE: suite/stats.go
type SuiteInformation (line 6) | type SuiteInformation struct
method start (line 24) | func (s *SuiteInformation) start(testName string) {
method end (line 34) | func (s *SuiteInformation) end(testName string, passed bool) {
method Passed (line 42) | func (s *SuiteInformation) Passed() bool {
type TestInformation (line 12) | type TestInformation struct
function newSuiteInformation (line 18) | func newSuiteInformation() *SuiteInformation {
FILE: suite/stats_test.go
function TestPassedReturnsTrueWhenAllTestsPass (line 9) | func TestPassedReturnsTrueWhenAllTestsPass(t *testing.T) {
function TestPassedReturnsFalseWhenSomeTestFails (line 20) | func TestPassedReturnsFalseWhenSomeTestFails(t *testing.T) {
function TestPassedReturnsFalseWhenAllTestsFail (line 31) | func TestPassedReturnsFalseWhenAllTestsFail(t *testing.T) {
FILE: suite/suite.go
type Suite (line 23) | type Suite struct
method T (line 35) | func (suite *Suite) T() *testing.T {
method SetT (line 42) | func (suite *Suite) SetT(t *testing.T) {
method SetS (line 52) | func (suite *Suite) SetS(s TestingSuite) {
method Require (line 57) | func (suite *Suite) Require() *require.Assertions {
method Assert (line 75) | func (suite *Suite) Assert() *assert.Assertions {
method Run (line 102) | func (suite *Suite) Run(name string, subtest func()) bool {
function recoverAndFailOnPanic (line 84) | func recoverAndFailOnPanic(t *testing.T) {
function failOnPanic (line 90) | func failOnPanic(t *testing.T, r interface{}) {
function Run (line 130) | func Run(t *testing.T, suite TestingSuite) {
function runTests (line 244) | func runTests(t *testing.T, tests []test) {
FILE: suite/suite_test.go
function allTestsFilter (line 20) | func allTestsFilter(pat, str string) (bool, error) {
type SuiteRequireTwice (line 26) | type SuiteRequireTwice struct
method TestRequireOne (line 45) | func (s *SuiteRequireTwice) TestRequireOne() {
method TestRequireTwo (line 50) | func (s *SuiteRequireTwice) TestRequireTwo() {
function TestSuiteRequireTwice (line 31) | func TestSuiteRequireTwice(t *testing.T) {
type panickingSuite (line 55) | type panickingSuite struct
method SetupSuite (line 66) | func (s *panickingSuite) SetupSuite() {
method SetupTest (line 72) | func (s *panickingSuite) SetupTest() {
method BeforeTest (line 78) | func (s *panickingSuite) BeforeTest(_, _ string) {
method Test (line 84) | func (s *panickingSuite) Test() {
method AfterTest (line 90) | func (s *panickingSuite) AfterTest(_, _ string) {
method TearDownTest (line 96) | func (s *panickingSuite) TearDownTest() {
method TearDownSuite (line 102) | func (s *panickingSuite) TearDownSuite() {
function TestSuiteRecoverPanic (line 108) | func TestSuiteRecoverPanic(t *testing.T) {
type SuiteTester (line 154) | type SuiteTester struct
method SetupSuite (line 185) | func (suite *SuiteTester) SetupSuite() {
method BeforeTest (line 189) | func (suite *SuiteTester) BeforeTest(suiteName, testName string) {
method AfterTest (line 195) | func (suite *SuiteTester) AfterTest(suiteName, testName string) {
method TearDownSuite (line 203) | func (suite *SuiteTester) TearDownSuite() {
method SetupTest (line 208) | func (suite *SuiteTester) SetupTest() {
method TearDownTest (line 213) | func (suite *SuiteTester) TearDownTest() {
method TestOne (line 221) | func (suite *SuiteTester) TestOne() {
method TestTwo (line 229) | func (suite *SuiteTester) TestTwo() {
method TestSkip (line 236) | func (suite *SuiteTester) TestSkip() {
method NonTestMethod (line 243) | func (suite *SuiteTester) NonTestMethod() {
method TestSubtest (line 247) | func (suite *SuiteTester) TestSubtest() {
method TearDownSubTest (line 268) | func (suite *SuiteTester) TearDownSubTest() {
method SetupSubTest (line 273) | func (suite *SuiteTester) SetupSubTest() {
type SuiteSkipTester (line 278) | type SuiteSkipTester struct
method SetupSuite (line 287) | func (suite *SuiteSkipTester) SetupSuite() {
method TestNothing (line 292) | func (suite *SuiteSkipTester) TestNothing() {
method TearDownSuite (line 298) | func (suite *SuiteSkipTester) TearDownSuite() {
function TestRunSuite (line 304) | func TestRunSuite(t *testing.T) {
type SuiteSetupSkipTester (line 384) | type SuiteSetupSkipTester struct
method SetupSuite (line 391) | func (s *SuiteSetupSkipTester) SetupSuite() {
method NonTestMethod (line 395) | func (s *SuiteSetupSkipTester) NonTestMethod() {
method TearDownSuite (line 399) | func (s *SuiteSetupSkipTester) TearDownSuite() {
function TestSkippingSuiteSetup (line 403) | func TestSkippingSuiteSetup(t *testing.T) {
function TestSuiteGetters (line 410) | func TestSuiteGetters(t *testing.T) {
type SuiteLoggingTester (line 419) | type SuiteLoggingTester struct
method TestLoggingPass (line 423) | func (s *SuiteLoggingTester) TestLoggingPass() {
method TestLoggingFail (line 427) | func (s *SuiteLoggingTester) TestLoggingFail() {
type StdoutCapture (line 432) | type StdoutCapture struct
method StartCapture (line 437) | func (sc *StdoutCapture) StartCapture() {
method StopCapture (line 442) | func (sc *StdoutCapture) StopCapture() (string, error) {
function TestSuiteLogging (line 455) | func TestSuiteLogging(t *testing.T) {
type CallOrderSuite (line 481) | type CallOrderSuite struct
method call (line 486) | func (s *CallOrderSuite) call(method string) {
method SetupSuite (line 494) | func (s *CallOrderSuite) SetupSuite() {
method TearDownSuite (line 498) | func (s *CallOrderSuite) TearDownSuite() {
method SetupTest (line 502) | func (s *CallOrderSuite) SetupTest() {
method TearDownTest (line 506) | func (s *CallOrderSuite) TearDownTest() {
method SetupSubTest (line 510) | func (s *CallOrderSuite) SetupSubTest() {
method TearDownSubTest (line 514) | func (s *CallOrderSuite) TearDownSubTest() {
method Test_A (line 518) | func (s *CallOrderSuite) Test_A() {
method Test_B (line 528) | func (s *CallOrderSuite) Test_B() {
function TestSuiteCallOrder (line 491) | func TestSuiteCallOrder(t *testing.T) {
type suiteWithStats (line 538) | type suiteWithStats struct
method HandleStats (line 544) | func (s *suiteWithStats) HandleStats(suiteName string, stats *SuiteInf...
method TestSomething (line 549) | func (s *suiteWithStats) TestSomething() {
method TestPanic (line 553) | func (s *suiteWithStats) TestPanic() {
function TestSuiteWithStats (line 557) | func TestSuiteWithStats(t *testing.T) {
type FailfastSuite (line 588) | type FailfastSuite struct
method call (line 593) | func (s *FailfastSuite) call(method string) {
method SetupSuite (line 663) | func (s *FailfastSuite) SetupSuite() {
method TearDownSuite (line 667) | func (s *FailfastSuite) TearDownSuite() {
method SetupTest (line 670) | func (s *FailfastSuite) SetupTest() {
method TearDownTest (line 674) | func (s *FailfastSuite) TearDownTest() {
method Test_A_Fails (line 678) | func (s *FailfastSuite) Test_A_Fails() {
method Test_B_Passes (line 683) | func (s *FailfastSuite) Test_B_Passes() {
function TestFailfastSuite (line 597) | func TestFailfastSuite(t *testing.T) {
type tHelper (line 623) | type tHelper interface
function callOrderAssert (line 630) | func callOrderAssert(t *testing.T, expect, callOrder []string) {
function TestFailfastSuiteFailFastOn (line 650) | func TestFailfastSuiteFailFastOn(t *testing.T) {
type subtestPanicSuite (line 688) | type subtestPanicSuite struct
method TearDownSuite (line 695) | func (s *subtestPanicSuite) TearDownSuite() {
method TearDownTest (line 699) | func (s *subtestPanicSuite) TearDownTest() {
method TearDownSubTest (line 703) | func (s *subtestPanicSuite) TearDownSubTest() {
method TestSubtestPanic (line 707) | func (s *subtestPanicSuite) TestSubtestPanic() {
function TestSubtestPanic (line 714) | func TestSubtestPanic(t *testing.T) {
type unInitializedSuite (line 731) | type unInitializedSuite struct
function TestUnInitializedSuites (line 737) | func TestUnInitializedSuites(t *testing.T) {
type SuiteSignatureValidationTester (line 756) | type SuiteSignatureValidationTester struct
method SetupSuite (line 765) | func (s *SuiteSignatureValidationTester) SetupSuite() {
method TearDownSuite (line 770) | func (s *SuiteSignatureValidationTester) TearDownSuite() {
method TestValidSignature (line 775) | func (s *SuiteSignatureValidationTester) TestValidSignature() {
method TestInvalidSignatureReturnValue (line 780) | func (s *SuiteSignatureValidationTester) TestInvalidSignatureReturnVal...
method TestInvalidSignatureArg (line 786) | func (s *SuiteSignatureValidationTester) TestInvalidSignatureArg(somea...
method TestInvalidSignatureBoth (line 791) | func (s *SuiteSignatureValidationTester) TestInvalidSignatureBoth(some...
function TestSuiteSignatureValidation (line 797) | func TestSuiteSignatureValidation(t *testing.T) {
Condensed preview — 86 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (989K chars).
[
{
"path": ".ci.gofmt.sh",
"chars": 286,
"preview": "#!/usr/bin/env bash\n\nif [ -n \"$(gofmt -l .)\" ]; then\n echo \"Go code is not formatted:\"\n gofmt -d .\n exit 1\nfi\n\ngo gen"
},
{
"path": ".ci.gogenerate.sh",
"chars": 463,
"preview": "#!/usr/bin/env bash\n\n# If GOMOD is defined we are running with Go Modules enabled, either\n# automatically or via the GO1"
},
{
"path": ".ci.govet.sh",
"chars": 42,
"preview": "#!/usr/bin/env bash\n\nset -e\n\ngo vet ./...\n"
},
{
"path": ".ci.readme.fmt.sh",
"chars": 416,
"preview": "#!/usr/bin/env bash\n\n# Verify that the code snippets in README.md are formatted.\n# The tool https://github.com/hougesen/"
},
{
"path": ".gitattributes",
"chars": 678,
"preview": "# This file is used to configure Git attributes for the repository.\n# It is particularly useful for managing how generat"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 535,
"preview": "---\nname: Bug report\nabout: Format to report a bug\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n<!-- If this is a question,"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 506,
"preview": "---\nname: Feature request\nabout: Propose a new feature\ntitle: ''\nlabels: enhancement\nassignees: ''\n\n---\n\n<!-- If this is"
},
{
"path": ".github/dependabot.yml",
"chars": 177,
"preview": "version: 2\nupdates:\n- package-ecosystem: gomod\n directory: /\n schedule:\n interval: daily\n- package-ecosystem: githu"
},
{
"path": ".github/pull_request_template.md",
"chars": 366,
"preview": "## Summary\n<!-- High-level, one sentence summary of what this PR accomplishes -->\n\n## Changes\n<!-- * Description of chan"
},
{
"path": ".github/workflows/main.yml",
"chars": 966,
"preview": "name: All builds\non: [push, pull_request]\n\njobs:\n build:\n runs-on: ubuntu-latest\n strategy:\n matrix:\n "
},
{
"path": ".github/workflows/release.yml",
"chars": 460,
"preview": "name: Create release from new tag\n\n# this flow will be run only when new tags are pushed that match our pattern\non:\n pu"
},
{
"path": ".gitignore",
"chars": 365,
"preview": "# Compiled Object files, Static and Dynamic libs (Shared Objects)\n*.o\n*.a\n*.so\n\n# Folders\n_obj\n_test\n\n# Architecture spe"
},
{
"path": ".mdsf.json",
"chars": 234,
"preview": "{\n \"$schema\": \"https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.8.2/mdsf.schema.json\",\n \"format_finishe"
},
{
"path": "CONTRIBUTING.md",
"chars": 2566,
"preview": "# Contributing to Testify\n\nSo you'd like to contribute to Testify? First of all, thank you! Testify is widely used, so e"
},
{
"path": "EMERITUS.md",
"chars": 303,
"preview": "# Emeritus\n\nWe would like to acknowledge previous testify maintainers and their huge contributions to our collective suc"
},
{
"path": "LICENSE",
"chars": 1103,
"preview": "MIT License\n\nCopyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors.\n\nPermission is hereby granted, free of ch"
},
{
"path": "MAINTAINERS.md",
"chars": 358,
"preview": "# Testify Maintainers\n\nThe individuals listed below are active in the project and have the ability to approve and merge\n"
},
{
"path": "README.md",
"chars": 12099,
"preview": "Testify - Thou Shalt Write Tests\n================================\n\n> [!NOTE]\n> Testify is being maintained at v1, no bre"
},
{
"path": "assert/assertion_compare.go",
"chars": 12691,
"preview": "package assert\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"time\"\n)\n\n// Deprecated: CompareType has only ever been for interna"
},
{
"path": "assert/assertion_compare_test.go",
"chars": 17670,
"preview": "package assert\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"runtime\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestCompare(t *testing.T) {\n\tt"
},
{
"path": "assert/assertion_format.go",
"chars": 35822,
"preview": "// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.\n\npackage assert\n\nimport (\n\thttp \"net/http\"\n\tur"
},
{
"path": "assert/assertion_format.go.tmpl",
"chars": 184,
"preview": "{{.CommentFormat}}\nfunc {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {\n\tif h, ok := t.(tHelper); ok { h.Helper"
},
{
"path": "assert/assertion_forward.go",
"chars": 63727,
"preview": "// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.\n\npackage assert\n\nimport (\n\thttp \"net/http\"\n\tur"
},
{
"path": "assert/assertion_forward.go.tmpl",
"chars": 185,
"preview": "{{.CommentWithoutT \"a\"}}\nfunc (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {\n\tif h, ok := a.t.(tHelper); ok { h.H"
},
{
"path": "assert/assertion_order.go",
"chars": 3021,
"preview": "package assert\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n)\n\n// isOrdered checks that collection contains orderable elements.\nfunc isOr"
},
{
"path": "assert/assertion_order_test.go",
"chars": 8439,
"preview": "package assert\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestIsIncreasing(t *testing.T) {\n\tt.Parallel()\n\n\tmockT := ne"
},
{
"path": "assert/assertions.go",
"chars": 67662,
"preview": "package assert\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"runtim"
},
{
"path": "assert/assertions_test.go",
"chars": 109262,
"preview": "package assert\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"refl"
},
{
"path": "assert/doc.go",
"chars": 1441,
"preview": "// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.\n//\n// # Note\n"
},
{
"path": "assert/errors.go",
"chars": 326,
"preview": "package assert\n\nimport (\n\t\"errors\"\n)\n\n// AnError is an error instance useful for testing. If the code does not care\n// "
},
{
"path": "assert/forward_assertions.go",
"chars": 428,
"preview": "package assert\n\n// Assertions provides assertion methods around the\n// TestingT interface.\ntype Assertions struct {\n\tt T"
},
{
"path": "assert/forward_assertions_test.go",
"chars": 21804,
"preview": "package assert\n\nimport (\n\t\"errors\"\n\t\"regexp\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestImplementsWrapper(t *testing.T) {\n\tt.Paralle"
},
{
"path": "assert/http_assertions.go",
"chars": 5724,
"preview": "package assert\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"net/url\"\n\t\"strings\"\n)\n\n// httpCode is a helper that r"
},
{
"path": "assert/http_assertions_test.go",
"chars": 7419,
"preview": "package assert\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"testing\"\n)\n\nfunc httpOK(w http.ResponseWriter, r *http.Re"
},
{
"path": "assert/internal/unsafetests/doc.go",
"chars": 152,
"preview": "// This package exists just to isolate tests that reference the [unsafe] package.\n//\n// The tests in this package are to"
},
{
"path": "assert/internal/unsafetests/unsafetests_test.go",
"chars": 1025,
"preview": "package unsafetests_test\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\t\"unsafe\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\ntype ignoreTest"
},
{
"path": "assert/yaml/yaml_custom.go",
"chars": 727,
"preview": "//go:build testify_yaml_custom && !testify_yaml_fail && !testify_yaml_default\n\n// Package yaml is an implementation of Y"
},
{
"path": "assert/yaml/yaml_default.go",
"chars": 1510,
"preview": "//go:build !testify_yaml_fail && !testify_yaml_custom\n\n// Package yaml is just an indirection to handle YAML deserializa"
},
{
"path": "assert/yaml/yaml_fail.go",
"chars": 565,
"preview": "//go:build testify_yaml_fail && !testify_yaml_custom && !testify_yaml_default\n\n// Package yaml is an implementation of Y"
},
{
"path": "doc.go",
"chars": 1076,
"preview": "// Module testify is a set of packages that provide many tools for testifying that your code will behave as you intend.\n"
},
{
"path": "go.mod",
"chars": 425,
"preview": "module github.com/stretchr/testify\n\n// This should match the minimum supported version that is tested in\n// .github/work"
},
{
"path": "go.sum",
"chars": 708,
"preview": "github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/pmezard/go-difflib v"
},
{
"path": "http/doc.go",
"chars": 61,
"preview": "// Deprecated: Use [net/http/httptest] instead.\npackage http\n"
},
{
"path": "http/test_response_writer.go",
"chars": 1020,
"preview": "package http\n\nimport (\n\t\"net/http\"\n)\n\n// Deprecated: Use [net/http/httptest] instead.\ntype TestResponseWriter struct {\n\n"
},
{
"path": "http/test_round_tripper.go",
"chars": 375,
"preview": "package http\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/stretchr/testify/mock\"\n)\n\n// Deprecated: Use [net/http/httptest] instea"
},
{
"path": "internal/difflib/LICENSE",
"chars": 1444,
"preview": "Copyright (c) 2013, Patrick Mezard\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or with"
},
{
"path": "internal/difflib/difflib.go",
"chars": 17972,
"preview": "// Package difflib is a partial port of Python difflib module.\n//\n// It provides tools to compare sequences of strings a"
},
{
"path": "internal/difflib/difflib_test.go",
"chars": 6719,
"preview": "package difflib\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"math\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc assertAlmostEqual(t *testing."
},
{
"path": "internal/spew/LICENSE",
"chars": 766,
"preview": "ISC License\n\nCopyright (c) 2012-2016 Dave Collins <dave@davec.name>\n\nPermission to use, copy, modify, and/or distribute "
},
{
"path": "internal/spew/README.md",
"chars": 379,
"preview": "go-spew\n=======\n\n[](http://copyfree.org)\n\nGo-spew implem"
},
{
"path": "internal/spew/bypass.go",
"chars": 4780,
"preview": "// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>\n//\n// Permission to use, copy, modify, and distribute this sof"
},
{
"path": "internal/spew/bypasssafe.go",
"chars": 1803,
"preview": "// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>\n//\n// Permission to use, copy, modify, and distribute this sof"
},
{
"path": "internal/spew/common.go",
"chars": 10364,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/common_test.go",
"chars": 7940,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/config.go",
"chars": 12845,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/doc.go",
"chars": 8628,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/dump.go",
"chars": 13803,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/dump_test.go",
"chars": 33791,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/dumpcgo_test.go",
"chars": 4031,
"preview": "// Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n//\n// Permission to use, copy, modify, and distribute this sof"
},
{
"path": "internal/spew/dumpnocgo_test.go",
"chars": 1247,
"preview": "// Copyright (c) 2013 Dave Collins <dave@davec.name>\n//\n// Permission to use, copy, modify, and distribute this software"
},
{
"path": "internal/spew/format.go",
"chars": 11314,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/format_test.go",
"chars": 57476,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/internal_test.go",
"chars": 2546,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/internalunsafe_test.go",
"chars": 3291,
"preview": "// Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n\n// Permission to use, copy, modify, and distribute this softw"
},
{
"path": "internal/spew/spew.go",
"chars": 5969,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/spew_test.go",
"chars": 9651,
"preview": "/*\n * Copyright (c) 2013-2016 Dave Collins <dave@davec.name>\n *\n * Permission to use, copy, modify, and distribute this "
},
{
"path": "internal/spew/testdata/dumpcgo.go",
"chars": 3313,
"preview": "// Copyright (c) 2013 Dave Collins <dave@davec.name>\n//\n// Permission to use, copy, modify, and distribute this software"
},
{
"path": "mock/doc.go",
"chars": 1553,
"preview": "// Package mock provides a system by which it is possible to mock your objects\n// and verify calls are happening as expe"
},
{
"path": "mock/mock.go",
"chars": 38193,
"preview": "package mock\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"path\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com"
},
{
"path": "mock/mock_test.go",
"chars": 66803,
"preview": "package mock\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strconv\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github."
},
{
"path": "package_test.go",
"chars": 186,
"preview": "package testify\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\nfunc TestImports(t *testing.T) {\n\tif asse"
},
{
"path": "require/doc.go",
"chars": 1007,
"preview": "// Package require implements the same assertions as the assert package but\n// stops test execution when a test fails.\n/"
},
{
"path": "require/forward_requirements.go",
"chars": 428,
"preview": "package require\n\n// Assertions provides assertion methods around the\n// TestingT interface.\ntype Assertions struct {\n\tt "
},
{
"path": "require/forward_requirements_test.go",
"chars": 12601,
"preview": "package require\n\nimport (\n\t\"errors\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestImplementsWrapper(t *testing.T) {\n\tt.Parallel()\n\n\treq"
},
{
"path": "require/require.go",
"chars": 67187,
"preview": "// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.\n\npackage require\n\nimport (\n\tassert \"github.com"
},
{
"path": "require/require.go.tmpl",
"chars": 194,
"preview": "{{.CommentRequire}}\nfunc {{.DocInfo.Name}}(t TestingT, {{.Params}}) {\n\tif h, ok := t.(tHelper); ok { h.Helper() }\n\tif as"
},
{
"path": "require/require_forward.go",
"chars": 61049,
"preview": "// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT.\n\npackage require\n\nimport (\n\tassert \"github.com"
},
{
"path": "require/require_forward.go.tmpl",
"chars": 180,
"preview": "{{.CommentRequireWithoutT \"a\"}}\nfunc (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {\n\tif h, ok := a.t.(tHelper); ok { h"
},
{
"path": "require/requirements.go",
"chars": 1133,
"preview": "package require\n\n// TestingT is an interface wrapper around *testing.T\ntype TestingT interface {\n\tErrorf(format string, "
},
{
"path": "require/requirements_test.go",
"chars": 15635,
"preview": "package require\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\n// Ass"
},
{
"path": "suite/doc.go",
"chars": 2709,
"preview": "// Package suite contains logic for creating testing suite structs\n// and running the methods on those structs as tests."
},
{
"path": "suite/interfaces.go",
"chars": 1795,
"preview": "package suite\n\nimport \"testing\"\n\n// TestingSuite can store and return the current *testing.T context\n// generated by 'go"
},
{
"path": "suite/stats.go",
"chars": 973,
"preview": "package suite\n\nimport \"time\"\n\n// SuiteInformation stats stores stats for the whole suite execution.\ntype SuiteInformatio"
},
{
"path": "suite/stats_test.go",
"chars": 1033,
"preview": "package suite\n\nimport (\n\t\"testing\"\n\n\t\"github.com/stretchr/testify/assert\"\n)\n\nfunc TestPassedReturnsTrueWhenAllTestsPass("
},
{
"path": "suite/suite.go",
"chars": 5858,
"preview": "package suite\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"os\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"runtime/debug\"\n\t\"strings\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\""
},
{
"path": "suite/suite_test.go",
"chars": 22111,
"preview": "package suite\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"flag\"\n\t\"io\"\n\t\"math/rand\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\""
}
]
About this extraction
This page contains the full source code of the stretchr/testify GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 86 files (884.8 KB), approximately 267.8k tokens, and a symbol index with 1653 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.