Skip to content

Commit

Permalink
Added test code
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Jul 23, 2021
1 parent c5a77e9 commit 5044460
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkg/gee/print_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
}
75 changes: 75 additions & 0 deletions pkg/gee/regex_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
124 changes: 124 additions & 0 deletions pkg/gee/string_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}
22 changes: 22 additions & 0 deletions pkg/gee/time_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}

0 comments on commit 5044460

Please sign in to comment.