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 › testRoundtripWtf8
testRoundtripWtf8
unicode.testRoundtripWtf8
fn testRoundtripWtf8 (wtf8 : []const u8 ) !void
File
Code
fn testRoundtripWtf8 (wtf8 : []const u8 ) !void {
{
var wtf16_buf : [32 ]u16 = undefined ;
const wtf16_len = try wtf8ToWtf16Le (&wtf16_buf , wtf8 );
try testing .expectEqual (wtf16_len , calcWtf16LeLen (wtf8 ));
const wtf16 = wtf16_buf [0 ..wtf16_len ];
var roundtripped_buf : [32 ]u8 = undefined ;
const roundtripped_len = wtf16LeToWtf8 (&roundtripped_buf , wtf16 );
const roundtripped = roundtripped_buf [0 ..roundtripped_len ];
try testing .expectEqualSlices (u8 , wtf8 , roundtripped );
}
{
const wtf16 = try wtf8ToWtf16LeAlloc (testing .allocator , wtf8 );
defer testing .allocator .free (wtf16 );
const roundtripped = try wtf16LeToWtf8Alloc (testing .allocator , wtf16 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u8 , wtf8 , roundtripped );
}
{
const wtf16 = try wtf8ToWtf16LeAllocZ (testing .allocator , wtf8 );
defer testing .allocator .free (wtf16 );
const roundtripped = try wtf16LeToWtf8AllocZ (testing .allocator , wtf16 );
defer testing .allocator .free (roundtripped );
try testing .expectEqualSlices (u8 , wtf8 , roundtripped );
}
}