tests/core: comments: specs only
This commit is contained in:
1 parent
e23adf2a2d
commit
53aa9a6ebf
4 files changed
+3
-24
No files matched your search
+1
-10
@@ -1,6 +1,4 @@
|
||||
-- core/Bytes, core/Err, core/Crc32, core/Adler32, core/Input tests: every Reader / Writer method both endians, the
|
||||
-- sticky TRUNCATED error (never a throw), sub-readers without copies, Writer growth and patching, Bytes.span, the
|
||||
-- MSB-first CRC-32 (MPEG-2 / bzip2 check values).
|
||||
-- core/Bytes, Err, Crc32, Adler32 and Input tests.
|
||||
local T = require("@tests/T")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -10,7 +8,6 @@ local Input = require("@rosetta/core/Input")
|
||||
|
||||
local t = T.suite("bytes")
|
||||
|
||||
-- Writer -> Reader round trip of every type
|
||||
do
|
||||
local w = Bytes.writer(4) -- grows
|
||||
w:u8(0xAB)
|
||||
@@ -97,7 +94,6 @@ do
|
||||
local nilv, e = r4:fail(Err.CORRUPT, "bad thing")
|
||||
t:check(nilv == nil and e.code == Err.CORRUPT and tostring(e) == "CORRUPT at 0x0: bad thing", "fail(): " .. tostring(e))
|
||||
t:check(not r4:need(5) and r4.err == e, "need keeps the first error")
|
||||
-- every method on an empty reader: no throw
|
||||
local empty = Bytes.reader(buffer.create(0))
|
||||
for _, m in { "u8", "i8", "u16le", "u16be", "i16le", "i16be", "u24le", "u24be", "u32le", "u32be", "i32le", "i32be", "u64le", "u64be", "i64le", "i64be", "f16le", "f16be", "f32le", "f32be", "f64le", "f64be", "cstring" } do
|
||||
local ok, v = pcall((Bytes.Reader :: any)[m], empty)
|
||||
@@ -113,7 +109,6 @@ do
|
||||
t:check(ok, "string / bytes / slice / skip / align on an empty reader")
|
||||
end
|
||||
|
||||
-- ranges, sub-readers, peek, match
|
||||
do
|
||||
local buf = buffer.fromstring("0123456789")
|
||||
local r = Bytes.reader(buf, 2, 5) -- "23456"
|
||||
@@ -141,7 +136,6 @@ do
|
||||
t:check(a:align(4) and a:tell() == 4, "align")
|
||||
end
|
||||
|
||||
-- checksums
|
||||
do
|
||||
t:eq(Crc32.string("123456789"), 0xCBF43926, "crc32 check value")
|
||||
t:eq(Crc32.of(buffer.fromstring("xx123456789yy"), 2, 9), 0xCBF43926, "crc32 range")
|
||||
@@ -151,7 +145,6 @@ do
|
||||
t:eq(Adler32.string("pedia", Adler32.string("Wiki")), 0x11E60398, "adler32 continuation")
|
||||
end
|
||||
|
||||
-- Input (without a host)
|
||||
do
|
||||
local b = buffer.create(3)
|
||||
t:check(Input.resolve(b) == b, "a buffer passes through")
|
||||
@@ -173,7 +166,6 @@ do
|
||||
t:eq(buffer.tostring(db :: buffer), "img.png", "opts.data forces data")
|
||||
end
|
||||
|
||||
-- Err
|
||||
do
|
||||
local e = Err.new(Err.CORRUPT, "bad", 16)
|
||||
t:check(Err.is(e) and not Err.is({}) and not Err.is("x"), "Err.is")
|
||||
@@ -182,7 +174,6 @@ do
|
||||
t:check(w.code == Err.CORRUPT and w.format == "gif", "wrap a string")
|
||||
end
|
||||
|
||||
-- Bytes.span: codec argument checking
|
||||
do
|
||||
local b, o, n = Bytes.span("x", "hello", 1, 10)
|
||||
t:check(type(b) == "buffer" and o == 1 and n == 4, "span clamps the length")
|
||||
|
||||
Reference in new issue
Block a user