An open API service indexing awesome lists of open source software.

https://github.com/weiwenchen2022/assert

Assert for Go 1.18+ test assertions
https://github.com/weiwenchen2022/assert

assertion go library testing

Last synced: 9 months ago
JSON representation

Assert for Go 1.18+ test assertions

Awesome Lists containing this project

README

          

# Assert for Go 1.18+ test assertions

## Install

```sh
go get github.com/weiwenchen2022/assert
```

## Usage

```go
package main

import (
"testing"
"github.com/weiwenchen2022/assert"
)

func greet(name string) (string, int) {
greeting := fmt.Sprintf("Hello %s", name)

// Return the greeting and its length (in bytes).
return greeting, len(greeting)
}

func TestGreet(t *testing.T) {
greeting, greetingLength := greet("Alice")

assert.Equal(t, "Hello Alice", greeting, "greeting:")
assert.Equal(t, 11, greetingLength, "greetingLength:")
}
```

## Reference

GoDoc: [https://godoc.org/github.com/weiwenchen2022/assert](https://godoc.org/github.com/weiwenchen2022/assert)