diff --git a/draw_test.go b/draw_test.go index 87865de..c667af0 100644 --- a/draw_test.go +++ b/draw_test.go @@ -6,7 +6,7 @@ "unicode/utf8" ) -func TestDraw(t *testing.T) { +func TestDrawDefault(t *testing.T) { // key is termWidth testSuite := map[int][]struct { style BarStyleComposer @@ -20,12 +20,14 @@ }{ 0: { { + style: BarStyle(), name: "t,c{60,20}", total: 60, current: 20, want: "", }, { + style: BarStyle(), name: "t,c{60,20}trim", total: 60, current: 20, @@ -35,12 +37,14 @@ }, 1: { { + style: BarStyle(), name: "t,c{60,20}", total: 60, current: 20, want: "", }, { + style: BarStyle(), name: "t,c{60,20}trim", total: 60, current: 20, @@ -50,12 +54,14 @@ }, 2: { { + style: BarStyle(), name: "t,c{60,20}", total: 60, current: 20, want: " ", }, { + style: BarStyle(), name: "t,c{60,20}trim", total: 60, current: 20, @@ -65,222 +71,476 @@ }, 3: { { + style: BarStyle(), name: "t,c{60,20}", total: 60, current: 20, want: " ", }, { - name: "t,c{60,20}trim", - total: 60, - current: 20, + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[-]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " ", + }, + { + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, trim: true, want: "[>]", }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[=]", + }, }, 4: { { + style: BarStyle(), name: "t,c{60,20}", total: 60, current: 20, want: " [] ", }, { - name: "t,c{60,20}trim", - total: 60, - current: 20, + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[>-]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [] ", + }, + { + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, trim: true, want: "[=>]", }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[==]", + }, }, 5: { { - name: "t,c{60,20}", - total: 60, - current: 20, + style: BarStyle(), + name: "t,c{60,20}", + total: 60, + current: 20, + want: " [-] ", + }, + { + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[>--]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, want: " [>] ", }, { - name: "t,c{60,20}trim", - total: 60, - current: 20, - trim: true, - want: "[=>-]", + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[==>]", + }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [=] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[===]", }, }, 6: { { - name: "t,c{60,20}", - total: 60, - current: 20, + style: BarStyle(), + name: "t,c{60,20}", + total: 60, + current: 20, + want: " [>-] ", + }, + { + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[>---]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, want: " [=>] ", }, { - name: "t,c{60,20}trim", - total: 60, - current: 20, - trim: true, - want: "[=>--]", + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[===>]", + }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [==] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[====]", }, }, 7: { { - name: "t,c{60,20}", - total: 60, - current: 20, - want: " [=>-] ", - }, - { - name: "t,c{60,20}trim", - total: 60, - current: 20, - trim: true, - want: "[==>--]", + style: BarStyle(), + name: "t,c{60,20}", + total: 60, + current: 20, + want: " [>--] ", + }, + { + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[=>---]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [==>] ", + }, + { + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[====>]", + }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [===] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[=====]", }, }, 8: { { - name: "t,c{60,20}", - total: 60, - current: 20, - want: " [=>--] ", - }, - { - name: "t,c{60,20}trim", - total: 60, - current: 20, - trim: true, - want: "[==>---]", + style: BarStyle(), + name: "t,c{60,20}", + total: 60, + current: 20, + want: " [>---] ", + }, + { + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[=>----]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [===>] ", + }, + { + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[=====>]", + }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [====] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[======]", }, }, 80: { { - name: "t,c{60,20}", - total: 60, - current: 20, - want: " [=========================>--------------------------------------------------] ", - }, - { - name: "t,c{60,20}trim", - total: 60, - current: 20, - trim: true, - want: "[==========================>---------------------------------------------------]", - }, - { + style: BarStyle(), + name: "t,c{60,20}", + total: 60, + current: 20, + want: " [========================>---------------------------------------------------] ", + }, + { + style: BarStyle(), + name: "t,c{60,20}trim", + total: 60, + current: 20, + trim: true, + want: "[=========================>----------------------------------------------------]", + }, + { + style: BarStyle(), name: "t,c,bw{60,20,60}", total: 60, current: 20, barWidth: 60, - want: " [===================>--------------------------------------] ", - }, - { + want: " [==================>---------------------------------------] ", + }, + { + style: BarStyle(), name: "t,c,bw{60,20,60}trim", total: 60, current: 20, barWidth: 60, trim: true, - want: "[===================>--------------------------------------]", + want: "[==================>---------------------------------------]", + }, + { + style: BarStyle(), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [==========================================================================>-] ", + }, + { + style: BarStyle(), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[============================================================================>-]", + }, + { + style: BarStyle(), + name: "t,c,bw{60,59,60}", + total: 60, + current: 59, + barWidth: 60, + want: " [========================================================>-] ", + }, + { + style: BarStyle(), + name: "t,c,bw{60,59,60}trim", + total: 60, + current: 59, + barWidth: 60, + trim: true, + want: "[========================================================>-]", + }, + { + style: BarStyle(), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [============================================================================] ", + }, + { + style: BarStyle(), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[==============================================================================]", + }, + { + style: BarStyle(), + name: "t,c,bw{60,60,60}", + total: 60, + current: 60, + barWidth: 60, + want: " [==========================================================] ", + }, + { + style: BarStyle(), + name: "t,c,bw{60,60,60}trim", + total: 60, + current: 60, + barWidth: 60, + trim: true, + want: "[==========================================================]", }, }, 99: { { style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,1}", - total: 99, + name: `t,c{100,1}Tip("だ")`, + total: 100, current: 1, want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", }, { style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,2}", - total: 99, + name: `t,c{100,2}Tip("だ")`, + total: 100, current: 2, - want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", + want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", }, { style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,3}", - total: 99, - current: 3, - want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", + name: `t,c{100,99}Tip("だ")`, + total: 100, + current: 99, + want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", }, { style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,4}", - total: 99, - current: 4, - want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,5}", - total: 99, - current: 5, - want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,6}", - total: 99, - current: 6, - want: " [のののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", + name: `t,c{100,100}Tip("だ")`, + total: 100, + current: 100, + want: " [ののののののののののののののののののののののののののののののののののののののののののののののの…] ", }, { style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]").Reverse(), - name: "[のだつ] t,c{99,6}rev", - total: 99, - current: 6, - want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだののの] ", + name: `t,c{100,100}Tip("だ")rev`, + total: 100, + current: 100, + want: " […ののののののののののののののののののののののののののののののののののののののののののののののの] ", }, }, 100: { { + style: BarStyle(), name: "t,c{100,0}", total: 100, current: 0, + want: " [------------------------------------------------------------------------------------------------] ", + }, + { + style: BarStyle(), + name: "t,c{100,0}trim", + total: 100, + current: 0, + trim: true, + want: "[--------------------------------------------------------------------------------------------------]", + }, + { + style: BarStyle(), + name: "t,c{100,1}", + total: 100, + current: 1, want: " [>-----------------------------------------------------------------------------------------------] ", }, { - name: "t,c{100,0}trim", - total: 100, - current: 0, + style: BarStyle(), + name: "t,c{100,1}trim", + total: 100, + current: 1, trim: true, want: "[>-------------------------------------------------------------------------------------------------]", }, { - name: "t,c{100,1}", - total: 100, - current: 1, - want: " [=>----------------------------------------------------------------------------------------------] ", - }, - { - name: "t,c{100,1}trim", - total: 100, - current: 1, - trim: true, - want: "[=>------------------------------------------------------------------------------------------------]", - }, - { + style: BarStyle(), name: "t,c{100,99}", total: 100, current: 99, - want: " [===============================================================================================>] ", - }, - { + want: " [==============================================================================================>-] ", + }, + { + style: BarStyle(), name: "t,c{100,99}trim", total: 100, current: 99, trim: true, - want: "[=================================================================================================>]", - }, - { + want: "[================================================================================================>-]", + }, + { + style: BarStyle(), name: "t,c{100,100}", total: 100, current: 100, want: " [================================================================================================] ", }, { + style: BarStyle(), name: "t,c{100,100}trim", total: 100, current: 100, @@ -288,6 +548,32 @@ want: "[==================================================================================================]", }, { + style: BarStyle(), + name: "t,c,r{100,100,99}", + total: 100, + current: 100, + refill: 99, + want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=] ", + }, + { + style: BarStyle(), + name: "t,c,r{100,100,99}trim", + total: 100, + current: 100, + refill: 99, + trim: true, + want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=]", + }, + { + style: BarStyle(), + name: "t,c,r{100,100,100}", + total: 100, + current: 100, + refill: 100, + want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", + }, + { + style: BarStyle(), name: "t,c,r{100,100,100}trim", total: 100, current: 100, @@ -296,64 +582,55 @@ want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", }, { - name: "t,c{100,33}", - total: 100, - current: 33, - want: " [================================>---------------------------------------------------------------] ", - }, - { - name: "t,c{100,33}trim", - total: 100, - current: 33, - trim: true, - want: "[================================>-----------------------------------------------------------------]", - }, - { - style: BarStyle().Tip("<").Reverse(), - name: "t,c{100,33}trim,rev", - total: 100, - current: 33, - trim: true, - want: "[-----------------------------------------------------------------<================================]", - }, - { - name: "t,c,r{100,33,33}", - total: 100, - current: 33, - refill: 33, - want: " [++++++++++++++++++++++++++++++++>---------------------------------------------------------------] ", - }, - { - name: "t,c,r{100,33,33}trim", - total: 100, - current: 33, - refill: 33, - trim: true, - want: "[++++++++++++++++++++++++++++++++>-----------------------------------------------------------------]", - }, - { - style: BarStyle().Tip("<").Reverse(), - name: "t,c,r{100,33,33}trim,rev", - total: 100, - current: 33, - refill: 33, - trim: true, - want: "[-----------------------------------------------------------------<++++++++++++++++++++++++++++++++]", - }, - { + style: BarStyle().Tip("", "<").Reverse(), + name: "t,c,r{100,100,99}rev", + total: 100, + current: 100, + refill: 99, + want: " [=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", + }, + { + style: BarStyle().Tip("", "<").Reverse(), + name: "t,c,r{100,100,99}trim,rev", + total: 100, + current: 100, + refill: 99, + trim: true, + want: "[=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", + }, + { + style: BarStyle().Tip("", "<").Reverse(), + name: "t,c,r{100,100,100}rev", + total: 100, + current: 100, + refill: 100, + want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", + }, + { + style: BarStyle().Tip("", "<").Reverse(), + name: "t,c,r{100,100,100}trim", + total: 100, + current: 100, + refill: 100, + trim: true, + want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", + }, + { + style: BarStyle(), name: "t,c,r{100,40,33}", total: 100, current: 40, refill: 33, - want: " [++++++++++++++++++++++++++++++++======>---------------------------------------------------------] ", - }, - { + want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ", + }, + { + style: BarStyle(), name: "t,c,r{100,40,33}trim", total: 100, current: 40, refill: 33, trim: true, - want: "[++++++++++++++++++++++++++++++++=======>----------------------------------------------------------]", + want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]", }, { style: BarStyle().Tip("<").Reverse(), @@ -361,7 +638,7 @@ total: 100, current: 40, refill: 33, - want: " [---------------------------------------------------------<======++++++++++++++++++++++++++++++++] ", + want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ", }, { style: BarStyle().Tip("<").Reverse(), @@ -370,7 +647,7 @@ current: 40, refill: 33, trim: true, - want: "[----------------------------------------------------------<=======++++++++++++++++++++++++++++++++]", + want: "[-----------------------------------------------------------<======++++++++++++++++++++++++++++++++]", }, }, } @@ -378,9 +655,6 @@ var tmpBuf bytes.Buffer for tw, cases := range testSuite { for _, tc := range cases { - if tc.style == nil { - tc.style = BarStyle() - } s := newTestState(NewBarFiller(tc.style)) s.reqWidth = tc.barWidth s.total = tc.total @@ -402,7 +676,7 @@ } } -func TestDrawTipInclusive(t *testing.T) { +func TestDrawTipOnComplete(t *testing.T) { // key is termWidth testSuite := map[int][]struct { style BarStyleComposer @@ -416,12 +690,14 @@ }{ 0: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: "", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, @@ -431,12 +707,14 @@ }, 1: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: "", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, @@ -446,12 +724,14 @@ }, 2: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, @@ -461,102 +741,296 @@ }, 3: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[-]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[>]", + }, }, 4: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[>-]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[=>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[=>]", + }, }, 5: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [-] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[>--]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[==>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[==>]", + }, }, 6: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [>-] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[>---]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [=>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[===>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [=>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[===>]", + }, }, 7: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [>--] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[=>---]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [==>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[====>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [==>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[====>]", + }, }, 8: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [>---] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, trim: true, want: "[=>----]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [===>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[=====>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [===>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[=====>]", + }, }, 80: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}", total: 60, current: 20, want: " [========================>---------------------------------------------------] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{60,20}trim", total: 60, current: 20, @@ -564,6 +1038,7 @@ want: "[=========================>----------------------------------------------------]", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c,bw{60,20,60}", total: 60, current: 20, @@ -571,6 +1046,7 @@ want: " [==================>---------------------------------------] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c,bw{60,20,60}trim", total: 60, current: 20, @@ -578,66 +1054,104 @@ trim: true, want: "[==================>---------------------------------------]", }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}", + total: 60, + current: 59, + want: " [==========================================================================>-] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,59}trim", + total: 60, + current: 59, + trim: true, + want: "[============================================================================>-]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,bw{60,59,60}", + total: 60, + current: 59, + barWidth: 60, + want: " [========================================================>-] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,bw{60,59,60}trim", + total: 60, + current: 59, + barWidth: 60, + trim: true, + want: "[========================================================>-]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}", + total: 60, + current: 60, + want: " [===========================================================================>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c{60,60}trim", + total: 60, + current: 60, + trim: true, + want: "[=============================================================================>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,bw{60,60,60}", + total: 60, + current: 60, + barWidth: 60, + want: " [=========================================================>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,bw{60,60,60}trim", + total: 60, + current: 60, + barWidth: 60, + trim: true, + want: "[=========================================================>]", + }, }, 99: { { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,1}", - total: 99, - current: 1, - want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,2}", - total: 99, - current: 2, - want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,3}", - total: 99, - current: 3, - want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,4}", - total: 99, - current: 4, - want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,5}", - total: 99, - current: 5, - want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), - name: "[のだつ] t,c{99,6}", - total: 99, - current: 6, - want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", - }, - { - style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]").Reverse(), - name: "[のだつ] t,c{99,6}rev", - total: 99, - current: 6, - want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだのの] ", + style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]"), + name: `t,c{100,99}Tip("だ").TipOnComplete("だ")`, + total: 100, + current: 99, + want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", + }, + { + style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]"), + name: `t,c{100,100}Tip("だ").TipOnComplete("だ")`, + total: 100, + current: 100, + want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", + }, + { + style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]").Reverse(), + name: `t,c{100,100}Tip("だ").TipOnComplete("だ")rev`, + total: 100, + current: 100, + want: " […だのののののののののののののののののののののののののののののののののののののののののののののの] ", }, }, 100: { { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,0}", total: 100, current: 0, want: " [------------------------------------------------------------------------------------------------] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,0}trim", total: 100, current: 0, @@ -645,12 +1159,14 @@ want: "[--------------------------------------------------------------------------------------------------]", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,1}", total: 100, current: 1, want: " [>-----------------------------------------------------------------------------------------------] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,1}trim", total: 100, current: 1, @@ -658,12 +1174,14 @@ want: "[>-------------------------------------------------------------------------------------------------]", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,99}", total: 100, current: 99, want: " [==============================================================================================>-] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,99}trim", total: 100, current: 99, @@ -671,12 +1189,14 @@ want: "[================================================================================================>-]", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,100}", total: 100, current: 100, want: " [===============================================================================================>] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c{100,100}trim", total: 100, current: 100, @@ -684,6 +1204,32 @@ want: "[=================================================================================================>]", }, { + style: BarStyle().TipOnComplete(">"), + name: "t,c,r{100,100,99}", + total: 100, + current: 100, + refill: 99, + want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>] ", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,r{100,100,99}trim", + total: 100, + current: 100, + refill: 99, + trim: true, + want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>]", + }, + { + style: BarStyle().TipOnComplete(">"), + name: "t,c,r{100,100,100}", + total: 100, + current: 100, + refill: 100, + want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>] ", + }, + { + style: BarStyle().TipOnComplete(">"), name: "t,c,r{100,100,100}trim", total: 100, current: 100, @@ -692,51 +1238,41 @@ want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>]", }, { - name: "t,c{100,33}", - total: 100, - current: 33, - want: " [===============================>----------------------------------------------------------------] ", - }, - { - name: "t,c{100,33}trim", - total: 100, - current: 33, - trim: true, - want: "[===============================>------------------------------------------------------------------]", - }, - { - style: BarStyle().Tip("<").Reverse(), - name: "t,c{100,33}trim,rev", - total: 100, - current: 33, - trim: true, - want: "[------------------------------------------------------------------<===============================]", - }, - { - name: "t,c,r{100,33,33}", - total: 100, - current: 33, - refill: 33, - want: " [+++++++++++++++++++++++++++++++>----------------------------------------------------------------] ", - }, - { - name: "t,c,r{100,33,33}trim", - total: 100, - current: 33, - refill: 33, - trim: true, - want: "[+++++++++++++++++++++++++++++++>------------------------------------------------------------------]", - }, - { - style: BarStyle().Tip("<").Reverse(), - name: "t,c,r{100,33,33}trim,rev", - total: 100, - current: 33, - refill: 33, - trim: true, - want: "[------------------------------------------------------------------<+++++++++++++++++++++++++++++++]", - }, - { + style: BarStyle().TipOnComplete("").Reverse(), + name: "t,c,r{100,100,99}rev", + total: 100, + current: 100, + refill: 99, + want: " [=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", + }, + { + style: BarStyle().TipOnComplete("").Reverse(), + name: "t,c,r{100,100,99}trim,rev", + total: 100, + current: 100, + refill: 99, + trim: true, + want: "[=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", + }, + { + style: BarStyle().TipOnComplete("").Reverse(), + name: "t,c,r{100,100,100}rev", + total: 100, + current: 100, + refill: 100, + want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", + }, + { + style: BarStyle().TipOnComplete("").Reverse(), + name: "t,c,r{100,100,100}trim", + total: 100, + current: 100, + refill: 100, + trim: true, + want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", + }, + { + style: BarStyle().TipOnComplete(">"), name: "t,c,r{100,40,33}", total: 100, current: 40, @@ -744,6 +1280,7 @@ want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ", }, { + style: BarStyle().TipOnComplete(">"), name: "t,c,r{100,40,33}trim", total: 100, current: 40, @@ -752,7 +1289,7 @@ want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]", }, { - style: BarStyle().Tip("<").Reverse(), + style: BarStyle().Tip("<").TipOnComplete("<").Reverse(), name: "t,c,r{100,40,33},rev", total: 100, current: 40, @@ -760,7 +1297,7 @@ want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ", }, { - style: BarStyle().Tip("<").Reverse(), + style: BarStyle().Tip("<").TipOnComplete("<").Reverse(), name: "t,c,r{100,40,33}trim,rev", total: 100, current: 40, @@ -774,10 +1311,7 @@ var tmpBuf bytes.Buffer for tw, cases := range testSuite { for _, tc := range cases { - if tc.style == nil { - tc.style = BarStyle() - } - s := newTestState(NewBarFiller(tc.style.Inclusive(0))) + s := newTestState(NewBarFiller(tc.style)) s.reqWidth = tc.barWidth s.total = tc.total s.current = tc.current