Skip to content

Commit

Permalink
(#30) Added logic and test code
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Jul 24, 2021
1 parent 53af315 commit a9d9b1f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/gee/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func StringProc(l string, stdLine int, options model.Options) (string, string) {
var returnString string
var returnPlainString string

if options.Reverse {
result = setReverse(result)
result = setReverse(resultPlain)
}

au := aurora.NewAurora(options.Color)
if options.Find != "" {
if options.Replace != "" {
Expand Down
61 changes: 60 additions & 1 deletion pkg/gee/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestStringProc(t *testing.T) {
want string
}{
{
name: "test",
name: "test1",
args: args{
l: "a1234",
stdLine: 0,
Expand All @@ -31,6 +31,65 @@ func TestStringProc(t *testing.T) {
},
want: "[0] b1234",
},
{
name: "test2",
args: args{
l: "a1234",
stdLine: 0,
options: model.Options{
Find: "a",
Format: "",
WithTimestamp: true,
Split: "1",
},
},
want: "[0] b1234",
},
{
name: "test3",
args: args{
l: "a1234",
stdLine: 0,
options: model.Options{
Format: "json",
},
},
want: "[0] b1234",
},
{
name: "test4",
args: args{
l: "a1234",
stdLine: 0,
options: model.Options{
Format: "md-table",
},
},
want: "[0] b1234",
},
{
name: "test4",
args: args{
l: "a1234",
stdLine: 0,
options: model.Options{
Format: "html-table",
},
},
want: "[0] b1234",
},
{
name: "test5",
args: args{
l: "abcd1234",
stdLine: 0,
options: model.Options{
Reverse: true,
Format: "",
},
},
want: "4321dcba",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit a9d9b1f

Please sign in to comment.