Files
love/testing/tests/system.lua
T
ell e03b2db08b 0.2
- Added tests for all obj creation, transformation, window + system info graphics methods
- Added half the state methods for graphics + added placeholders for missing drawing methods
- Added TestMethod:assertNotNil() for quick nil checking
- Added time total to the end of each module summary in console log to match file output

- Removed a bunch of unessecary nil checks
- Removed :release() from test methods, collectgarbage("collect") is called between methods instead

- Renamed /output to /examples to avoid confusion

- Replaced love.filesystem.newFile with love.filesystem.openFile
- Replaced love.math.noise with love.math.perlinNoise / love.math.simplexNoise

- Fixed newGearJoint throwing an error in 12 as body needs to be dynamic not static now

- Some general cleanup, incl. better comments and time format in file output
2023-10-05 23:03:32 +01:00

77 lines
2.3 KiB
Lua

-- love.system
-- love.system.getClipboardText
love.test.system.getClipboardText = function(test)
-- ignore if not using window
if love.test.windowmode == false then
return test:skipTest('clipboard only available in window mode')
end
-- check clipboard value is set
love.system.setClipboardText('helloworld')
test:assertEquals('helloworld', love.system.getClipboardText(), 'check clipboard match')
end
-- love.system.getOS
love.test.system.getOS = function(test)
-- check os is in documented values
local os = love.system.getOS()
local options = {'OS X', 'Windows', 'Linux', 'Android', 'iOS'}
test:assertMatch(options, os, 'check value matches')
end
-- love.system.getPowerInfo
love.test.system.getPowerInfo = function(test)
-- check battery state is one of the documented states
local state, percent, seconds = love.system.getPowerInfo()
local states = {'unknown', 'battery', 'nobattery', 'charging', 'charged'}
test:assertMatch(states, state, 'check value matches')
-- if percent/seconds check within expected range
if percent ~= nil then
test:assertRange(percent, 0, 100, 'check value within range')
end
if seconds ~= nil then
test:assertRange(seconds, 0, 100, 'check value within range')
end
end
-- love.system.getProcessorCount
love.test.system.getProcessorCount = function(test)
test:assertNotNil(love.system.getProcessorCount()) -- youd hope right
end
-- love.system.hasBackgroundMusic
love.test.system.hasBackgroundMusic = function(test)
test:assertNotNil(love.system.hasBackgroundMusic())
end
-- love.system.openURL
love.test.system.openURL = function(test)
test:skipTest('cant test this worked')
--test:assertNotEquals(nil, love.system.openURL('https://love2d.org'), 'check open URL')
end
-- love.system.getClipboardText
love.test.system.setClipboardText = function(test)
-- ignore if not using window
if love.test.windowmode == false then
return test:skipTest('clipboard only available in window mode')
end
-- check value returned is what was set
love.system.setClipboardText('helloworld')
test:assertEquals('helloworld', love.system.getClipboardText(), 'check set text')
end
-- love.system.vibrate
-- @NOTE cant really test this
love.test.system.vibrate = function(test)
test:skipTest('cant test this worked')
end