|
| 1 | +from capirca.lib.aclgenerator import WrapWords |
| 2 | +import pytest |
| 3 | + |
| 4 | +SINGLE_LINE_OVERFLOW_TEXT_LONG = \ |
| 5 | + "http://github.com/google/capirca/commit/c5" + \ |
| 6 | + "6ddf19e2679892ff078cf27aeb18310c2697ed This " + \ |
| 7 | + "is a long header. It's long on purpose. It's " + \ |
| 8 | + "purpose is to test that the splitting works co" + \ |
| 9 | + "rrectly. It should be well over the line limit" + \ |
| 10 | + ". If it is shorter, it would not test the limit." |
| 11 | + |
| 12 | +SINGLE_LINE_OVERFLOW_TEXT_LONG_EXPECTED = [ |
| 13 | + "http://github.com/google/capirca/commit/c56ddf19e2679892ff078cf27aeb18", |
| 14 | + "310c2697ed", |
| 15 | + "This is a long header. It's long on purpose. It's purpose is to test", |
| 16 | + "that the splitting works correctly. It should be well over the line", |
| 17 | + "limit. If it is shorter, it would not test the limit." |
| 18 | +] |
| 19 | + |
| 20 | +MULTI_LINE_OVERFLOW_TEXT_LONG = \ |
| 21 | + "this is a veryveryveryveryveryveryveryveryver" + \ |
| 22 | + "yveryveryveryveryveryveryveryveryveryveryvery" + \ |
| 23 | + "veryveryveryveryveryveryveryveryveryveryveryv" + \ |
| 24 | + "eryveryveryveryveryveryveryveryveryveryvery long word" |
| 25 | + |
| 26 | +MULTI_LINE_OVERFLOW_TEXT_LONG_EXPECTED = [ |
| 27 | + "this is a", |
| 28 | + "veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryve", |
| 29 | + "ryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryvery", |
| 30 | + "veryveryveryveryveryveryvery", |
| 31 | + "long word" |
| 32 | +] |
| 33 | + |
| 34 | +NO_OVERFLOW_LONG = \ |
| 35 | + "This " + \ |
| 36 | + "is a long header. It's long on purpose. It's " + \ |
| 37 | + "purpose is to test that the splitting works co" + \ |
| 38 | + "rrectly. It should be well over the line limit" + \ |
| 39 | + ". If it is shorter, it would not test the limit." |
| 40 | + |
| 41 | +NO_OVERFLOW_LONG_EXPECTED = [ |
| 42 | + "This is a long header. It's long on purpose. It's purpose is to test", |
| 43 | + "that the splitting works correctly. It should be well over the line", |
| 44 | + "limit. If it is shorter, it would not test the limit." |
| 45 | +] |
| 46 | + |
| 47 | +NO_OVERFLOW_SHORT = \ |
| 48 | + "This is a short line of text" |
| 49 | + |
| 50 | +NO_OVERFLOW_SHORT_EXPECTED = [ |
| 51 | + "This is a short line of text" |
| 52 | +] |
| 53 | + |
| 54 | +@pytest.mark.parametrize("test_input,expected", [ |
| 55 | + (NO_OVERFLOW_SHORT, NO_OVERFLOW_SHORT_EXPECTED), |
| 56 | + (NO_OVERFLOW_LONG, NO_OVERFLOW_LONG_EXPECTED), |
| 57 | + (SINGLE_LINE_OVERFLOW_TEXT_LONG, SINGLE_LINE_OVERFLOW_TEXT_LONG_EXPECTED), |
| 58 | + (MULTI_LINE_OVERFLOW_TEXT_LONG, MULTI_LINE_OVERFLOW_TEXT_LONG_EXPECTED) |
| 59 | +] |
| 60 | + ) |
| 61 | + |
| 62 | + |
| 63 | +def testWrapWords(test_input, expected): |
| 64 | + result = WrapWords([test_input], 70) |
| 65 | + assert all((res == exp for res, exp in zip(result, expected))) |
0 commit comments