-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |