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/ › crypto/ › blake3.zig › testBlake3
testBlake3
blake3.testBlake3
fn testBlake3 (hasher : *Blake3 , input_len : usize , expected_hex : [262 ]u8 ) !void
File
Code
fn testBlake3 (hasher : *Blake3 , input_len : usize , expected_hex : [262 ]u8 ) !void {
const initial_state = hasher .*;
var input_pattern : [251 ]u8 = undefined ;
for (&input_pattern , 0 ..) |*e , i | e .* = @as (u8 , @truncate (i ));
var input_counter = input_len ;
while (input_counter > 0 ) {
const update_len = @min (input_counter , input_pattern .len );
hasher .update (input_pattern [0 ..update_len ]);
input_counter -= update_len ;
}
var actual_bytes : [expected_hex .len / 2 ]u8 = undefined ;
hasher .final (actual_bytes [0 ..]);
var expected_bytes : [expected_hex .len / 2 ]u8 = undefined ;
_ = fmt .hexToBytes (expected_bytes [0 ..], expected_hex [0 ..]) catch unreachable ;
try std .testing .expectEqual (actual_bytes , expected_bytes );
hasher .* = initial_state ;
}