fn test_casing_assumptions()

in components/places/src/match_impl.rs [458:520]


    fn test_casing_assumptions() {
        use std::char;
        // Verify the assertion in next_search_candidate that the
        // only non-ASCII characters that lower-case to ASCII ones are:
        //  * U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE
        //  * U+212A KELVIN SIGN
        //
        // It also checks that U+0130 is the only single codepoint that lower cases
        // to multiple characters.
        for c in 128..0x11_0000 {
            if let Some(ch) = char::from_u32(c) {
                // Not quite the same (because codepoints aren't characters), but
                // should serve the same purpose.
                let mut li = ch.to_lowercase();
                let lc = li.next().unwrap();
                if c != 304 && c != 8490 {
                    assert!(
                        (lc as u32) >= 128,
                        "Lower case of non-ascii '{}' ({}) was unexpectedly ascii",
                        ch,
                        c
                    );
                    // This one we added (it's an implicit assumption in the utilities the
                    // places code uses).
                    assert!(
                        li.next().is_none(),
                        "Lower case of '{}' ({}) produced multiple codepoints unexpectedly",
                        ch,
                        c
                    );
                } else {
                    assert!(
                        (lc as u32) < 128,
                        "Lower case of non-ascii '{}' ({}) was unexpectedly not ascii",
                        ch,
                        c
                    );
                }
            }
        }

        // Verify the assertion that all ASCII characters lower-case to ASCII.
        for c in 0..128 {
            let ch = char::from_u32(c).unwrap();
            let mut li = ch.to_lowercase();
            let lc = li.next().unwrap();
            assert!(
                li.next().is_none() && (lc as u32) < 128,
                "Lower case of ascii '{}' ({}) wasn't ascii :(",
                ch,
                c
            );
        }

        for c in (b'a'..=b'z').chain(b'A'..=b'Z') {
            assert_eq!(
                dubious_to_ascii_lower(c),
                c.to_ascii_lowercase(),
                "c: '{}'",
                c as char
            );
        }
    }