File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed
Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ local Case = Group:extend("LeetCase")
2222
2323--- @private
2424--- @param input string[]
25- function Case :input (input ) return Input (" Input" , input , self .question .q .meta_data .params ) end
25+ function Case :input (input )
26+ input = vim .tbl_map (utils .norm_ins , input )
27+ return Input (" Input" , input , self .question .q .meta_data .params )
28+ end
2629
2730--- @private
2831--- @param output string
@@ -31,7 +34,7 @@ function Case:output(output, expected)
3134 local key = t (" Output" )
3235
3336 local title = Line ():append (key , " leetcode_normal" )
34- local pre = Pre (title , Line ():append (output ))
37+ local pre = Pre (title , Line ():append (utils . norm_ins ( output ) ))
3538
3639 return pre
3740end
@@ -43,7 +46,7 @@ function Case:expected(expected, output)
4346 local key = t (" Expected" )
4447 local title = Line ():append (key , " leetcode_normal" )
4548
46- local pre = Pre (title , Line ():append (expected ))
49+ local pre = Pre (title , Line ():append (utils . norm_ins ( expected ) ))
4750
4851 return pre
4952end
Original file line number Diff line number Diff line change @@ -2,16 +2,13 @@ local Pre = require("leetcode-ui.group.pre")
22local t = require (" leetcode.translator" )
33local Line = require (" leetcode-ui.line" )
44local Lines = require (" leetcode-ui.lines" )
5+
6+ local utils = require (" leetcode.utils" )
57local log = require (" leetcode.logger" )
68
79--- @class lc.ui.Stdout : lc.ui.Pre
810local Stdout = Pre :extend (" LeetStdout" )
911
10- local function norm (str )
11- local ins = vim .inspect (str )
12- return ins :sub (2 , # ins - 1 )
13- end
14-
1512--- @param output string
1613---
1714--- @return lc.ui.Lines | nil
@@ -25,7 +22,7 @@ function Stdout:init(output)
2522
2623 local lines = Lines ()
2724 for i = 1 , # output_list do
28- lines :append (norm (output_list [i ])):endl ()
25+ lines :append (utils . norm_ins (output_list [i ])):endl ()
2926 end
3027
3128 local title = Line ():append ((" %s" ):format (t (" Stdout" )), " leetcode_alt" )
Original file line number Diff line number Diff line change 9898
9999function utils .auth_guard () assert (config .auth .is_signed_in , " User not logged-in" ) end
100100
101+ function utils .norm_ins (str )
102+ local ins = vim .inspect (str )
103+ return ins :sub (2 , # ins - 1 )
104+ end
105+
101106return utils
You can’t perform that action at this time.
0 commit comments