๐Ÿ“ฆ RobLoach / raylib-lua-sol

๐Ÿ“„ raylib-lua-sol-tests.lua ยท 58 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58local function describe(name, descriptor)
  local errors = {}
  local successes = {}
  function it(spec_line, spec)
    local status = xpcall(spec, function (err)
      table.insert(errors, string.format("\t%s\n\t\t%s\n", spec_line, err))
    end)
    if status then
      table.insert(successes, string.format("\t%s\n", spec_line))
    end
  end
  local status = xpcall(descriptor, function (err)
    table.insert(errors, err)
  end, it)
  print(name)
  if #successes > 0 then
    print('Successes:')
    print(table.concat(successes))
  end
  if #errors > 0 then
    print('Failures:')
    print(table.concat(errors))
    TraceLog(LOG_ERROR, 'Error count: ' .. #errors)
  end
end

describe('raylib-lua-sol Tests', function (it)
  it('Functions', function()
    assert(IsWindowFullscreen() == false, 'IsWindowFullscreen() should be false')
    assert(GetFileExtension('something.lua') == '.lua', 'GetFileExtension("something.lua") should return "lua"')
  end)

  it('Enumerations', function ()
    assert(FLAG_FULLSCREEN_MODE == 2, "FLAG_FULLSCREEN_MODE should equal 2")
  end)

  it('Structs', function ()
    local rect = Rectangle(10, 20, 30, 40)
    assert(rect.width == 30, "Rectangle width should be 30")
    rect.width = 500
    assert(rect.width == 500, "Rectangle width should be 500")

    local vec = Vector2(30, 40)
    assert(vec.x == 30)
  end)

  it ('Color', function ()
    assert(RAYWHITE.r == 245, "RAYWHITE should have 245 red")

    local c = Color(100, 100, 100, 255)
    assert(c.g == 100, "c.g should be 100")
  end)

  it('rlgl', function ()
    assert(MAX_MATERIAL_MAPS == 12, "MAX_MATERIAL_MAPS should be 12")
  end)
end)