aboutsummaryrefslogtreecommitdiffhomepage
path: root/helper/args_test.go
blob: 378c6dccbdd4b763746a1068cb85e5109abcd3dc (plain)
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
package helper_test

import (
	"errors"
	"fmt"
	"strings"
	"testing"

	"git.ophivana.moe/cat/fortify/helper"
)

func Test_argsFD_String(t *testing.T) {
	argsOnce.Do(prepareArgs)

	wantString := strings.Join(want, " ")
	if got := argsWt.(fmt.Stringer).String(); got != wantString {
		t.Errorf("String(): got %v; want %v",
			got, wantString)
	}
}

func TestNewCheckedArgs(t *testing.T) {
	args := []string{"\x00"}
	if _, err := helper.NewCheckedArgs(args); !errors.Is(err, helper.ErrContainsNull) {
		t.Errorf("NewCheckedArgs(%q) error = %v, wantErr %v",
			args,
			err, helper.ErrContainsNull)
	}
}