Skip to content

Commit c4b112e

Browse files
committed
doc: update readme.
1 parent 641c815 commit c4b112e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
A collection of Golang assertion functions for verifying invariants.
1010

11+
- [Installation](#installation)
12+
- [Getting Started](#getting-started)
13+
- [Available Assertions](#available-assertions)
14+
- [Equality](#equality)
15+
- [Value](#value)
16+
- [String](#string)
17+
- [Slice or Array](#slice-or-array)
18+
- [Error Handling](#error-handling)
19+
- [License](#license)
20+
1121
## Installation
1222

1323
To install this library, just use `go get` command like the following line:
@@ -68,6 +78,16 @@ func TestExample(t *testing.T) {
6878
}
6979
```
7080

81+
Since v0.2.0, we also provided some assertions for array/slice, for example, you can use `ContainsElement` to check whether an array or a slice contains a specified element.
82+
83+
```go
84+
func TestExample(t *testing.T) {
85+
arr := []int{1, 2, 3}
86+
assert.ContainsElement(arr, 1) // success
87+
assert.ContainsElement(arr, 4) // fail
88+
}
89+
```
90+
7191
It also provided assertion functions to verify a function will panic or not:
7292

7393
```go
@@ -133,29 +153,56 @@ func TestExample(t *testing.T) {
133153
### Equality
134154

135155
- [`DeepEqual`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.DeepEqual) and [`NotDeepEqual`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotDeepEqual): assert the deep equality or inequality.
156+
157+
> Since v0.1.0
158+
136159
- [`Equal`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.Equal) and [`NotEqual`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotEqual): assert the equality or inequality.
137160

161+
> Since v0.1.5
162+
138163
### Value
139164

140165
- [`Nil`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.Nil) and [`NotNil`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotNil): assert the value is nil or not.
166+
167+
> Since v0.1.1
168+
141169
- [`True`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.True) and [`NotTrue`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotTrue): assert the truthy of the value.
142170

171+
> Since v0.1.4
172+
143173
### String
144174

145175
- [`ContainsString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.ContainsString) and [`NotContainsString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotContainsString): assert whether the string contains the substring or not.
176+
177+
> Since v0.1.7
178+
146179
- [`HasPrefixString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.HasPrefixString) and [`NotHasPrefixString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotHasPrefixString): assert whether the string have the prefix string or not.
180+
181+
> Since v0.1.7
182+
147183
- [`HasSuffixString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.HasSuffixString) and [`NotHasSuffixString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotHasSuffixString): assert whether the string have the suffix string or not.
184+
185+
> Since v0.1.7
186+
148187
- [`Match`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.Match) and [`NotMatch`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotMatch): assert whether the string matches the regular expression pattern or not.
188+
189+
> Since v0.1.5
190+
149191
- [`MatchString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.MatchString) and [`NotMatchString`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotMatchString): compile the regular expression pattern and assert whether the string matches the pattern or not.
150192

193+
> Since v0.1.5
194+
151195
### Slice or Array
152196

153197
- [`ContainsElement`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.ContainsElement) and [`NotContainsElement`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotContainsElement): assert whether the array or slice contains the specified element or not.
154198

199+
> Since v0.2.0
200+
155201
### Error Handling
156202

157203
- [`Panic`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.Panic) and [`NotPanic`](https://pkg.go.dev/github.com/ghosind/go-assert#Assertion.NotPanic): assert the function will panic or not.
158204

205+
> Since v0.1.0
159206
160207
## License
161208

0 commit comments

Comments
 (0)