-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.go
39 lines (39 loc) · 1.21 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Package aver adds assertion functions for Go. Its usage is inspired by the "expect" assertion pattern.
//
// Usage
//
// Example usage in a *_test.go file:
// import (
// "testing"
// "github.com/mtso/aver"
// )
//
// func TestExample(t *testing.T) {
// // Create a new Averrer instance
// aver := aver.New(t)
//
// // FAIL the test with Errorf
// expected := "expectedString"
// actual := "actualString"
// aver(expected).ToEqual(actual)
//
// // Store the returned Averrable in a variable
// isEven := aver(true)
// actual1 := 1 % 2 == 0 // false
// actual2 := 2 % 2 == 0 // true
// isEven.ToNotEqual(actual1)
// isEven.ToEqual(actual2)
// }
//
// Aver is Expect
//
// Aver (Expect) assertions allow you to compare two values in a test.
// aver.New(t *testing.T) returns a new Averrer function.
// The Averrer function accepts an "expected" value as a parameter and returns
// an Aver object that conforms to the Averrable interface. The Aver
// object stores the expected value and a reference to the testing.T instance.
// The Aver object can then be called with an Averrable function to compare
// the stored "expected" value with an "actual" value passed into the
// Averrable function.
//
package aver