-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharguments_test.go
More file actions
43 lines (35 loc) · 861 Bytes
/
arguments_test.go
File metadata and controls
43 lines (35 loc) · 861 Bytes
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
40
41
42
43
//
// This file is part of go-algorithms.
//
// Copyright (c) 2024-2026 go-algorithms (go.bug.st/f) authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
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")
})
})
}