Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: show ExampleB3 in readme #9

Merged
merged 1 commit into from
Dec 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ Functions like `True(bool)` and friends. To assert a condition or panic.
`B1`, `B2`... are generic assertions that pass their first inputs unmodified with compile time type info preserved.
They return a function to specify what assertions are made on each field.

``` go
func ExampleB3() {
// lets say we have an io.RuneReader
readRune := func() (r rune, size int, err error) {
return 'a', 1, nil
}

// that must return 1 byte runes and never err out
char, _, _ := must.B3(readRune())(must.Any, 1, nil)
fmt.Println(string(char))

// output:
// a
}
```

Assertions have optional debug arguments, to provide additional information when
violated. Usually, just pass in the line comment as string.

Expand Down