Exhaustive check for all ints from 0 to 1112060 for correctness of implementation of `intToRune() -> runeToInt()`. This test is slow and runs longer than 5 seconds but it does provide a safety guarantee that these 2 functions are correct for the ranges we support.
(t *testing.T)
| 120 | // This test is slow and runs longer than 5 seconds but it does provide a safety |
| 121 | // guarantee that these 2 functions are correct for the ranges we support. |
| 122 | func TestRuneToInt(t *testing.T) { |
| 123 | |
| 124 | for i := uint32(0); i <= UNICODE_RANGE_MAX-UNICODE_INVALID_RANGE_DELTA-3; i += 1 { |
| 125 | r := intToRune(i) |
| 126 | ic := runeToInt(r) |
| 127 | |
| 128 | assert.Equal(t, i, ic, fmt.Sprintf("intToRune(%d)=%d and runeToInt(%d)=%d", i, r, r, ic)) |
| 129 | } |
| 130 | |
| 131 | assert.Panics(t, func() { |
| 132 | intToRune(UNICODE_RANGE_MAX - UNICODE_INVALID_RANGE_DELTA - 2) |
| 133 | }) |
| 134 | } |
| 135 | |
| 136 | func TestIntToRuneLimit(t *testing.T) { |
| 137 | // DiffLinesToChars and DiffLinesToRunes can encode at most 1,112,060 |