File: arguments_test.go

package info (click to toggle)
golang-bugst-f 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 108 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 623 bytes parent folder | download
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
package f_test

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"

	f "go.bug.st/f"
)

func TestMust(t *testing.T) {
	t.Run("no error", func(t *testing.T) {
		assert.Equal(t, 12, f.Must(12, nil))
	})

	t.Run("error", func(t *testing.T) {
		want := fmt.Errorf("this is an error")
		assert.PanicsWithValue(t, want.Error(), func() {
			f.Must(0, want)
		})
	})
}

func TestAssert(t *testing.T) {
	t.Run("true", func(_ *testing.T) {
		f.Assert(true, "should not panic")
	})

	t.Run("false", func(t *testing.T) {
		assert.PanicsWithValue(t, "should panic", func() {
			f.Assert(false, "should panic")
		})
	})
}