Some checks failed
release / linux/x86_64 (pull_request) Failing after 1m54s
release / freebsd/x86_64 (pull_request) Successful in 5m1s
release / linux/aarch64 (pull_request) Failing after 1m54s
release / linux/armv7 (pull_request) Failing after 2m12s
release / linux/i686 (pull_request) Failing after 1m59s
release / android (pull_request) Successful in 2m54s
release / windows/i686 (pull_request) Successful in 2m3s
release / windows/x86_64 (pull_request) Successful in 2m15s
37 lines
1.2 KiB
Lua
37 lines
1.2 KiB
Lua
-- 07: inout Image parameters mutate the caller's cdata in place, and the
|
|
-- wrapper returns that same object so the GC sees exactly one owner.
|
|
local M = dofile("tests/helpers.lua")
|
|
local R = M.load()
|
|
|
|
M.reset()
|
|
local b = M.snapshot()
|
|
|
|
local rgba = R.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
|
|
local gray = R.PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
|
|
|
|
local img = R.GenImageColor(4, 4, R.RED)
|
|
M.eq(img.format, rgba, "GenImageColor produced RGBA")
|
|
|
|
local out = R.ImageFormat(img, gray)
|
|
M.ok(rawequal(out, img), "ImageFormat returned the caller's cdata")
|
|
M.eq(img.format, gray, "ImageFormat mutated the cdata")
|
|
|
|
img = nil
|
|
out = nil
|
|
M.gc(3)
|
|
M.eq(M.delta(b, "released"), 1, "ImageFormat did not create a second owner")
|
|
M.eq(M.delta(b, "errors"), 0, "no finalizer errors")
|
|
|
|
local img2 = R.GenImageColor(4, 4, R.RED)
|
|
local resized = R.ImageResize(img2, 2, 2)
|
|
M.ok(rawequal(resized, img2), "ImageResize returned the caller's cdata")
|
|
M.eq(img2.width, 2, "ImageResize width")
|
|
M.eq(img2.height, 2, "ImageResize height")
|
|
|
|
img2 = nil
|
|
resized = nil
|
|
M.gc(3)
|
|
M.eq(M.delta(b, "released"), 2, "ImageResize did not create a second owner")
|
|
M.eq(M.delta(b, "errors"), 0, "no finalizer errors after resize")
|
|
|
|
print("ok 07_inout")
|