draw_test TipOnComplete
Vladimir Bauer
4 years ago
| 5 | 5 | "unicode/utf8" |
| 6 | 6 | ) |
| 7 | 7 | |
| 8 | func TestDraw(t *testing.T) { | |
| 8 | func TestDrawDefault(t *testing.T) { | |
| 9 | 9 | // key is termWidth |
| 10 | 10 | testSuite := map[int][]struct { |
| 11 | 11 | style BarStyleComposer |
| 19 | 19 | }{ |
| 20 | 20 | 0: { |
| 21 | 21 | { |
| 22 | style: BarStyle(), | |
| 22 | 23 | name: "t,c{60,20}", |
| 23 | 24 | total: 60, |
| 24 | 25 | current: 20, |
| 25 | 26 | want: "", |
| 26 | 27 | }, |
| 27 | 28 | { |
| 29 | style: BarStyle(), | |
| 28 | 30 | name: "t,c{60,20}trim", |
| 29 | 31 | total: 60, |
| 30 | 32 | current: 20, |
| 34 | 36 | }, |
| 35 | 37 | 1: { |
| 36 | 38 | { |
| 39 | style: BarStyle(), | |
| 37 | 40 | name: "t,c{60,20}", |
| 38 | 41 | total: 60, |
| 39 | 42 | current: 20, |
| 40 | 43 | want: "", |
| 41 | 44 | }, |
| 42 | 45 | { |
| 46 | style: BarStyle(), | |
| 43 | 47 | name: "t,c{60,20}trim", |
| 44 | 48 | total: 60, |
| 45 | 49 | current: 20, |
| 49 | 53 | }, |
| 50 | 54 | 2: { |
| 51 | 55 | { |
| 56 | style: BarStyle(), | |
| 52 | 57 | name: "t,c{60,20}", |
| 53 | 58 | total: 60, |
| 54 | 59 | current: 20, |
| 55 | 60 | want: " ", |
| 56 | 61 | }, |
| 57 | 62 | { |
| 63 | style: BarStyle(), | |
| 58 | 64 | name: "t,c{60,20}trim", |
| 59 | 65 | total: 60, |
| 60 | 66 | current: 20, |
| 64 | 70 | }, |
| 65 | 71 | 3: { |
| 66 | 72 | { |
| 73 | style: BarStyle(), | |
| 67 | 74 | name: "t,c{60,20}", |
| 68 | 75 | total: 60, |
| 69 | 76 | current: 20, |
| 70 | 77 | want: " ", |
| 71 | 78 | }, |
| 72 | 79 | { |
| 73 | name: "t,c{60,20}trim", | |
| 74 | total: 60, | |
| 75 | current: 20, | |
| 80 | style: BarStyle(), | |
| 81 | name: "t,c{60,20}trim", | |
| 82 | total: 60, | |
| 83 | current: 20, | |
| 84 | trim: true, | |
| 85 | want: "[-]", | |
| 86 | }, | |
| 87 | { | |
| 88 | style: BarStyle(), | |
| 89 | name: "t,c{60,59}", | |
| 90 | total: 60, | |
| 91 | current: 59, | |
| 92 | want: " ", | |
| 93 | }, | |
| 94 | { | |
| 95 | style: BarStyle(), | |
| 96 | name: "t,c{60,59}trim", | |
| 97 | total: 60, | |
| 98 | current: 59, | |
| 76 | 99 | trim: true, |
| 77 | 100 | want: "[>]", |
| 78 | 101 | }, |
| 102 | { | |
| 103 | style: BarStyle(), | |
| 104 | name: "t,c{60,60}", | |
| 105 | total: 60, | |
| 106 | current: 60, | |
| 107 | want: " ", | |
| 108 | }, | |
| 109 | { | |
| 110 | style: BarStyle(), | |
| 111 | name: "t,c{60,60}trim", | |
| 112 | total: 60, | |
| 113 | current: 60, | |
| 114 | trim: true, | |
| 115 | want: "[=]", | |
| 116 | }, | |
| 79 | 117 | }, |
| 80 | 118 | 4: { |
| 81 | 119 | { |
| 120 | style: BarStyle(), | |
| 82 | 121 | name: "t,c{60,20}", |
| 83 | 122 | total: 60, |
| 84 | 123 | current: 20, |
| 85 | 124 | want: " [] ", |
| 86 | 125 | }, |
| 87 | 126 | { |
| 88 | name: "t,c{60,20}trim", | |
| 89 | total: 60, | |
| 90 | current: 20, | |
| 127 | style: BarStyle(), | |
| 128 | name: "t,c{60,20}trim", | |
| 129 | total: 60, | |
| 130 | current: 20, | |
| 131 | trim: true, | |
| 132 | want: "[>-]", | |
| 133 | }, | |
| 134 | { | |
| 135 | style: BarStyle(), | |
| 136 | name: "t,c{60,59}", | |
| 137 | total: 60, | |
| 138 | current: 59, | |
| 139 | want: " [] ", | |
| 140 | }, | |
| 141 | { | |
| 142 | style: BarStyle(), | |
| 143 | name: "t,c{60,59}trim", | |
| 144 | total: 60, | |
| 145 | current: 59, | |
| 91 | 146 | trim: true, |
| 92 | 147 | want: "[=>]", |
| 93 | 148 | }, |
| 149 | { | |
| 150 | style: BarStyle(), | |
| 151 | name: "t,c{60,60}", | |
| 152 | total: 60, | |
| 153 | current: 60, | |
| 154 | want: " [] ", | |
| 155 | }, | |
| 156 | { | |
| 157 | style: BarStyle(), | |
| 158 | name: "t,c{60,60}trim", | |
| 159 | total: 60, | |
| 160 | current: 60, | |
| 161 | trim: true, | |
| 162 | want: "[==]", | |
| 163 | }, | |
| 94 | 164 | }, |
| 95 | 165 | 5: { |
| 96 | 166 | { |
| 97 | name: "t,c{60,20}", | |
| 98 | total: 60, | |
| 99 | current: 20, | |
| 167 | style: BarStyle(), | |
| 168 | name: "t,c{60,20}", | |
| 169 | total: 60, | |
| 170 | current: 20, | |
| 171 | want: " [-] ", | |
| 172 | }, | |
| 173 | { | |
| 174 | style: BarStyle(), | |
| 175 | name: "t,c{60,20}trim", | |
| 176 | total: 60, | |
| 177 | current: 20, | |
| 178 | trim: true, | |
| 179 | want: "[>--]", | |
| 180 | }, | |
| 181 | { | |
| 182 | style: BarStyle(), | |
| 183 | name: "t,c{60,59}", | |
| 184 | total: 60, | |
| 185 | current: 59, | |
| 100 | 186 | want: " [>] ", |
| 101 | 187 | }, |
| 102 | 188 | { |
| 103 | name: "t,c{60,20}trim", | |
| 104 | total: 60, | |
| 105 | current: 20, | |
| 106 | trim: true, | |
| 107 | want: "[=>-]", | |
| 189 | style: BarStyle(), | |
| 190 | name: "t,c{60,59}trim", | |
| 191 | total: 60, | |
| 192 | current: 59, | |
| 193 | trim: true, | |
| 194 | want: "[==>]", | |
| 195 | }, | |
| 196 | { | |
| 197 | style: BarStyle(), | |
| 198 | name: "t,c{60,60}", | |
| 199 | total: 60, | |
| 200 | current: 60, | |
| 201 | want: " [=] ", | |
| 202 | }, | |
| 203 | { | |
| 204 | style: BarStyle(), | |
| 205 | name: "t,c{60,60}trim", | |
| 206 | total: 60, | |
| 207 | current: 60, | |
| 208 | trim: true, | |
| 209 | want: "[===]", | |
| 108 | 210 | }, |
| 109 | 211 | }, |
| 110 | 212 | 6: { |
| 111 | 213 | { |
| 112 | name: "t,c{60,20}", | |
| 113 | total: 60, | |
| 114 | current: 20, | |
| 214 | style: BarStyle(), | |
| 215 | name: "t,c{60,20}", | |
| 216 | total: 60, | |
| 217 | current: 20, | |
| 218 | want: " [>-] ", | |
| 219 | }, | |
| 220 | { | |
| 221 | style: BarStyle(), | |
| 222 | name: "t,c{60,20}trim", | |
| 223 | total: 60, | |
| 224 | current: 20, | |
| 225 | trim: true, | |
| 226 | want: "[>---]", | |
| 227 | }, | |
| 228 | { | |
| 229 | style: BarStyle(), | |
| 230 | name: "t,c{60,59}", | |
| 231 | total: 60, | |
| 232 | current: 59, | |
| 115 | 233 | want: " [=>] ", |
| 116 | 234 | }, |
| 117 | 235 | { |
| 118 | name: "t,c{60,20}trim", | |
| 119 | total: 60, | |
| 120 | current: 20, | |
| 121 | trim: true, | |
| 122 | want: "[=>--]", | |
| 236 | style: BarStyle(), | |
| 237 | name: "t,c{60,59}trim", | |
| 238 | total: 60, | |
| 239 | current: 59, | |
| 240 | trim: true, | |
| 241 | want: "[===>]", | |
| 242 | }, | |
| 243 | { | |
| 244 | style: BarStyle(), | |
| 245 | name: "t,c{60,60}", | |
| 246 | total: 60, | |
| 247 | current: 60, | |
| 248 | want: " [==] ", | |
| 249 | }, | |
| 250 | { | |
| 251 | style: BarStyle(), | |
| 252 | name: "t,c{60,60}trim", | |
| 253 | total: 60, | |
| 254 | current: 60, | |
| 255 | trim: true, | |
| 256 | want: "[====]", | |
| 123 | 257 | }, |
| 124 | 258 | }, |
| 125 | 259 | 7: { |
| 126 | 260 | { |
| 127 | name: "t,c{60,20}", | |
| 128 | total: 60, | |
| 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: "[==>--]", | |
| 261 | style: BarStyle(), | |
| 262 | name: "t,c{60,20}", | |
| 263 | total: 60, | |
| 264 | current: 20, | |
| 265 | want: " [>--] ", | |
| 266 | }, | |
| 267 | { | |
| 268 | style: BarStyle(), | |
| 269 | name: "t,c{60,20}trim", | |
| 270 | total: 60, | |
| 271 | current: 20, | |
| 272 | trim: true, | |
| 273 | want: "[=>---]", | |
| 274 | }, | |
| 275 | { | |
| 276 | style: BarStyle(), | |
| 277 | name: "t,c{60,59}", | |
| 278 | total: 60, | |
| 279 | current: 59, | |
| 280 | want: " [==>] ", | |
| 281 | }, | |
| 282 | { | |
| 283 | style: BarStyle(), | |
| 284 | name: "t,c{60,59}trim", | |
| 285 | total: 60, | |
| 286 | current: 59, | |
| 287 | trim: true, | |
| 288 | want: "[====>]", | |
| 289 | }, | |
| 290 | { | |
| 291 | style: BarStyle(), | |
| 292 | name: "t,c{60,60}", | |
| 293 | total: 60, | |
| 294 | current: 60, | |
| 295 | want: " [===] ", | |
| 296 | }, | |
| 297 | { | |
| 298 | style: BarStyle(), | |
| 299 | name: "t,c{60,60}trim", | |
| 300 | total: 60, | |
| 301 | current: 60, | |
| 302 | trim: true, | |
| 303 | want: "[=====]", | |
| 138 | 304 | }, |
| 139 | 305 | }, |
| 140 | 306 | 8: { |
| 141 | 307 | { |
| 142 | name: "t,c{60,20}", | |
| 143 | total: 60, | |
| 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: "[==>---]", | |
| 308 | style: BarStyle(), | |
| 309 | name: "t,c{60,20}", | |
| 310 | total: 60, | |
| 311 | current: 20, | |
| 312 | want: " [>---] ", | |
| 313 | }, | |
| 314 | { | |
| 315 | style: BarStyle(), | |
| 316 | name: "t,c{60,20}trim", | |
| 317 | total: 60, | |
| 318 | current: 20, | |
| 319 | trim: true, | |
| 320 | want: "[=>----]", | |
| 321 | }, | |
| 322 | { | |
| 323 | style: BarStyle(), | |
| 324 | name: "t,c{60,59}", | |
| 325 | total: 60, | |
| 326 | current: 59, | |
| 327 | want: " [===>] ", | |
| 328 | }, | |
| 329 | { | |
| 330 | style: BarStyle(), | |
| 331 | name: "t,c{60,59}trim", | |
| 332 | total: 60, | |
| 333 | current: 59, | |
| 334 | trim: true, | |
| 335 | want: "[=====>]", | |
| 336 | }, | |
| 337 | { | |
| 338 | style: BarStyle(), | |
| 339 | name: "t,c{60,60}", | |
| 340 | total: 60, | |
| 341 | current: 60, | |
| 342 | want: " [====] ", | |
| 343 | }, | |
| 344 | { | |
| 345 | style: BarStyle(), | |
| 346 | name: "t,c{60,60}trim", | |
| 347 | total: 60, | |
| 348 | current: 60, | |
| 349 | trim: true, | |
| 350 | want: "[======]", | |
| 153 | 351 | }, |
| 154 | 352 | }, |
| 155 | 353 | 80: { |
| 156 | 354 | { |
| 157 | name: "t,c{60,20}", | |
| 158 | total: 60, | |
| 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: "[==========================>---------------------------------------------------]", | |
| 168 | }, | |
| 169 | { | |
| 355 | style: BarStyle(), | |
| 356 | name: "t,c{60,20}", | |
| 357 | total: 60, | |
| 358 | current: 20, | |
| 359 | want: " [========================>---------------------------------------------------] ", | |
| 360 | }, | |
| 361 | { | |
| 362 | style: BarStyle(), | |
| 363 | name: "t,c{60,20}trim", | |
| 364 | total: 60, | |
| 365 | current: 20, | |
| 366 | trim: true, | |
| 367 | want: "[=========================>----------------------------------------------------]", | |
| 368 | }, | |
| 369 | { | |
| 370 | style: BarStyle(), | |
| 170 | 371 | name: "t,c,bw{60,20,60}", |
| 171 | 372 | total: 60, |
| 172 | 373 | current: 20, |
| 173 | 374 | barWidth: 60, |
| 174 | want: " [===================>--------------------------------------] ", | |
| 175 | }, | |
| 176 | { | |
| 375 | want: " [==================>---------------------------------------] ", | |
| 376 | }, | |
| 377 | { | |
| 378 | style: BarStyle(), | |
| 177 | 379 | name: "t,c,bw{60,20,60}trim", |
| 178 | 380 | total: 60, |
| 179 | 381 | current: 20, |
| 180 | 382 | barWidth: 60, |
| 181 | 383 | trim: true, |
| 182 | want: "[===================>--------------------------------------]", | |
| 384 | want: "[==================>---------------------------------------]", | |
| 385 | }, | |
| 386 | { | |
| 387 | style: BarStyle(), | |
| 388 | name: "t,c{60,59}", | |
| 389 | total: 60, | |
| 390 | current: 59, | |
| 391 | want: " [==========================================================================>-] ", | |
| 392 | }, | |
| 393 | { | |
| 394 | style: BarStyle(), | |
| 395 | name: "t,c{60,59}trim", | |
| 396 | total: 60, | |
| 397 | current: 59, | |
| 398 | trim: true, | |
| 399 | want: "[============================================================================>-]", | |
| 400 | }, | |
| 401 | { | |
| 402 | style: BarStyle(), | |
| 403 | name: "t,c,bw{60,59,60}", | |
| 404 | total: 60, | |
| 405 | current: 59, | |
| 406 | barWidth: 60, | |
| 407 | want: " [========================================================>-] ", | |
| 408 | }, | |
| 409 | { | |
| 410 | style: BarStyle(), | |
| 411 | name: "t,c,bw{60,59,60}trim", | |
| 412 | total: 60, | |
| 413 | current: 59, | |
| 414 | barWidth: 60, | |
| 415 | trim: true, | |
| 416 | want: "[========================================================>-]", | |
| 417 | }, | |
| 418 | { | |
| 419 | style: BarStyle(), | |
| 420 | name: "t,c{60,60}", | |
| 421 | total: 60, | |
| 422 | current: 60, | |
| 423 | want: " [============================================================================] ", | |
| 424 | }, | |
| 425 | { | |
| 426 | style: BarStyle(), | |
| 427 | name: "t,c{60,60}trim", | |
| 428 | total: 60, | |
| 429 | current: 60, | |
| 430 | trim: true, | |
| 431 | want: "[==============================================================================]", | |
| 432 | }, | |
| 433 | { | |
| 434 | style: BarStyle(), | |
| 435 | name: "t,c,bw{60,60,60}", | |
| 436 | total: 60, | |
| 437 | current: 60, | |
| 438 | barWidth: 60, | |
| 439 | want: " [==========================================================] ", | |
| 440 | }, | |
| 441 | { | |
| 442 | style: BarStyle(), | |
| 443 | name: "t,c,bw{60,60,60}trim", | |
| 444 | total: 60, | |
| 445 | current: 60, | |
| 446 | barWidth: 60, | |
| 447 | trim: true, | |
| 448 | want: "[==========================================================]", | |
| 183 | 449 | }, |
| 184 | 450 | }, |
| 185 | 451 | 99: { |
| 186 | 452 | { |
| 187 | 453 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), |
| 188 | name: "[のだつ] t,c{99,1}", | |
| 189 | total: 99, | |
| 454 | name: `t,c{100,1}Tip("だ")`, | |
| 455 | total: 100, | |
| 190 | 456 | current: 1, |
| 191 | 457 | want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", |
| 192 | 458 | }, |
| 193 | 459 | { |
| 194 | 460 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), |
| 195 | name: "[のだつ] t,c{99,2}", | |
| 196 | total: 99, | |
| 461 | name: `t,c{100,2}Tip("だ")`, | |
| 462 | total: 100, | |
| 197 | 463 | current: 2, |
| 198 | want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 464 | want: " [だつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 199 | 465 | }, |
| 200 | 466 | { |
| 201 | 467 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), |
| 202 | name: "[のだつ] t,c{99,3}", | |
| 203 | total: 99, | |
| 204 | current: 3, | |
| 205 | want: " [のだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 468 | name: `t,c{100,99}Tip("だ")`, | |
| 469 | total: 100, | |
| 470 | current: 99, | |
| 471 | want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", | |
| 206 | 472 | }, |
| 207 | 473 | { |
| 208 | 474 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), |
| 209 | name: "[のだつ] t,c{99,4}", | |
| 210 | total: 99, | |
| 211 | current: 4, | |
| 212 | want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 213 | }, | |
| 214 | { | |
| 215 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), | |
| 216 | name: "[のだつ] t,c{99,5}", | |
| 217 | total: 99, | |
| 218 | current: 5, | |
| 219 | want: " [ののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 220 | }, | |
| 221 | { | |
| 222 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]"), | |
| 223 | name: "[のだつ] t,c{99,6}", | |
| 224 | total: 99, | |
| 225 | current: 6, | |
| 226 | want: " [のののだつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつ…] ", | |
| 475 | name: `t,c{100,100}Tip("だ")`, | |
| 476 | total: 100, | |
| 477 | current: 100, | |
| 478 | want: " [ののののののののののののののののののののののののののののののののののののののののののののののの…] ", | |
| 227 | 479 | }, |
| 228 | 480 | { |
| 229 | 481 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").Padding("つ").Rbound("]").Reverse(), |
| 230 | name: "[のだつ] t,c{99,6}rev", | |
| 231 | total: 99, | |
| 232 | current: 6, | |
| 233 | want: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだののの] ", | |
| 482 | name: `t,c{100,100}Tip("だ")rev`, | |
| 483 | total: 100, | |
| 484 | current: 100, | |
| 485 | want: " […ののののののののののののののののののののののののののののののののののののののののののののののの] ", | |
| 234 | 486 | }, |
| 235 | 487 | }, |
| 236 | 488 | 100: { |
| 237 | 489 | { |
| 490 | style: BarStyle(), | |
| 238 | 491 | name: "t,c{100,0}", |
| 239 | 492 | total: 100, |
| 240 | 493 | current: 0, |
| 494 | want: " [------------------------------------------------------------------------------------------------] ", | |
| 495 | }, | |
| 496 | { | |
| 497 | style: BarStyle(), | |
| 498 | name: "t,c{100,0}trim", | |
| 499 | total: 100, | |
| 500 | current: 0, | |
| 501 | trim: true, | |
| 502 | want: "[--------------------------------------------------------------------------------------------------]", | |
| 503 | }, | |
| 504 | { | |
| 505 | style: BarStyle(), | |
| 506 | name: "t,c{100,1}", | |
| 507 | total: 100, | |
| 508 | current: 1, | |
| 241 | 509 | want: " [>-----------------------------------------------------------------------------------------------] ", |
| 242 | 510 | }, |
| 243 | 511 | { |
| 244 | name: "t,c{100,0}trim", | |
| 245 | total: 100, | |
| 246 | current: 0, | |
| 512 | style: BarStyle(), | |
| 513 | name: "t,c{100,1}trim", | |
| 514 | total: 100, | |
| 515 | current: 1, | |
| 247 | 516 | trim: true, |
| 248 | 517 | want: "[>-------------------------------------------------------------------------------------------------]", |
| 249 | 518 | }, |
| 250 | 519 | { |
| 251 | name: "t,c{100,1}", | |
| 252 | total: 100, | |
| 253 | current: 1, | |
| 254 | want: " [=>----------------------------------------------------------------------------------------------] ", | |
| 255 | }, | |
| 256 | { | |
| 257 | name: "t,c{100,1}trim", | |
| 258 | total: 100, | |
| 259 | current: 1, | |
| 260 | trim: true, | |
| 261 | want: "[=>------------------------------------------------------------------------------------------------]", | |
| 262 | }, | |
| 263 | { | |
| 520 | style: BarStyle(), | |
| 264 | 521 | name: "t,c{100,99}", |
| 265 | 522 | total: 100, |
| 266 | 523 | current: 99, |
| 267 | want: " [===============================================================================================>] ", | |
| 268 | }, | |
| 269 | { | |
| 524 | want: " [==============================================================================================>-] ", | |
| 525 | }, | |
| 526 | { | |
| 527 | style: BarStyle(), | |
| 270 | 528 | name: "t,c{100,99}trim", |
| 271 | 529 | total: 100, |
| 272 | 530 | current: 99, |
| 273 | 531 | trim: true, |
| 274 | want: "[=================================================================================================>]", | |
| 275 | }, | |
| 276 | { | |
| 532 | want: "[================================================================================================>-]", | |
| 533 | }, | |
| 534 | { | |
| 535 | style: BarStyle(), | |
| 277 | 536 | name: "t,c{100,100}", |
| 278 | 537 | total: 100, |
| 279 | 538 | current: 100, |
| 280 | 539 | want: " [================================================================================================] ", |
| 281 | 540 | }, |
| 282 | 541 | { |
| 542 | style: BarStyle(), | |
| 283 | 543 | name: "t,c{100,100}trim", |
| 284 | 544 | total: 100, |
| 285 | 545 | current: 100, |
| 287 | 547 | want: "[==================================================================================================]", |
| 288 | 548 | }, |
| 289 | 549 | { |
| 550 | style: BarStyle(), | |
| 551 | name: "t,c,r{100,100,99}", | |
| 552 | total: 100, | |
| 553 | current: 100, | |
| 554 | refill: 99, | |
| 555 | want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=] ", | |
| 556 | }, | |
| 557 | { | |
| 558 | style: BarStyle(), | |
| 559 | name: "t,c,r{100,100,99}trim", | |
| 560 | total: 100, | |
| 561 | current: 100, | |
| 562 | refill: 99, | |
| 563 | trim: true, | |
| 564 | want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=]", | |
| 565 | }, | |
| 566 | { | |
| 567 | style: BarStyle(), | |
| 568 | name: "t,c,r{100,100,100}", | |
| 569 | total: 100, | |
| 570 | current: 100, | |
| 571 | refill: 100, | |
| 572 | want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", | |
| 573 | }, | |
| 574 | { | |
| 575 | style: BarStyle(), | |
| 290 | 576 | name: "t,c,r{100,100,100}trim", |
| 291 | 577 | total: 100, |
| 292 | 578 | current: 100, |
| 295 | 581 | want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", |
| 296 | 582 | }, |
| 297 | 583 | { |
| 298 | name: "t,c{100,33}", | |
| 299 | total: 100, | |
| 300 | current: 33, | |
| 301 | want: " [================================>---------------------------------------------------------------] ", | |
| 302 | }, | |
| 303 | { | |
| 304 | name: "t,c{100,33}trim", | |
| 305 | total: 100, | |
| 306 | current: 33, | |
| 307 | trim: true, | |
| 308 | want: "[================================>-----------------------------------------------------------------]", | |
| 309 | }, | |
| 310 | { | |
| 311 | style: BarStyle().Tip("<").Reverse(), | |
| 312 | name: "t,c{100,33}trim,rev", | |
| 313 | total: 100, | |
| 314 | current: 33, | |
| 315 | trim: true, | |
| 316 | want: "[-----------------------------------------------------------------<================================]", | |
| 317 | }, | |
| 318 | { | |
| 319 | name: "t,c,r{100,33,33}", | |
| 320 | total: 100, | |
| 321 | current: 33, | |
| 322 | refill: 33, | |
| 323 | want: " [++++++++++++++++++++++++++++++++>---------------------------------------------------------------] ", | |
| 324 | }, | |
| 325 | { | |
| 326 | name: "t,c,r{100,33,33}trim", | |
| 327 | total: 100, | |
| 328 | current: 33, | |
| 329 | refill: 33, | |
| 330 | trim: true, | |
| 331 | want: "[++++++++++++++++++++++++++++++++>-----------------------------------------------------------------]", | |
| 332 | }, | |
| 333 | { | |
| 334 | style: BarStyle().Tip("<").Reverse(), | |
| 335 | name: "t,c,r{100,33,33}trim,rev", | |
| 336 | total: 100, | |
| 337 | current: 33, | |
| 338 | refill: 33, | |
| 339 | trim: true, | |
| 340 | want: "[-----------------------------------------------------------------<++++++++++++++++++++++++++++++++]", | |
| 341 | }, | |
| 342 | { | |
| 584 | style: BarStyle().Tip("", "<").Reverse(), | |
| 585 | name: "t,c,r{100,100,99}rev", | |
| 586 | total: 100, | |
| 587 | current: 100, | |
| 588 | refill: 99, | |
| 589 | want: " [=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", | |
| 590 | }, | |
| 591 | { | |
| 592 | style: BarStyle().Tip("", "<").Reverse(), | |
| 593 | name: "t,c,r{100,100,99}trim,rev", | |
| 594 | total: 100, | |
| 595 | current: 100, | |
| 596 | refill: 99, | |
| 597 | trim: true, | |
| 598 | want: "[=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", | |
| 599 | }, | |
| 600 | { | |
| 601 | style: BarStyle().Tip("", "<").Reverse(), | |
| 602 | name: "t,c,r{100,100,100}rev", | |
| 603 | total: 100, | |
| 604 | current: 100, | |
| 605 | refill: 100, | |
| 606 | want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", | |
| 607 | }, | |
| 608 | { | |
| 609 | style: BarStyle().Tip("", "<").Reverse(), | |
| 610 | name: "t,c,r{100,100,100}trim", | |
| 611 | total: 100, | |
| 612 | current: 100, | |
| 613 | refill: 100, | |
| 614 | trim: true, | |
| 615 | want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", | |
| 616 | }, | |
| 617 | { | |
| 618 | style: BarStyle(), | |
| 343 | 619 | name: "t,c,r{100,40,33}", |
| 344 | 620 | total: 100, |
| 345 | 621 | current: 40, |
| 346 | 622 | refill: 33, |
| 347 | want: " [++++++++++++++++++++++++++++++++======>---------------------------------------------------------] ", | |
| 348 | }, | |
| 349 | { | |
| 623 | want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ", | |
| 624 | }, | |
| 625 | { | |
| 626 | style: BarStyle(), | |
| 350 | 627 | name: "t,c,r{100,40,33}trim", |
| 351 | 628 | total: 100, |
| 352 | 629 | current: 40, |
| 353 | 630 | refill: 33, |
| 354 | 631 | trim: true, |
| 355 | want: "[++++++++++++++++++++++++++++++++=======>----------------------------------------------------------]", | |
| 632 | want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]", | |
| 356 | 633 | }, |
| 357 | 634 | { |
| 358 | 635 | style: BarStyle().Tip("<").Reverse(), |
| 360 | 637 | total: 100, |
| 361 | 638 | current: 40, |
| 362 | 639 | refill: 33, |
| 363 | want: " [---------------------------------------------------------<======++++++++++++++++++++++++++++++++] ", | |
| 640 | want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ", | |
| 364 | 641 | }, |
| 365 | 642 | { |
| 366 | 643 | style: BarStyle().Tip("<").Reverse(), |
| 369 | 646 | current: 40, |
| 370 | 647 | refill: 33, |
| 371 | 648 | trim: true, |
| 372 | want: "[----------------------------------------------------------<=======++++++++++++++++++++++++++++++++]", | |
| 649 | want: "[-----------------------------------------------------------<======++++++++++++++++++++++++++++++++]", | |
| 373 | 650 | }, |
| 374 | 651 | }, |
| 375 | 652 | } |
| 377 | 654 | var tmpBuf bytes.Buffer |
| 378 | 655 | for tw, cases := range testSuite { |
| 379 | 656 | for _, tc := range cases { |
| 380 | if tc.style == nil { | |
| 381 | tc.style = BarStyle() | |
| 382 | } | |
| 383 | 657 | s := newTestState(NewBarFiller(tc.style)) |
| 384 | 658 | s.reqWidth = tc.barWidth |
| 385 | 659 | s.total = tc.total |
| 401 | 675 | } |
| 402 | 676 | } |
| 403 | 677 | |
| 404 | func TestDrawTipInclusive(t *testing.T) { | |
| 678 | func TestDrawTipOnComplete(t *testing.T) { | |
| 405 | 679 | // key is termWidth |
| 406 | 680 | testSuite := map[int][]struct { |
| 407 | 681 | style BarStyleComposer |
| 415 | 689 | }{ |
| 416 | 690 | 0: { |
| 417 | 691 | { |
| 692 | style: BarStyle().TipOnComplete(">"), | |
| 418 | 693 | name: "t,c{60,20}", |
| 419 | 694 | total: 60, |
| 420 | 695 | current: 20, |
| 421 | 696 | want: "", |
| 422 | 697 | }, |
| 423 | 698 | { |
| 699 | style: BarStyle().TipOnComplete(">"), | |
| 424 | 700 | name: "t,c{60,20}trim", |
| 425 | 701 | total: 60, |
| 426 | 702 | current: 20, |
| 430 | 706 | }, |
| 431 | 707 | 1: { |
| 432 | 708 | { |
| 709 | style: BarStyle().TipOnComplete(">"), | |
| 433 | 710 | name: "t,c{60,20}", |
| 434 | 711 | total: 60, |
| 435 | 712 | current: 20, |
| 436 | 713 | want: "", |
| 437 | 714 | }, |
| 438 | 715 | { |
| 716 | style: BarStyle().TipOnComplete(">"), | |
| 439 | 717 | name: "t,c{60,20}trim", |
| 440 | 718 | total: 60, |
| 441 | 719 | current: 20, |
| 445 | 723 | }, |
| 446 | 724 | 2: { |
| 447 | 725 | { |
| 726 | style: BarStyle().TipOnComplete(">"), | |
| 448 | 727 | name: "t,c{60,20}", |
| 449 | 728 | total: 60, |
| 450 | 729 | current: 20, |
| 451 | 730 | want: " ", |
| 452 | 731 | }, |
| 453 | 732 | { |
| 733 | style: BarStyle().TipOnComplete(">"), | |
| 454 | 734 | name: "t,c{60,20}trim", |
| 455 | 735 | total: 60, |
| 456 | 736 | current: 20, |
| 460 | 740 | }, |
| 461 | 741 | 3: { |
| 462 | 742 | { |
| 743 | style: BarStyle().TipOnComplete(">"), | |
| 463 | 744 | name: "t,c{60,20}", |
| 464 | 745 | total: 60, |
| 465 | 746 | current: 20, |
| 466 | 747 | want: " ", |
| 467 | 748 | }, |
| 468 | 749 | { |
| 750 | style: BarStyle().TipOnComplete(">"), | |
| 469 | 751 | name: "t,c{60,20}trim", |
| 470 | 752 | total: 60, |
| 471 | 753 | current: 20, |
| 472 | 754 | trim: true, |
| 473 | 755 | want: "[-]", |
| 474 | 756 | }, |
| 757 | { | |
| 758 | style: BarStyle().TipOnComplete(">"), | |
| 759 | name: "t,c{60,59}", | |
| 760 | total: 60, | |
| 761 | current: 59, | |
| 762 | want: " ", | |
| 763 | }, | |
| 764 | { | |
| 765 | style: BarStyle().TipOnComplete(">"), | |
| 766 | name: "t,c{60,59}trim", | |
| 767 | total: 60, | |
| 768 | current: 59, | |
| 769 | trim: true, | |
| 770 | want: "[>]", | |
| 771 | }, | |
| 772 | { | |
| 773 | style: BarStyle().TipOnComplete(">"), | |
| 774 | name: "t,c{60,60}", | |
| 775 | total: 60, | |
| 776 | current: 60, | |
| 777 | want: " ", | |
| 778 | }, | |
| 779 | { | |
| 780 | style: BarStyle().TipOnComplete(">"), | |
| 781 | name: "t,c{60,60}trim", | |
| 782 | total: 60, | |
| 783 | current: 60, | |
| 784 | trim: true, | |
| 785 | want: "[>]", | |
| 786 | }, | |
| 475 | 787 | }, |
| 476 | 788 | 4: { |
| 477 | 789 | { |
| 790 | style: BarStyle().TipOnComplete(">"), | |
| 478 | 791 | name: "t,c{60,20}", |
| 479 | 792 | total: 60, |
| 480 | 793 | current: 20, |
| 481 | 794 | want: " [] ", |
| 482 | 795 | }, |
| 483 | 796 | { |
| 797 | style: BarStyle().TipOnComplete(">"), | |
| 484 | 798 | name: "t,c{60,20}trim", |
| 485 | 799 | total: 60, |
| 486 | 800 | current: 20, |
| 487 | 801 | trim: true, |
| 488 | 802 | want: "[>-]", |
| 489 | 803 | }, |
| 804 | { | |
| 805 | style: BarStyle().TipOnComplete(">"), | |
| 806 | name: "t,c{60,59}", | |
| 807 | total: 60, | |
| 808 | current: 59, | |
| 809 | want: " [] ", | |
| 810 | }, | |
| 811 | { | |
| 812 | style: BarStyle().TipOnComplete(">"), | |
| 813 | name: "t,c{60,59}trim", | |
| 814 | total: 60, | |
| 815 | current: 59, | |
| 816 | trim: true, | |
| 817 | want: "[=>]", | |
| 818 | }, | |
| 819 | { | |
| 820 | style: BarStyle().TipOnComplete(">"), | |
| 821 | name: "t,c{60,60}", | |
| 822 | total: 60, | |
| 823 | current: 60, | |
| 824 | want: " [] ", | |
| 825 | }, | |
| 826 | { | |
| 827 | style: BarStyle().TipOnComplete(">"), | |
| 828 | name: "t,c{60,60}trim", | |
| 829 | total: 60, | |
| 830 | current: 60, | |
| 831 | trim: true, | |
| 832 | want: "[=>]", | |
| 833 | }, | |
| 490 | 834 | }, |
| 491 | 835 | 5: { |
| 492 | 836 | { |
| 837 | style: BarStyle().TipOnComplete(">"), | |
| 493 | 838 | name: "t,c{60,20}", |
| 494 | 839 | total: 60, |
| 495 | 840 | current: 20, |
| 496 | 841 | want: " [-] ", |
| 497 | 842 | }, |
| 498 | 843 | { |
| 844 | style: BarStyle().TipOnComplete(">"), | |
| 499 | 845 | name: "t,c{60,20}trim", |
| 500 | 846 | total: 60, |
| 501 | 847 | current: 20, |
| 502 | 848 | trim: true, |
| 503 | 849 | want: "[>--]", |
| 504 | 850 | }, |
| 851 | { | |
| 852 | style: BarStyle().TipOnComplete(">"), | |
| 853 | name: "t,c{60,59}", | |
| 854 | total: 60, | |
| 855 | current: 59, | |
| 856 | want: " [>] ", | |
| 857 | }, | |
| 858 | { | |
| 859 | style: BarStyle().TipOnComplete(">"), | |
| 860 | name: "t,c{60,59}trim", | |
| 861 | total: 60, | |
| 862 | current: 59, | |
| 863 | trim: true, | |
| 864 | want: "[==>]", | |
| 865 | }, | |
| 866 | { | |
| 867 | style: BarStyle().TipOnComplete(">"), | |
| 868 | name: "t,c{60,60}", | |
| 869 | total: 60, | |
| 870 | current: 60, | |
| 871 | want: " [>] ", | |
| 872 | }, | |
| 873 | { | |
| 874 | style: BarStyle().TipOnComplete(">"), | |
| 875 | name: "t,c{60,60}trim", | |
| 876 | total: 60, | |
| 877 | current: 60, | |
| 878 | trim: true, | |
| 879 | want: "[==>]", | |
| 880 | }, | |
| 505 | 881 | }, |
| 506 | 882 | 6: { |
| 507 | 883 | { |
| 884 | style: BarStyle().TipOnComplete(">"), | |
| 508 | 885 | name: "t,c{60,20}", |
| 509 | 886 | total: 60, |
| 510 | 887 | current: 20, |
| 511 | 888 | want: " [>-] ", |
| 512 | 889 | }, |
| 513 | 890 | { |
| 891 | style: BarStyle().TipOnComplete(">"), | |
| 514 | 892 | name: "t,c{60,20}trim", |
| 515 | 893 | total: 60, |
| 516 | 894 | current: 20, |
| 517 | 895 | trim: true, |
| 518 | 896 | want: "[>---]", |
| 519 | 897 | }, |
| 898 | { | |
| 899 | style: BarStyle().TipOnComplete(">"), | |
| 900 | name: "t,c{60,59}", | |
| 901 | total: 60, | |
| 902 | current: 59, | |
| 903 | want: " [=>] ", | |
| 904 | }, | |
| 905 | { | |
| 906 | style: BarStyle().TipOnComplete(">"), | |
| 907 | name: "t,c{60,59}trim", | |
| 908 | total: 60, | |
| 909 | current: 59, | |
| 910 | trim: true, | |
| 911 | want: "[===>]", | |
| 912 | }, | |
| 913 | { | |
| 914 | style: BarStyle().TipOnComplete(">"), | |
| 915 | name: "t,c{60,60}", | |
| 916 | total: 60, | |
| 917 | current: 60, | |
| 918 | want: " [=>] ", | |
| 919 | }, | |
| 920 | { | |
| 921 | style: BarStyle().TipOnComplete(">"), | |
| 922 | name: "t,c{60,60}trim", | |
| 923 | total: 60, | |
| 924 | current: 60, | |
| 925 | trim: true, | |
| 926 | want: "[===>]", | |
| 927 | }, | |
| 520 | 928 | }, |
| 521 | 929 | 7: { |
| 522 | 930 | { |
| 931 | style: BarStyle().TipOnComplete(">"), | |
| 523 | 932 | name: "t,c{60,20}", |
| 524 | 933 | total: 60, |
| 525 | 934 | current: 20, |
| 526 | 935 | want: " [>--] ", |
| 527 | 936 | }, |
| 528 | 937 | { |
| 938 | style: BarStyle().TipOnComplete(">"), | |
| 529 | 939 | name: "t,c{60,20}trim", |
| 530 | 940 | total: 60, |
| 531 | 941 | current: 20, |
| 532 | 942 | trim: true, |
| 533 | 943 | want: "[=>---]", |
| 534 | 944 | }, |
| 945 | { | |
| 946 | style: BarStyle().TipOnComplete(">"), | |
| 947 | name: "t,c{60,59}", | |
| 948 | total: 60, | |
| 949 | current: 59, | |
| 950 | want: " [==>] ", | |
| 951 | }, | |
| 952 | { | |
| 953 | style: BarStyle().TipOnComplete(">"), | |
| 954 | name: "t,c{60,59}trim", | |
| 955 | total: 60, | |
| 956 | current: 59, | |
| 957 | trim: true, | |
| 958 | want: "[====>]", | |
| 959 | }, | |
| 960 | { | |
| 961 | style: BarStyle().TipOnComplete(">"), | |
| 962 | name: "t,c{60,60}", | |
| 963 | total: 60, | |
| 964 | current: 60, | |
| 965 | want: " [==>] ", | |
| 966 | }, | |
| 967 | { | |
| 968 | style: BarStyle().TipOnComplete(">"), | |
| 969 | name: "t,c{60,60}trim", | |
| 970 | total: 60, | |
| 971 | current: 60, | |
| 972 | trim: true, | |
| 973 | want: "[====>]", | |
| 974 | }, | |
| 535 | 975 | }, |
| 536 | 976 | 8: { |
| 537 | 977 | { |
| 978 | style: BarStyle().TipOnComplete(">"), | |
| 538 | 979 | name: "t,c{60,20}", |
| 539 | 980 | total: 60, |
| 540 | 981 | current: 20, |
| 541 | 982 | want: " [>---] ", |
| 542 | 983 | }, |
| 543 | 984 | { |
| 985 | style: BarStyle().TipOnComplete(">"), | |
| 544 | 986 | name: "t,c{60,20}trim", |
| 545 | 987 | total: 60, |
| 546 | 988 | current: 20, |
| 547 | 989 | trim: true, |
| 548 | 990 | want: "[=>----]", |
| 549 | 991 | }, |
| 992 | { | |
| 993 | style: BarStyle().TipOnComplete(">"), | |
| 994 | name: "t,c{60,59}", | |
| 995 | total: 60, | |
| 996 | current: 59, | |
| 997 | want: " [===>] ", | |
| 998 | }, | |
| 999 | { | |
| 1000 | style: BarStyle().TipOnComplete(">"), | |
| 1001 | name: "t,c{60,59}trim", | |
| 1002 | total: 60, | |
| 1003 | current: 59, | |
| 1004 | trim: true, | |
| 1005 | want: "[=====>]", | |
| 1006 | }, | |
| 1007 | { | |
| 1008 | style: BarStyle().TipOnComplete(">"), | |
| 1009 | name: "t,c{60,60}", | |
| 1010 | total: 60, | |
| 1011 | current: 60, | |
| 1012 | want: " [===>] ", | |
| 1013 | }, | |
| 1014 | { | |
| 1015 | style: BarStyle().TipOnComplete(">"), | |
| 1016 | name: "t,c{60,60}trim", | |
| 1017 | total: 60, | |
| 1018 | current: 60, | |
| 1019 | trim: true, | |
| 1020 | want: "[=====>]", | |
| 1021 | }, | |
| 550 | 1022 | }, |
| 551 | 1023 | 80: { |
| 552 | 1024 | { |
| 1025 | style: BarStyle().TipOnComplete(">"), | |
| 553 | 1026 | name: "t,c{60,20}", |
| 554 | 1027 | total: 60, |
| 555 | 1028 | current: 20, |
| 556 | 1029 | want: " [========================>---------------------------------------------------] ", |
| 557 | 1030 | }, |
| 558 | 1031 | { |
| 1032 | style: BarStyle().TipOnComplete(">"), | |
| 559 | 1033 | name: "t,c{60,20}trim", |
| 560 | 1034 | total: 60, |
| 561 | 1035 | current: 20, |
| 563 | 1037 | want: "[=========================>----------------------------------------------------]", |
| 564 | 1038 | }, |
| 565 | 1039 | { |
| 1040 | style: BarStyle().TipOnComplete(">"), | |
| 566 | 1041 | name: "t,c,bw{60,20,60}", |
| 567 | 1042 | total: 60, |
| 568 | 1043 | current: 20, |
| 570 | 1045 | want: " [==================>---------------------------------------] ", |
| 571 | 1046 | }, |
| 572 | 1047 | { |
| 1048 | style: BarStyle().TipOnComplete(">"), | |
| 573 | 1049 | name: "t,c,bw{60,20,60}trim", |
| 574 | 1050 | total: 60, |
| 575 | 1051 | current: 20, |
| 577 | 1053 | trim: true, |
| 578 | 1054 | want: "[==================>---------------------------------------]", |
| 579 | 1055 | }, |
| 1056 | { | |
| 1057 | style: BarStyle().TipOnComplete(">"), | |
| 1058 | name: "t,c{60,59}", | |
| 1059 | total: 60, | |
| 1060 | current: 59, | |
| 1061 | want: " [==========================================================================>-] ", | |
| 1062 | }, | |
| 1063 | { | |
| 1064 | style: BarStyle().TipOnComplete(">"), | |
| 1065 | name: "t,c{60,59}trim", | |
| 1066 | total: 60, | |
| 1067 | current: 59, | |
| 1068 | trim: true, | |
| 1069 | want: "[============================================================================>-]", | |
| 1070 | }, | |
| 1071 | { | |
| 1072 | style: BarStyle().TipOnComplete(">"), | |
| 1073 | name: "t,c,bw{60,59,60}", | |
| 1074 | total: 60, | |
| 1075 | current: 59, | |
| 1076 | barWidth: 60, | |
| 1077 | want: " [========================================================>-] ", | |
| 1078 | }, | |
| 1079 | { | |
| 1080 | style: BarStyle().TipOnComplete(">"), | |
| 1081 | name: "t,c,bw{60,59,60}trim", | |
| 1082 | total: 60, | |
| 1083 | current: 59, | |
| 1084 | barWidth: 60, | |
| 1085 | trim: true, | |
| 1086 | want: "[========================================================>-]", | |
| 1087 | }, | |
| 1088 | { | |
| 1089 | style: BarStyle().TipOnComplete(">"), | |
| 1090 | name: "t,c{60,60}", | |
| 1091 | total: 60, | |
| 1092 | current: 60, | |
| 1093 | want: " [===========================================================================>] ", | |
| 1094 | }, | |
| 1095 | { | |
| 1096 | style: BarStyle().TipOnComplete(">"), | |
| 1097 | name: "t,c{60,60}trim", | |
| 1098 | total: 60, | |
| 1099 | current: 60, | |
| 1100 | trim: true, | |
| 1101 | want: "[=============================================================================>]", | |
| 1102 | }, | |
| 1103 | { | |
| 1104 | style: BarStyle().TipOnComplete(">"), | |
| 1105 | name: "t,c,bw{60,60,60}", | |
| 1106 | total: 60, | |
| 1107 | current: 60, | |
| 1108 | barWidth: 60, | |
| 1109 | want: " [=========================================================>] ", | |
| 1110 | }, | |
| 1111 | { | |
| 1112 | style: BarStyle().TipOnComplete(">"), | |
| 1113 | name: "t,c,bw{60,60,60}trim", | |
| 1114 | total: 60, | |
| 1115 | current: 60, | |
| 1116 | barWidth: 60, | |
| 1117 | trim: true, | |
| 1118 | want: "[=========================================================>]", | |
| 1119 | }, | |
| 580 | 1120 | }, |
| 581 | 1121 | 99: { |
| 582 | 1122 | { |
| 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: " […つつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつつだのの] ", | |
| 1123 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]"), | |
| 1124 | name: `t,c{100,99}Tip("だ").TipOnComplete("だ")`, | |
| 1125 | total: 100, | |
| 1126 | current: 99, | |
| 1127 | want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", | |
| 1128 | }, | |
| 1129 | { | |
| 1130 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]"), | |
| 1131 | name: `t,c{100,100}Tip("だ").TipOnComplete("だ")`, | |
| 1132 | total: 100, | |
| 1133 | current: 100, | |
| 1134 | want: " [ののののののののののののののののののののののののののののののののののののののののののののののだ…] ", | |
| 1135 | }, | |
| 1136 | { | |
| 1137 | style: BarStyle().Lbound("[").Filler("の").Tip("だ").TipOnComplete("だ").Padding("つ").Rbound("]").Reverse(), | |
| 1138 | name: `t,c{100,100}Tip("だ").TipOnComplete("だ")rev`, | |
| 1139 | total: 100, | |
| 1140 | current: 100, | |
| 1141 | want: " […だのののののののののののののののののののののののののののののののののののののののののののののの] ", | |
| 630 | 1142 | }, |
| 631 | 1143 | }, |
| 632 | 1144 | 100: { |
| 633 | 1145 | { |
| 1146 | style: BarStyle().TipOnComplete(">"), | |
| 634 | 1147 | name: "t,c{100,0}", |
| 635 | 1148 | total: 100, |
| 636 | 1149 | current: 0, |
| 637 | 1150 | want: " [------------------------------------------------------------------------------------------------] ", |
| 638 | 1151 | }, |
| 639 | 1152 | { |
| 1153 | style: BarStyle().TipOnComplete(">"), | |
| 640 | 1154 | name: "t,c{100,0}trim", |
| 641 | 1155 | total: 100, |
| 642 | 1156 | current: 0, |
| 644 | 1158 | want: "[--------------------------------------------------------------------------------------------------]", |
| 645 | 1159 | }, |
| 646 | 1160 | { |
| 1161 | style: BarStyle().TipOnComplete(">"), | |
| 647 | 1162 | name: "t,c{100,1}", |
| 648 | 1163 | total: 100, |
| 649 | 1164 | current: 1, |
| 650 | 1165 | want: " [>-----------------------------------------------------------------------------------------------] ", |
| 651 | 1166 | }, |
| 652 | 1167 | { |
| 1168 | style: BarStyle().TipOnComplete(">"), | |
| 653 | 1169 | name: "t,c{100,1}trim", |
| 654 | 1170 | total: 100, |
| 655 | 1171 | current: 1, |
| 657 | 1173 | want: "[>-------------------------------------------------------------------------------------------------]", |
| 658 | 1174 | }, |
| 659 | 1175 | { |
| 1176 | style: BarStyle().TipOnComplete(">"), | |
| 660 | 1177 | name: "t,c{100,99}", |
| 661 | 1178 | total: 100, |
| 662 | 1179 | current: 99, |
| 663 | 1180 | want: " [==============================================================================================>-] ", |
| 664 | 1181 | }, |
| 665 | 1182 | { |
| 1183 | style: BarStyle().TipOnComplete(">"), | |
| 666 | 1184 | name: "t,c{100,99}trim", |
| 667 | 1185 | total: 100, |
| 668 | 1186 | current: 99, |
| 670 | 1188 | want: "[================================================================================================>-]", |
| 671 | 1189 | }, |
| 672 | 1190 | { |
| 1191 | style: BarStyle().TipOnComplete(">"), | |
| 673 | 1192 | name: "t,c{100,100}", |
| 674 | 1193 | total: 100, |
| 675 | 1194 | current: 100, |
| 676 | 1195 | want: " [===============================================================================================>] ", |
| 677 | 1196 | }, |
| 678 | 1197 | { |
| 1198 | style: BarStyle().TipOnComplete(">"), | |
| 679 | 1199 | name: "t,c{100,100}trim", |
| 680 | 1200 | total: 100, |
| 681 | 1201 | current: 100, |
| 683 | 1203 | want: "[=================================================================================================>]", |
| 684 | 1204 | }, |
| 685 | 1205 | { |
| 1206 | style: BarStyle().TipOnComplete(">"), | |
| 1207 | name: "t,c,r{100,100,99}", | |
| 1208 | total: 100, | |
| 1209 | current: 100, | |
| 1210 | refill: 99, | |
| 1211 | want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>] ", | |
| 1212 | }, | |
| 1213 | { | |
| 1214 | style: BarStyle().TipOnComplete(">"), | |
| 1215 | name: "t,c,r{100,100,99}trim", | |
| 1216 | total: 100, | |
| 1217 | current: 100, | |
| 1218 | refill: 99, | |
| 1219 | trim: true, | |
| 1220 | want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>]", | |
| 1221 | }, | |
| 1222 | { | |
| 1223 | style: BarStyle().TipOnComplete(">"), | |
| 1224 | name: "t,c,r{100,100,100}", | |
| 1225 | total: 100, | |
| 1226 | current: 100, | |
| 1227 | refill: 100, | |
| 1228 | want: " [+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>] ", | |
| 1229 | }, | |
| 1230 | { | |
| 1231 | style: BarStyle().TipOnComplete(">"), | |
| 686 | 1232 | name: "t,c,r{100,100,100}trim", |
| 687 | 1233 | total: 100, |
| 688 | 1234 | current: 100, |
| 691 | 1237 | want: "[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>]", |
| 692 | 1238 | }, |
| 693 | 1239 | { |
| 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 | { | |
| 1240 | style: BarStyle().TipOnComplete("").Reverse(), | |
| 1241 | name: "t,c,r{100,100,99}rev", | |
| 1242 | total: 100, | |
| 1243 | current: 100, | |
| 1244 | refill: 99, | |
| 1245 | want: " [=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", | |
| 1246 | }, | |
| 1247 | { | |
| 1248 | style: BarStyle().TipOnComplete("").Reverse(), | |
| 1249 | name: "t,c,r{100,100,99}trim,rev", | |
| 1250 | total: 100, | |
| 1251 | current: 100, | |
| 1252 | refill: 99, | |
| 1253 | trim: true, | |
| 1254 | want: "[=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", | |
| 1255 | }, | |
| 1256 | { | |
| 1257 | style: BarStyle().TipOnComplete("").Reverse(), | |
| 1258 | name: "t,c,r{100,100,100}rev", | |
| 1259 | total: 100, | |
| 1260 | current: 100, | |
| 1261 | refill: 100, | |
| 1262 | want: " [++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++] ", | |
| 1263 | }, | |
| 1264 | { | |
| 1265 | style: BarStyle().TipOnComplete("").Reverse(), | |
| 1266 | name: "t,c,r{100,100,100}trim", | |
| 1267 | total: 100, | |
| 1268 | current: 100, | |
| 1269 | refill: 100, | |
| 1270 | trim: true, | |
| 1271 | want: "[++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]", | |
| 1272 | }, | |
| 1273 | { | |
| 1274 | style: BarStyle().TipOnComplete(">"), | |
| 739 | 1275 | name: "t,c,r{100,40,33}", |
| 740 | 1276 | total: 100, |
| 741 | 1277 | current: 40, |
| 743 | 1279 | want: " [++++++++++++++++++++++++++++++++=====>----------------------------------------------------------] ", |
| 744 | 1280 | }, |
| 745 | 1281 | { |
| 1282 | style: BarStyle().TipOnComplete(">"), | |
| 746 | 1283 | name: "t,c,r{100,40,33}trim", |
| 747 | 1284 | total: 100, |
| 748 | 1285 | current: 40, |
| 751 | 1288 | want: "[++++++++++++++++++++++++++++++++======>-----------------------------------------------------------]", |
| 752 | 1289 | }, |
| 753 | 1290 | { |
| 754 | style: BarStyle().Tip("<").Reverse(), | |
| 1291 | style: BarStyle().Tip("<").TipOnComplete("<").Reverse(), | |
| 755 | 1292 | name: "t,c,r{100,40,33},rev", |
| 756 | 1293 | total: 100, |
| 757 | 1294 | current: 40, |
| 759 | 1296 | want: " [----------------------------------------------------------<=====++++++++++++++++++++++++++++++++] ", |
| 760 | 1297 | }, |
| 761 | 1298 | { |
| 762 | style: BarStyle().Tip("<").Reverse(), | |
| 1299 | style: BarStyle().Tip("<").TipOnComplete("<").Reverse(), | |
| 763 | 1300 | name: "t,c,r{100,40,33}trim,rev", |
| 764 | 1301 | total: 100, |
| 765 | 1302 | current: 40, |
| 773 | 1310 | var tmpBuf bytes.Buffer |
| 774 | 1311 | for tw, cases := range testSuite { |
| 775 | 1312 | for _, tc := range cases { |
| 776 | if tc.style == nil { | |
| 777 | tc.style = BarStyle() | |
| 778 | } | |
| 779 | s := newTestState(NewBarFiller(tc.style.Inclusive(0))) | |
| 1313 | s := newTestState(NewBarFiller(tc.style)) | |
| 780 | 1314 | s.reqWidth = tc.barWidth |
| 781 | 1315 | s.total = tc.total |
| 782 | 1316 | s.current = tc.current |