diff --git a/pkg/gee/print_test.go b/pkg/gee/print_test.go new file mode 100644 index 0000000..2e8ae33 --- /dev/null +++ b/pkg/gee/print_test.go @@ -0,0 +1,42 @@ +package gee + +import ( + "testing" + + model "github.com/hahwul/gee/pkg/model" +) + +func TestStdPrint(t *testing.T) { + type args struct { + line string + options model.Options + } + tests := []struct { + name string + args args + }{ + { + name: "test", + args: args{ + line: "", + options: model.Options{ + RemoveNewLine: true, + }, + }, + }, + { + name: "test", + args: args{ + line: "", + options: model.Options{ + RemoveNewLine: false, + }, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + StdPrint(tt.args.line, tt.args.options) + }) + } +} diff --git a/pkg/gee/regex_test.go b/pkg/gee/regex_test.go new file mode 100644 index 0000000..7ec56ac --- /dev/null +++ b/pkg/gee/regex_test.go @@ -0,0 +1,75 @@ +package gee + +import "testing" + +func TestRegex(t *testing.T) { + type args struct { + pattern string + str string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "test - true", + args: args{ + pattern: "abcd", + str: "123abcd444", + }, + want: true, + }, + { + name: "test - false", + args: args{ + pattern: "abcd", + str: "123d444", + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := Regex(tt.args.pattern, tt.args.str); got != tt.want { + t.Errorf("Regex() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestRegexV(t *testing.T) { + type args struct { + pattern string + str string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "test - true", + args: args{ + pattern: "abcd", + str: "123d444", + }, + want: true, + }, + { + name: "test - false", + args: args{ + pattern: "abcd", + str: "123abcd444", + }, + want: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := RegexV(tt.args.pattern, tt.args.str); got != tt.want { + t.Errorf("RegexV() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/gee/string_test.go b/pkg/gee/string_test.go new file mode 100644 index 0000000..b7c08c7 --- /dev/null +++ b/pkg/gee/string_test.go @@ -0,0 +1,124 @@ +package gee + +import ( + "testing" + + "github.com/hahwul/gee/pkg/model" +) + +func TestStringProc(t *testing.T) { + type args struct { + l string + stdLine int + options model.Options + } + tests := []struct { + name string + args args + want string + }{ + { + name: "test", + args: args{ + l: "a1234", + stdLine: 0, + options: model.Options{ + Find: "a", + Replace: "b", + Format: "", + WithLine: true, + }, + }, + want: "[0] b1234", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, _ = StringProc(tt.args.l, tt.args.stdLine, tt.args.options) + }) + } +} + +func Test_toFormat(t *testing.T) { + type args struct { + str string + options model.Options + } + tests := []struct { + name string + args args + want string + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := toFormat(tt.args.str, tt.args.options); got != tt.want { + t.Errorf("toFormat() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_setFix(t *testing.T) { + type args struct { + str string + options model.Options + } + tests := []struct { + name string + args args + want string + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := setFix(tt.args.str, tt.args.options); got != tt.want { + t.Errorf("setFix() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_setPrefix(t *testing.T) { + type args struct { + str string + options model.Options + } + tests := []struct { + name string + args args + want string + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := setPrefix(tt.args.str, tt.args.options); got != tt.want { + t.Errorf("setPrefix() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_setSuffix(t *testing.T) { + type args struct { + str string + options model.Options + } + tests := []struct { + name string + args args + want string + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := setSuffix(tt.args.str, tt.args.options); got != tt.want { + t.Errorf("setSuffix() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/gee/time_test.go b/pkg/gee/time_test.go new file mode 100644 index 0000000..f3dfbc0 --- /dev/null +++ b/pkg/gee/time_test.go @@ -0,0 +1,22 @@ +package gee + +import "testing" + +func TestGetNowTime(t *testing.T) { + tests := []struct { + name string + notwant int + }{ + { + name: "test", + notwant: 0, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := GetNowTime(); len(got) == tt.notwant { + t.Errorf("GetNowTime() = %v, want %v", len(got), tt.notwant) + } + }) + } +}