mirror of
https://github.com/ziglang/zig.git
synced 2026-02-06 14:37:04 +00:00
std: Fix broken tests
This commit is contained in:
parent
4ab13a359d
commit
2f1052a313
@ -350,12 +350,18 @@ pub fn BitInStream(endian: builtin.Endian, comptime Error: type) type {
|
||||
switch (endian) {
|
||||
.Big => {
|
||||
out_buffer = @as(Buf, self.bit_buffer >> shift);
|
||||
self.bit_buffer <<= n;
|
||||
if (n >= u7_bit_count)
|
||||
self.bit_buffer = 0
|
||||
else
|
||||
self.bit_buffer <<= n;
|
||||
},
|
||||
.Little => {
|
||||
const value = (self.bit_buffer << shift) >> shift;
|
||||
out_buffer = @as(Buf, value);
|
||||
self.bit_buffer >>= n;
|
||||
if (n >= u7_bit_count)
|
||||
self.bit_buffer = 0
|
||||
else
|
||||
self.bit_buffer >>= n;
|
||||
},
|
||||
}
|
||||
self.bit_count -= n;
|
||||
|
||||
@ -921,6 +921,9 @@ pub fn writeInt(comptime T: type, buffer: *[@divExact(T.bit_count, 8)]u8, value:
|
||||
pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
|
||||
assert(buffer.len >= @divExact(T.bit_count, 8));
|
||||
|
||||
if (T.bit_count == 0)
|
||||
return set(u8, buffer, 0);
|
||||
|
||||
// TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough
|
||||
const uint = std.meta.IntType(false, T.bit_count);
|
||||
var bits = @truncate(uint, value);
|
||||
@ -938,6 +941,9 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
|
||||
pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
|
||||
assert(buffer.len >= @divExact(T.bit_count, 8));
|
||||
|
||||
if (T.bit_count == 0)
|
||||
return set(u8, buffer, 0);
|
||||
|
||||
// TODO I want to call writeIntBig here but comptime eval facilities aren't good enough
|
||||
const uint = std.meta.IntType(false, T.bit_count);
|
||||
var bits = @truncate(uint, value);
|
||||
@ -1807,7 +1813,7 @@ test "sliceAsBytes" {
|
||||
}
|
||||
|
||||
test "sliceAsBytes with sentinel slice" {
|
||||
const empty_string:[:0]const u8 = "";
|
||||
const empty_string: [:0]const u8 = "";
|
||||
const bytes = sliceAsBytes(empty_string);
|
||||
testing.expect(bytes.len == 0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user