okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
12c65e6
main
1//// Scalar and grapheme limits differ on combining marks. E2E cannot inspect 2//// retained binary size or exhaust exact slicing boundaries deterministically. 3 4import albedo/daemon/session_configuration 5import albedo/text_scalars 6import gleam/option .{ Some } 7import gleam/string 8import gleeunit/should 9 10@external ( erlang , "albedo_text_scalars_test_support" , "referenced_size" ) 11fn referenced_size ( text : String ) -> Int 12 13pub fn scalar_slices_preserve_combining_marks_and_utf8_boundaries_test () -> Nil { 14let text = "a\u{0301}😀z" 15text_scalars . length ( text ) |> should . equal ( 4 ) 16text_scalars . take ( text , 2 ) |> should . equal ( "a\u{0301}" ) 17text_scalars . drop ( text , 2 ) |> should . equal ( "😀z" ) 18text_scalars . tail ( text , 2 ) |> should . equal ( "😀z" ) 19text_scalars . take ( text , - 1 ) |> should . equal ( "" ) 20text_scalars . drop ( text , - 1 ) |> should . equal ( text ) 21text_scalars . tail ( text , - 1 ) |> should . equal ( "" ) 22text_scalars . drop ( text , 10 ) |> should . equal ( "" ) 23text_scalars . take ( "" , 2 ) |> should . equal ( "" ) 24let large = string . repeat ( "😀" , 100_000 ) 25let prefix = text_scalars . take ( large , 1 ) 26let suffix = text_scalars . tail ( large , 1 ) 27referenced_size ( prefix ) |> should . equal ( 4 ) 28referenced_size ( suffix ) |> should . equal ( 4 ) 29} 30 31pub fn names_mask_controls_and_limit_scalars_without_splitting_marks_test () -> Nil { 32session_configuration . clean_name ( 33" a\u{0000}\u{0085}\u{00AD}\u{200B}\u{200E}\u{2028}\u{2060}\u{FEFF} b " , 34) 35|> should . equal ( Some ( "a b" )) 36let text = "x" <> string . repeat ( "\u{0301}" , 5000 ) 37let assert Some ( clean ) = session_configuration . clean_name ( text ) 38text_scalars . length ( clean ) |> should . equal ( 4096 ) 39clean |> should . equal ( "x" <> string . repeat ( "\u{0301}" , 4095 )) 40}