vile / scheme / transcoded_fractional_boundary_test.v
20 lines · 18 sloc · 701 bytes · 76646891b77a3d5c6af4a1e42b122cd61dc1654b
Raw
1module scheme
2
3import os
4import rand
5
6// A three-byte facade scalar occupies only two bytes in the raw UTF16 stream.
7fn test_utf16_quoted_three_byte_scalar_requires_retaining_partial_boundary() {
8 path := os.join_path(os.vtmp_dir(), 'vile-fractional-negative-' + rand.ulid())
9 defer { os.rm(path) or {} }
10 os.write_file_array(path, [u8(0xfe), 0xff, 0, 34, 9, 5, 0, 34, 0, 66]) or { panic(err.msg()) }
11 mut vm := new()
12 p := vm.open_file_input_output_port(path,
13 no_create: true
14 no_truncate: true
15 buffer_mode: .none
16 transcoder: transcoder_value(.utf16, .none, .raise)
17 ) or { panic(err.msg()) }
18 defer { vm.close_port(p) or {} }
19 assert (vm.read(p) or { panic(err.msg()) }).text() == 'अ'
20}
21