From a9d9b1fec87cc2a76fbd1d6a35760cfbabcf089b Mon Sep 17 00:00:00 2001 From: hahwul Date: Sun, 25 Jul 2021 00:28:35 +0900 Subject: [PATCH] (#30) Added logic and test code --- pkg/gee/string.go | 5 ++++ pkg/gee/string_test.go | 61 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/pkg/gee/string.go b/pkg/gee/string.go index 3ea770a..273661b 100644 --- a/pkg/gee/string.go +++ b/pkg/gee/string.go @@ -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 != "" { diff --git a/pkg/gee/string_test.go b/pkg/gee/string_test.go index c68a148..d980f7c 100644 --- a/pkg/gee/string_test.go +++ b/pkg/gee/string_test.go @@ -18,7 +18,7 @@ func TestStringProc(t *testing.T) { want string }{ { - name: "test", + name: "test1", args: args{ l: "a1234", stdLine: 0, @@ -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) {