| 74 | 74 |
total: 60,
|
| 75 | 75 |
current: 20,
|
| 76 | 76 |
trim: true,
|
| 77 | |
want: "[-]",
|
|
77 |
want: "[>]",
|
| 78 | 78 |
},
|
| 79 | 79 |
},
|
| 80 | 80 |
4: {
|
|
| 89 | 89 |
total: 60,
|
| 90 | 90 |
current: 20,
|
| 91 | 91 |
trim: true,
|
| 92 | |
want: "[>-]",
|
|
92 |
want: "[=>]",
|
| 93 | 93 |
},
|
| 94 | 94 |
},
|
| 95 | 95 |
5: {
|
|
| 97 | 97 |
name: "t,c{60,20}",
|
| 98 | 98 |
total: 60,
|
| 99 | 99 |
current: 20,
|
| 100 | |
want: " [-] ",
|
| 101 | |
},
|
| 102 | |
{
|
| 103 | |
name: "t,c{60,20}trim",
|
| 104 | |
total: 60,
|
| 105 | |
current: 20,
|
| 106 | |
trim: true,
|
| 107 | |
want: "[>--]",
|
|
100 |
want: " [>] ",
|
|
101 |
},
|
|
102 |
{
|
|
103 |
name: "t,c{60,20}trim",
|
|
104 |
total: 60,
|
|
105 |
current: 20,
|
|
106 |
trim: true,
|
|
107 |
want: "[=>-]",
|
| 108 | 108 |
},
|
| 109 | 109 |
},
|
| 110 | 110 |
6: {
|
|
| 112 | 112 |
name: "t,c{60,20}",
|
| 113 | 113 |
total: 60,
|
| 114 | 114 |
current: 20,
|
| 115 | |
want: " [>-] ",
|
| 116 | |
},
|
| 117 | |
{
|
| 118 | |
name: "t,c{60,20}trim",
|
| 119 | |
total: 60,
|
| 120 | |
current: 20,
|
| 121 | |
trim: true,
|
| 122 | |
want: "[>---]",
|
|
115 |
want: " [=>] ",
|
|
116 |
},
|
|
117 |
{
|
|
118 |
name: "t,c{60,20}trim",
|
|
119 |
total: 60,
|
|
120 |
current: 20,
|
|
121 |
trim: true,
|
|
122 |
want: "[=>--]",
|
| 123 | 123 |
},
|
| 124 | 124 |
},
|
| 125 | 125 |
7: {
|
|
| 127 | 127 |
name: "t,c{60,20}",
|
| 128 | 128 |
total: 60,
|
| 129 | 129 |
current: 20,
|
| 130 | |
want: " [>--] ",
|
| 131 | |
},
|
| 132 | |
{
|
| 133 | |
name: "t,c{60,20}trim",
|
| 134 | |
total: 60,
|
| 135 | |
current: 20,
|
| 136 | |
trim: true,
|
| 137 | |
want: "[=>---]",
|
|
130 |
want: " [=>-] ",
|
|
131 |
},
|
|
132 |
{
|
|
133 |
name: "t,c{60,20}trim",
|
|
134 |
total: 60,
|
|
135 |
current: 20,
|
|
136 |
trim: true,
|
|
137 |
want: "[==>--]",
|
| 138 | 138 |
},
|
| 139 | 139 |
},
|
| 140 | 140 |
8: {
|
|
| 142 | 142 |
name: "t,c{60,20}",
|
| 143 | 143 |
total: 60,
|
| 144 | 144 |
current: 20,
|
| 145 | |
want: " [>---] ",
|
| 146 | |
},
|
| 147 | |
{
|
| 148 | |
name: "t,c{60,20}trim",
|
| 149 | |
total: 60,
|
| 150 | |
current: 20,
|
| 151 | |
trim: true,
|
| 152 | |
want: "[=>----]",
|
|
145 |
want: " [=>--] ",
|
|
146 |
},
|
|
147 |
{
|
|
148 |
name: "t,c{60,20}trim",
|
|
149 |
total: 60,
|
|
150 |
current: 20,
|
|
151 |
trim: true,
|
|
152 |
want: "[==>---]",
|
| 153 | 153 |
},
|
| 154 | 154 |
},
|
| 155 | 155 |
80: {
|
|
| 157 | 157 |
name: "t,c{60,20}",
|
| 158 | 158 |
total: 60,
|
| 159 | 159 |
current: 20,
|
| 160 | |
want: " [========================>---------------------------------------------------] ",
|
| 161 | |
},
|
| 162 | |
{
|
| 163 | |
name: "t,c{60,20}trim",
|
| 164 | |
total: 60,
|
| 165 | |
current: 20,
|
| 166 | |
trim: true,
|
| 167 | |
want: "[=========================>----------------------------------------------------]",
|
|
160 |
want: " [=========================>--------------------------------------------------] ",
|
|
161 |
},
|
|
162 |
{
|
|
163 |
name: "t,c{60,20}trim",
|
|
164 |
total: 60,
|
|
165 |
current: 20,
|
|
166 |
trim: true,
|
|
167 |
want: "[==========================>---------------------------------------------------]",
|
| 168 | 168 |
},
|
| 169 | 169 |
{
|
| 170 | 170 |
name: "t,c,bw{60,20,60}",
|
| 171 | 171 |
total: 60,
|
| 172 | 172 |
current: 20,
|
| 173 | 173 |
barWidth: 60,
|
| 174 | |
want: " [==================>---------------------------------------] ",
|
|
174 |
want: " [===================>--------------------------------------] ",
|
| 175 | 175 |
},
|
| 176 | 176 |
{
|
| 177 | 177 |
name: "t,c,bw{60,20,60}trim",
|
|
| 179 | 179 |
current: 20,
|
| 180 | 180 |
barWidth: 60,
|
| 181 | 181 |
trim: true,
|
| 182 | |
want: "[==================>---------------------------------------]",
|
|
182 |
want: "[===================>--------------------------------------]",
|
| 183 | 183 |
},
|
| 184 | 184 |
},
|
| 185 | 185 |
99: {
|
|
| 195 | 195 |
name: "[のだつ] t,c{99,2}",
|
| 196 | 196 |
total: 99,
|
| 197 | 197 |
current: 2,
|
| 198 | |
want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
198 |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
| 199 | 199 |
},
|
| 200 | 200 |
{
|
| 201 | 201 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
| 202 | 202 |
name: "[のだつ] t,c{99,3}",
|
| 203 | 203 |
total: 99,
|
| 204 | 204 |
current: 3,
|
| 205 | |
want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
205 |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
| 206 | 206 |
},
|
| 207 | 207 |
{
|
| 208 | 208 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
| 209 | 209 |
name: "[のだつ] t,c{99,4}",
|
| 210 | 210 |
total: 99,
|
| 211 | 211 |
current: 4,
|
| 212 | |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
212 |
want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
| 213 | 213 |
},
|
| 214 | 214 |
{
|
| 215 | 215 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
| 216 | 216 |
name: "[のだつ] t,c{99,5}",
|
| 217 | 217 |
total: 99,
|
| 218 | 218 |
current: 5,
|
| 219 | |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
219 |
want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
| 220 | 220 |
},
|
| 221 | 221 |
{
|
| 222 | 222 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
| 223 | 223 |
name: "[のだつ] t,c{99,6}",
|
| 224 | 224 |
total: 99,
|
| 225 | 225 |
current: 6,
|
| 226 | |
want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
226 |
want: " [のののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
| 227 | 227 |
},
|
| 228 | 228 |
{
|
| 229 | 229 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]").Reverse(),
|
| 230 | 230 |
name: "[のだつ] t,c{99,6}rev",
|
| 231 | 231 |
total: 99,
|
| 232 | 232 |
current: 6,
|
| 233 | |
want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだのの] ",
|
|
233 |
want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだののの] ",
|
| 234 | 234 |
},
|
| 235 | 235 |
},
|
| 236 | 236 |
100: {
|
|
| 238 | 238 |
name: "t,c{100,0}",
|
| 239 | 239 |
total: 100,
|
| 240 | 240 |
current: 0,
|
| 241 | |
want: " [------------------------------------------------------------------------------------------------] ",
|
|
241 |
want: " [>-----------------------------------------------------------------------------------------------] ",
|
| 242 | 242 |
},
|
| 243 | 243 |
{
|
| 244 | 244 |
name: "t,c{100,0}trim",
|
| 245 | 245 |
total: 100,
|
| 246 | 246 |
current: 0,
|
| 247 | 247 |
trim: true,
|
| 248 | |
want: "[--------------------------------------------------------------------------------------------------]",
|
|
248 |
want: "[>-------------------------------------------------------------------------------------------------]",
|
| 249 | 249 |
},
|
| 250 | 250 |
{
|
| 251 | 251 |
name: "t,c{100,1}",
|
| 252 | 252 |
total: 100,
|
| 253 | 253 |
current: 1,
|
| 254 | |
want: " [>-----------------------------------------------------------------------------------------------] ",
|
|
254 |
want: " [=>----------------------------------------------------------------------------------------------] ",
|
| 255 | 255 |
},
|
| 256 | 256 |
{
|
| 257 | 257 |
name: "t,c{100,1}trim",
|
| 258 | 258 |
total: 100,
|
| 259 | 259 |
current: 1,
|
| 260 | 260 |
trim: true,
|
| 261 | |
want: "[>-------------------------------------------------------------------------------------------------]",
|
|
261 |
want: "[=>------------------------------------------------------------------------------------------------]",
|
| 262 | 262 |
},
|
| 263 | 263 |
{
|
| 264 | 264 |
name: "t,c{100,99}",
|
| 265 | 265 |
total: 100,
|
| 266 | 266 |
current: 99,
|
| 267 | |
want: " [==============================================================================================>-] ",
|
|
267 |
want: " [===============================================================================================>] ",
|
| 268 | 268 |
},
|
| 269 | 269 |
{
|
| 270 | 270 |
name: "t,c{100,99}trim",
|
| 271 | 271 |
total: 100,
|
| 272 | 272 |
current: 99,
|
| 273 | 273 |
trim: true,
|
| 274 | |
want: "[================================================================================================>-]",
|
|
274 |
want: "[=================================================================================================>]",
|
| 275 | 275 |
},
|
| 276 | 276 |
{
|
| 277 | 277 |
name: "t,c{100,100}",
|
|
| 298 | 298 |
name: "t,c{100,33}",
|
| 299 | 299 |
total: 100,
|
| 300 | 300 |
current: 33,
|
| 301 | |
want: " [===============================>----------------------------------------------------------------] ",
|
|
301 |
want: " [================================>---------------------------------------------------------------] ",
|
| 302 | 302 |
},
|
| 303 | 303 |
{
|
| 304 | 304 |
name: "t,c{100,33}trim",
|
| 305 | 305 |
total: 100,
|
| 306 | 306 |
current: 33,
|
| 307 | 307 |
trim: true,
|
| 308 | |
want: "[===============================>------------------------------------------------------------------]",
|
|
308 |
want: "[================================>-----------------------------------------------------------------]",
|
| 309 | 309 |
},
|
| 310 | 310 |
{
|
| 311 | 311 |
style: BarStyle().Tip("<").Reverse(),
|
|
| 313 | 313 |
total: 100,
|
| 314 | 314 |
current: 33,
|
| 315 | 315 |
trim: true,
|
| 316 | |
want: "[------------------------------------------------------------------<===============================]",
|
|
316 |
want: "[-----------------------------------------------------------------<================================]",
|
| 317 | 317 |
},
|
| 318 | 318 |
{
|
| 319 | 319 |
name: "t,c,r{100,33,33}",
|
| 320 | 320 |
total: 100,
|
| 321 | 321 |
current: 33,
|
| 322 | 322 |
refill: 33,
|
| 323 | |
want: " [+++++++++++++++++++++++++++++++>----------------------------------------------------------------] ",
|
|
323 |
want: " [++++++++++++++++++++++++++++++++>---------------------------------------------------------------] ",
|
| 324 | 324 |
},
|
| 325 | 325 |
{
|
| 326 | 326 |
name: "t,c,r{100,33,33}trim",
|
|
| 328 | 328 |
current: 33,
|
| 329 | 329 |
refill: 33,
|
| 330 | 330 |
trim: true,
|
| 331 | |
want: "[+++++++++++++++++++++++++++++++>------------------------------------------------------------------]",
|
|
331 |
want: "[++++++++++++++++++++++++++++++++>-----------------------------------------------------------------]",
|
| 332 | 332 |
},
|
| 333 | 333 |
{
|
| 334 | 334 |
style: BarStyle().Tip("<").Reverse(),
|
|
| 337 | 337 |
current: 33,
|
| 338 | 338 |
refill: 33,
|
| 339 | 339 |
trim: true,
|
| 340 | |
want: "[------------------------------------------------------------------<+++++++++++++++++++++++++++++++]",
|
|
340 |
want: "[-----------------------------------------------------------------<++++++++++++++++++++++++++++++++]",
|
| 341 | 341 |
},
|
| 342 | 342 |
{
|
| 343 | 343 |
name: "t,c,r{100,40,33}",
|
| 344 | 344 |
total: 100,
|
| 345 | 345 |
current: 40,
|
| 346 | 346 |
refill: 33,
|
| 347 | |
want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ",
|
|
347 |
want: " [++++++++++++++++++++++++++++++++======>---------------------------------------------------------] ",
|
| 348 | 348 |
},
|
| 349 | 349 |
{
|
| 350 | 350 |
name: "t,c,r{100,40,33}trim",
|
|
| 352 | 352 |
current: 40,
|
| 353 | 353 |
refill: 33,
|
| 354 | 354 |
trim: true,
|
| 355 | |
want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]",
|
|
355 |
want: "[++++++++++++++++++++++++++++++++=======>----------------------------------------------------------]",
|
| 356 | 356 |
},
|
| 357 | 357 |
{
|
| 358 | 358 |
style: BarStyle().Tip("<").Reverse(),
|
|
| 360 | 360 |
total: 100,
|
| 361 | 361 |
current: 40,
|
| 362 | 362 |
refill: 33,
|
| 363 | |
want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ",
|
|
363 |
want: " [---------------------------------------------------------<======++++++++++++++++++++++++++++++++] ",
|
| 364 | 364 |
},
|
| 365 | 365 |
{
|
| 366 | 366 |
style: BarStyle().Tip("<").Reverse(),
|
|
| 369 | 369 |
current: 40,
|
| 370 | 370 |
refill: 33,
|
| 371 | 371 |
trim: true,
|
| 372 | |
want: "[-----------------------------------------------------------<======++++++++++++++++++++++++++++++++]",
|
| 373 | |
},
|
| 374 | |
},
|
| 375 | |
197: {
|
| 376 | |
{
|
| 377 | |
name: "t,c,r{97486999,2805950,2805483}trim",
|
| 378 | |
total: 97486999,
|
| 379 | |
current: 2805950,
|
| 380 | |
refill: 2805483,
|
| 381 | |
barWidth: 60,
|
| 382 | |
trim: true,
|
| 383 | |
want: "[+>--------------------------------------------------------]",
|
|
372 |
want: "[----------------------------------------------------------<=======++++++++++++++++++++++++++++++++]",
|
| 384 | 373 |
},
|
| 385 | 374 |
},
|
| 386 | 375 |
}
|
|
| 412 | 401 |
}
|
| 413 | 402 |
}
|
| 414 | 403 |
|
|
404 |
func TestDrawTipInclusive(t *testing.T) {
|
|
405 |
// key is termWidth
|
|
406 |
testSuite := map[int][]struct {
|
|
407 |
style BarStyleComposer
|
|
408 |
name string
|
|
409 |
total int64
|
|
410 |
current int64
|
|
411 |
refill int64
|
|
412 |
barWidth int
|
|
413 |
trim bool
|
|
414 |
want string
|
|
415 |
}{
|
|
416 |
0: {
|
|
417 |
{
|
|
418 |
name: "t,c{60,20}",
|
|
419 |
total: 60,
|
|
420 |
current: 20,
|
|
421 |
want: "",
|
|
422 |
},
|
|
423 |
{
|
|
424 |
name: "t,c{60,20}trim",
|
|
425 |
total: 60,
|
|
426 |
current: 20,
|
|
427 |
trim: true,
|
|
428 |
want: "",
|
|
429 |
},
|
|
430 |
},
|
|
431 |
1: {
|
|
432 |
{
|
|
433 |
name: "t,c{60,20}",
|
|
434 |
total: 60,
|
|
435 |
current: 20,
|
|
436 |
want: "",
|
|
437 |
},
|
|
438 |
{
|
|
439 |
name: "t,c{60,20}trim",
|
|
440 |
total: 60,
|
|
441 |
current: 20,
|
|
442 |
trim: true,
|
|
443 |
want: "",
|
|
444 |
},
|
|
445 |
},
|
|
446 |
2: {
|
|
447 |
{
|
|
448 |
name: "t,c{60,20}",
|
|
449 |
total: 60,
|
|
450 |
current: 20,
|
|
451 |
want: " ",
|
|
452 |
},
|
|
453 |
{
|
|
454 |
name: "t,c{60,20}trim",
|
|
455 |
total: 60,
|
|
456 |
current: 20,
|
|
457 |
trim: true,
|
|
458 |
want: "[]",
|
|
459 |
},
|
|
460 |
},
|
|
461 |
3: {
|
|
462 |
{
|
|
463 |
name: "t,c{60,20}",
|
|
464 |
total: 60,
|
|
465 |
current: 20,
|
|
466 |
want: " ",
|
|
467 |
},
|
|
468 |
{
|
|
469 |
name: "t,c{60,20}trim",
|
|
470 |
total: 60,
|
|
471 |
current: 20,
|
|
472 |
trim: true,
|
|
473 |
want: "[-]",
|
|
474 |
},
|
|
475 |
},
|
|
476 |
4: {
|
|
477 |
{
|
|
478 |
name: "t,c{60,20}",
|
|
479 |
total: 60,
|
|
480 |
current: 20,
|
|
481 |
want: " [] ",
|
|
482 |
},
|
|
483 |
{
|
|
484 |
name: "t,c{60,20}trim",
|
|
485 |
total: 60,
|
|
486 |
current: 20,
|
|
487 |
trim: true,
|
|
488 |
want: "[>-]",
|
|
489 |
},
|
|
490 |
},
|
|
491 |
5: {
|
|
492 |
{
|
|
493 |
name: "t,c{60,20}",
|
|
494 |
total: 60,
|
|
495 |
current: 20,
|
|
496 |
want: " [-] ",
|
|
497 |
},
|
|
498 |
{
|
|
499 |
name: "t,c{60,20}trim",
|
|
500 |
total: 60,
|
|
501 |
current: 20,
|
|
502 |
trim: true,
|
|
503 |
want: "[>--]",
|
|
504 |
},
|
|
505 |
},
|
|
506 |
6: {
|
|
507 |
{
|
|
508 |
name: "t,c{60,20}",
|
|
509 |
total: 60,
|
|
510 |
current: 20,
|
|
511 |
want: " [>-] ",
|
|
512 |
},
|
|
513 |
{
|
|
514 |
name: "t,c{60,20}trim",
|
|
515 |
total: 60,
|
|
516 |
current: 20,
|
|
517 |
trim: true,
|
|
518 |
want: "[>---]",
|
|
519 |
},
|
|
520 |
},
|
|
521 |
7: {
|
|
522 |
{
|
|
523 |
name: "t,c{60,20}",
|
|
524 |
total: 60,
|
|
525 |
current: 20,
|
|
526 |
want: " [>--] ",
|
|
527 |
},
|
|
528 |
{
|
|
529 |
name: "t,c{60,20}trim",
|
|
530 |
total: 60,
|
|
531 |
current: 20,
|
|
532 |
trim: true,
|
|
533 |
want: "[=>---]",
|
|
534 |
},
|
|
535 |
},
|
|
536 |
8: {
|
|
537 |
{
|
|
538 |
name: "t,c{60,20}",
|
|
539 |
total: 60,
|
|
540 |
current: 20,
|
|
541 |
want: " [>---] ",
|
|
542 |
},
|
|
543 |
{
|
|
544 |
name: "t,c{60,20}trim",
|
|
545 |
total: 60,
|
|
546 |
current: 20,
|
|
547 |
trim: true,
|
|
548 |
want: "[=>----]",
|
|
549 |
},
|
|
550 |
},
|
|
551 |
80: {
|
|
552 |
{
|
|
553 |
name: "t,c{60,20}",
|
|
554 |
total: 60,
|
|
555 |
current: 20,
|
|
556 |
want: " [========================>---------------------------------------------------] ",
|
|
557 |
},
|
|
558 |
{
|
|
559 |
name: "t,c{60,20}trim",
|
|
560 |
total: 60,
|
|
561 |
current: 20,
|
|
562 |
trim: true,
|
|
563 |
want: "[=========================>----------------------------------------------------]",
|
|
564 |
},
|
|
565 |
{
|
|
566 |
name: "t,c,bw{60,20,60}",
|
|
567 |
total: 60,
|
|
568 |
current: 20,
|
|
569 |
barWidth: 60,
|
|
570 |
want: " [==================>---------------------------------------] ",
|
|
571 |
},
|
|
572 |
{
|
|
573 |
name: "t,c,bw{60,20,60}trim",
|
|
574 |
total: 60,
|
|
575 |
current: 20,
|
|
576 |
barWidth: 60,
|
|
577 |
trim: true,
|
|
578 |
want: "[==================>---------------------------------------]",
|
|
579 |
},
|
|
580 |
},
|
|
581 |
99: {
|
|
582 |
{
|
|
583 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
584 |
name: "[のだつ] t,c{99,1}",
|
|
585 |
total: 99,
|
|
586 |
current: 1,
|
|
587 |
want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
588 |
},
|
|
589 |
{
|
|
590 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
591 |
name: "[のだつ] t,c{99,2}",
|
|
592 |
total: 99,
|
|
593 |
current: 2,
|
|
594 |
want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
595 |
},
|
|
596 |
{
|
|
597 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
598 |
name: "[のだつ] t,c{99,3}",
|
|
599 |
total: 99,
|
|
600 |
current: 3,
|
|
601 |
want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
602 |
},
|
|
603 |
{
|
|
604 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
605 |
name: "[のだつ] t,c{99,4}",
|
|
606 |
total: 99,
|
|
607 |
current: 4,
|
|
608 |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
609 |
},
|
|
610 |
{
|
|
611 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
612 |
name: "[のだつ] t,c{99,5}",
|
|
613 |
total: 99,
|
|
614 |
current: 5,
|
|
615 |
want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
616 |
},
|
|
617 |
{
|
|
618 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"),
|
|
619 |
name: "[のだつ] t,c{99,6}",
|
|
620 |
total: 99,
|
|
621 |
current: 6,
|
|
622 |
want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ",
|
|
623 |
},
|
|
624 |
{
|
|
625 |
style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]").Reverse(),
|
|
626 |
name: "[のだつ] t,c{99,6}rev",
|
|
627 |
total: 99,
|
|
628 |
current: 6,
|
|
629 |
want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだのの] ",
|
|
630 |
},
|
|
631 |
},
|
|
632 |
100: {
|
|
633 |
{
|
|
634 |
name: "t,c{100,0}",
|
|
635 |
total: 100,
|
|
636 |
current: 0,
|
|
637 |
want: " [------------------------------------------------------------------------------------------------] ",
|
|
638 |
},
|
|
639 |
{
|
|
640 |
name: "t,c{100,0}trim",
|
|
641 |
total: 100,
|
|
642 |
current: 0,
|
|
643 |
trim: true,
|
|
644 |
want: "[--------------------------------------------------------------------------------------------------]",
|
|
645 |
},
|
|
646 |
{
|
|
647 |
name: "t,c{100,1}",
|
|
648 |
total: 100,
|
|
649 |
current: 1,
|
|
650 |
want: " [>-----------------------------------------------------------------------------------------------] ",
|
|
651 |
},
|
|
652 |
{
|
|
653 |
name: "t,c{100,1}trim",
|
|
654 |
total: 100,
|
|
655 |
current: 1,
|
|
656 |
trim: true,
|
|
657 |
want: "[>-------------------------------------------------------------------------------------------------]",
|
|
658 |
},
|
|
659 |
{
|
|
660 |
name: "t,c{100,99}",
|
|
661 |
total: 100,
|
|
662 |
current: 99,
|
|
663 |
want: " [==============================================================================================>-] ",
|
|
664 |
},
|
|
665 |
{
|
|
666 |
name: "t,c{100,99}trim",
|
|
667 |
total: 100,
|
|
668 |
current: 99,
|
|
669 |
trim: true,
|
|
670 |
want: "[================================================================================================>-]",
|
|
671 |
},
|
|
672 |
{
|
|
673 |
name: "t,c{100,100}",
|
|
674 |
total: 100,
|
|
675 |
current: 100,
|
|
676 |
want: " [===============================================================================================>] ",
|
|
677 |
},
|
|
678 |
{
|
|
679 |
name: "t,c{100,100}trim",
|
|
680 |
total: 100,
|
|
681 |
current: 100,
|
|
682 |
trim: true,
|
|
683 |
want: "[=================================================================================================>]",
|
|
684 |
},
|
|
685 |
{
|
|
686 |
name: "t,c,r{100,100,100}trim",
|
|
687 |
total: 100,
|
|
688 |
current: 100,
|
|
689 |
refill: 100,
|
|
690 |
trim: true,
|
|
691 |
want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>]",
|
|
692 |
},
|
|
693 |
{
|
|
694 |
name: "t,c{100,33}",
|
|
695 |
total: 100,
|
|
696 |
current: 33,
|
|
697 |
want: " [===============================>----------------------------------------------------------------] ",
|
|
698 |
},
|
|
699 |
{
|
|
700 |
name: "t,c{100,33}trim",
|
|
701 |
total: 100,
|
|
702 |
current: 33,
|
|
703 |
trim: true,
|
|
704 |
want: "[===============================>------------------------------------------------------------------]",
|
|
705 |
},
|
|
706 |
{
|
|
707 |
style: BarStyle().Tip("<").Reverse(),
|
|
708 |
name: "t,c{100,33}trim,rev",
|
|
709 |
total: 100,
|
|
710 |
current: 33,
|
|
711 |
trim: true,
|
|
712 |
want: "[------------------------------------------------------------------<===============================]",
|
|
713 |
},
|
|
714 |
{
|
|
715 |
name: "t,c,r{100,33,33}",
|
|
716 |
total: 100,
|
|
717 |
current: 33,
|
|
718 |
refill: 33,
|
|
719 |
want: " [+++++++++++++++++++++++++++++++>----------------------------------------------------------------] ",
|
|
720 |
},
|
|
721 |
{
|
|
722 |
name: "t,c,r{100,33,33}trim",
|
|
723 |
total: 100,
|
|
724 |
current: 33,
|
|
725 |
refill: 33,
|
|
726 |
trim: true,
|
|
727 |
want: "[+++++++++++++++++++++++++++++++>------------------------------------------------------------------]",
|
|
728 |
},
|
|
729 |
{
|
|
730 |
style: BarStyle().Tip("<").Reverse(),
|
|
731 |
name: "t,c,r{100,33,33}trim,rev",
|
|
732 |
total: 100,
|
|
733 |
current: 33,
|
|
734 |
refill: 33,
|
|
735 |
trim: true,
|
|
736 |
want: "[------------------------------------------------------------------<+++++++++++++++++++++++++++++++]",
|
|
737 |
},
|
|
738 |
{
|
|
739 |
name: "t,c,r{100,40,33}",
|
|
740 |
total: 100,
|
|
741 |
current: 40,
|
|
742 |
refill: 33,
|
|
743 |
want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ",
|
|
744 |
},
|
|
745 |
{
|
|
746 |
name: "t,c,r{100,40,33}trim",
|
|
747 |
total: 100,
|
|
748 |
current: 40,
|
|
749 |
refill: 33,
|
|
750 |
trim: true,
|
|
751 |
want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]",
|
|
752 |
},
|
|
753 |
{
|
|
754 |
style: BarStyle().Tip("<").Reverse(),
|
|
755 |
name: "t,c,r{100,40,33},rev",
|
|
756 |
total: 100,
|
|
757 |
current: 40,
|
|
758 |
refill: 33,
|
|
759 |
want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ",
|
|
760 |
},
|
|
761 |
{
|
|
762 |
style: BarStyle().Tip("<").Reverse(),
|
|
763 |
name: "t,c,r{100,40,33}trim,rev",
|
|
764 |
total: 100,
|
|
765 |
current: 40,
|
|
766 |
refill: 33,
|
|
767 |
trim: true,
|
|
768 |
want: "[-----------------------------------------------------------<======++++++++++++++++++++++++++++++++]",
|
|
769 |
},
|
|
770 |
},
|
|
771 |
}
|
|
772 |
|
|
773 |
var tmpBuf bytes.Buffer
|
|
774 |
for tw, cases := range testSuite {
|
|
775 |
for _, tc := range cases {
|
|
776 |
if tc.style == nil {
|
|
777 |
tc.style = BarStyle()
|
|
778 |
}
|
|
779 |
s := newTestState(NewBarFiller(tc.style.Inclusive(0)))
|
|
780 |
s.reqWidth = tc.barWidth
|
|
781 |
s.total = tc.total
|
|
782 |
s.current = tc.current
|
|
783 |
s.trimSpace = tc.trim
|
|
784 |
s.refill = tc.refill
|
|
785 |
tmpBuf.Reset()
|
|
786 |
tmpBuf.ReadFrom(s.draw(newStatistics(tw, s)))
|
|
787 |
by := tmpBuf.Bytes()
|
|
788 |
|
|
789 |
got := string(by[:len(by)-1])
|
|
790 |
if !utf8.ValidString(got) {
|
|
791 |
t.Fail()
|
|
792 |
}
|
|
793 |
if got != tc.want {
|
|
794 |
t.Errorf("termWidth:%d %q want: %q %d, got: %q %d\n", tw, tc.name, tc.want, utf8.RuneCountInString(tc.want), got, utf8.RuneCountInString(got))
|
|
795 |
}
|
|
796 |
}
|
|
797 |
}
|
|
798 |
}
|
|
799 |
|
| 415 | 800 |
func newTestState(filler BarFiller) *bState {
|
| 416 | 801 |
s := &bState{
|
| 417 | 802 |
filler: filler,
|