Skip to content

weiwenchen2022/assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assert for Go 1.18+ test assertions

Install

go get github.com/weiwenchen2022/assert

Usage

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