Skip to content

Commit

Permalink
Extend cdata_var test slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
corsix committed Oct 12, 2016
1 parent 071f050 commit bcf938b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/lib/ffi/cdata_var.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local ffi = require("ffi")

do --- byte array allocations
local typ = ffi.typeof"uint8_t[?]"
for i = 4, 20 do
for d = -3, 3 do
for i = 4, 24 do
for d = -5, 5 do
local sz = 2^i + d
assert(ffi.sizeof(typ, sz) == sz)
local mem = ffi.new(typ, sz)
Expand All @@ -17,6 +17,8 @@ do --- byte array allocations
assert(mem[0] == 0x21)
assert(mem[1] == 0x32)
assert(mem[2] == 0x43)
assert(mem[3] == 0)
assert(mem[sz-4] == 0)
assert(mem[sz-3] == 0x54)
assert(mem[sz-2] == 0x65)
assert(mem[sz-1] == 0x76)
Expand All @@ -35,6 +37,10 @@ do --- int array allocations
mem[0] = -3
mem[sz-1] = -4
assert(mem[0] == -3)
if sz ~= 2 then
assert(mem[1] == 0)
assert(mem[sz-2] == 0)
end
assert(mem[sz-1] == -4)
end
end
Expand Down

0 comments on commit bcf938b

Please sign in to comment.