Skip to content

Commit

Permalink
more buffer view tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Jun 4, 2016
1 parent 9cee892 commit fcab063
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_buffer.exp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ vec4(503, 603, 703, 803)
0
3
4
[0, 5, 5, 4]
[0, 5, 5, 0]
[0, 7, 8, 0]
[0, 7, 8, 0]
[0, 1, 2, 0]
vec3(1, 2, 3)
vec3(4, 5, 6)
vec3(6, 7, 8)
Expand Down
26 changes: 25 additions & 1 deletion tests/test_buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ function printv_and_restore(view, index, val)
view[index] = old
end

local
function print_view(view)
str = "["
for i = 1, #view do
str = str..view[i]
if i == #view then
str = str.."]"
else
str = str..", "
end
end
print(str)
end

local n = 10000
local buf = am.buffer(4 * n)
local view = buf:view("float")
Expand Down Expand Up @@ -140,10 +154,20 @@ for _, vs in ipairs({{viewub, viewubn}, {viewushort, viewushortn}, {viewshort, v
end

local settest1 = am.float_array({1, 2, 3, 4})
settest1:set(0, 1, 2)
settest1:set(0, 1, 2) -- 0 0 3 4
for i = 1, 4 do
print(settest1[i])
end
settest1:set({5, 5}, 2) -- 0 5 5 4
print_view(settest1)
settest1:set(settest1, 4) -- 0 5 5 0
print_view(settest1)
settest1:set({7, 8, 9}, 2, 2) -- 0 7 8 0
print_view(settest1)
settest1:set(settest1, 1, 0) -- 0 7 8 0
print_view(settest1)
settest1:set(am.float_array{1, 2, 3, 4}, 2, 2) -- 0 1 2 0
print_view(settest1)

local setvec = am.vec3_array({1, 2, 3, 4, 5, 6})
printvec(setvec[1])
Expand Down

0 comments on commit fcab063

Please sign in to comment.