Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › unicode.zig › testRoundtripWtf16
testRoundtripWtf16
unicode.testRoundtripWtf16
fn testRoundtripWtf16 (wtf16le : []const u16 ) !void
File
Code
fn testRoundtripWtf16 (wtf16le : []const u16 ) !void {
{
var wtf8_buf : [32 ]u8 = undefined ;
const wtf8_len = wtf16LeToWtf8 (&wtf8_buf , wtf16le );
const wtf8 = wtf8_buf [0 ..wtf8_len ];
var roundtripped_buf : [32 ]u16 = undefined ;
const roundtripped_len = try wtf8ToWtf16Le (&roundtripped_buf , wtf8 );
const roundtripped = roundtripped_buf [0 ..roundtripped_len ];
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
{
const wtf8 = try wtf16LeToWtf8Alloc (testing .allocator , wtf16le );
defer testing .allocator .free (wtf8 );
const roundtripped = try wtf8ToWtf16LeAlloc (testing .allocator , wtf8 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
{
const wtf8 = try wtf16LeToWtf8AllocZ (testing .allocator , wtf16le );
defer testing .allocator .free (wtf8 );
const roundtripped = try wtf8ToWtf16LeAllocZ (testing .allocator , wtf8 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u16 , wtf16le , roundtripped );
}
}