fn test_convert_str_indices()

in starlark/src/values/types/string/fast_string.rs [289:345]


    fn test_convert_str_indices() {
        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "abc",
            }),
            convert_str_indices("abc", NoneOr::None, NoneOr::None)
        );
        assert_eq!(
            None,
            convert_str_indices("abc", NoneOr::Other(2), NoneOr::Other(1))
        );

        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "abc",
            }),
            convert_str_indices("abc", NoneOr::Other(-10), NoneOr::Other(10))
        );
        assert_eq!(
            Some(StrIndices {
                start: CharIndex(1),
                haystack: "",
            }),
            convert_str_indices("abc", NoneOr::Other(1), NoneOr::Other(1))
        );
        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "ab",
            }),
            convert_str_indices("abc", NoneOr::Other(-10), NoneOr::Other(2))
        );
        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "ab",
            }),
            convert_str_indices("abc", NoneOr::Other(-10), NoneOr::Other(-1))
        );

        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "s",
            }),
            convert_str_indices("short", NoneOr::Other(0), NoneOr::Other(-4))
        );
        assert_eq!(
            Some(StrIndices {
                start: CharIndex(0),
                haystack: "fish",
            }),
            convert_str_indices("fish", NoneOr::None, NoneOr::Other(10))
        );
    }