MCPcopy Create free account
hub / github.com/sergi/go-diff / TestRuneToInt

Function TestRuneToInt

diffmatchpatch/stringutil_test.go:122–134  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
122func 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}

Callers

nothing calls this directly

Calls 2

intToRuneFunction · 0.85
runeToIntFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…