Test padding and fixed width methods
()
| 414 | |
| 415 | /** Test padding and fixed width methods */ |
| 416 | @Test |
| 417 | public void paddingTest () { |
| 418 | CharArray array = new CharArray(); |
| 419 | |
| 420 | // Append padding |
| 421 | array.append("Hello"); |
| 422 | array.appendPadding(5, '*'); |
| 423 | Assert.assertEquals("Hello*****", array.toString()); |
| 424 | array.clear(); |
| 425 | |
| 426 | // Fixed width pad left |
| 427 | array.appendFixedWidthPadLeft("42", 5, '0'); |
| 428 | Assert.assertEquals("00042", array.toString()); |
| 429 | array.clear(); |
| 430 | |
| 431 | array.appendFixedWidthPadLeft("12345", 3, '0'); |
| 432 | Assert.assertEquals("345", array.toString()); // Keeps rightmost chars when too long |
| 433 | array.clear(); |
| 434 | |
| 435 | // Fixed width pad right |
| 436 | array.appendFixedWidthPadRight("Hi", 5, ' '); |
| 437 | Assert.assertEquals("Hi ", array.toString()); |
| 438 | array.clear(); |
| 439 | } |
| 440 | |
| 441 | /** Test delete methods */ |
| 442 | @Test |
nothing calls this directly
no test coverage detected