+5
-5
src/Golomb.zig
+5
-5
src/Golomb.zig
···
187
return (value & (value - 1)) == 0;
188
}
189
190
-
test "encode val = 42, m = 8" {
191
const testing = std.testing;
192
193
var gol = Self{ .m = 8 };
···
197
try testing.expectEqualSlices(u8, &.{50}, &encoded);
198
}
199
200
-
test "decode val = {50}, m = 8" {
201
const testing = std.testing;
202
203
var gol = Self{ .m = 8 };
···
207
try testing.expectEqual(42, decoded);
208
}
209
210
-
test "encode + decode val = 1564, m = 457" {
211
const testing = std.testing;
212
213
var gol = Self{ .m = 457 };
···
225
try testing.expectEqual(input, decoded);
226
}
227
228
-
test "encode multiple val = { 1564, 42 }, m = 457" {
229
const testing = std.testing;
230
231
var gol = Self{ .m = 457 };
···
238
try testing.expectEqualSlices(u8, &.{ 35, 6, 42 }, &encoded);
239
}
240
241
-
test "decode multiple val = { 35, 6, 8 }, m = 457" {
242
const testing = std.testing;
243
244
var gol = Self{ .m = 457 };
···
187
return (value & (value - 1)) == 0;
188
}
189
190
+
test "golomb.encode val = 42, m = 8" {
191
const testing = std.testing;
192
193
var gol = Self{ .m = 8 };
···
197
try testing.expectEqualSlices(u8, &.{50}, &encoded);
198
}
199
200
+
test "golomb.decode val = {50}, m = 8" {
201
const testing = std.testing;
202
203
var gol = Self{ .m = 8 };
···
207
try testing.expectEqual(42, decoded);
208
}
209
210
+
test "golomb.encode + decode val = 1564, m = 457" {
211
const testing = std.testing;
212
213
var gol = Self{ .m = 457 };
···
225
try testing.expectEqual(input, decoded);
226
}
227
228
+
test "golomb.encode multiple val = { 1564, 42 }, m = 457" {
229
const testing = std.testing;
230
231
var gol = Self{ .m = 457 };
···
238
try testing.expectEqualSlices(u8, &.{ 35, 6, 42 }, &encoded);
239
}
240
241
+
test "golomb.decode multiple val = { 35, 6, 8 }, m = 457" {
242
const testing = std.testing;
243
244
var gol = Self{ .m = 457 };