File: test_table.lua

package info (click to toggle)
premake4 4.3%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,852 kB
  • sloc: ansic: 636; makefile: 57; sh: 2
file content (57 lines) | stat: -rw-r--r-- 1,035 bytes parent folder | download | duplicates (9)
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
--
-- tests/base/test_table.lua
-- Automated test suite for the new table functions.
-- Copyright (c) 2008-2010 Jason Perkins and the Premake project
--


	T.table = { }
	local suite = T.table


--
-- table.contains() tests
--

	function suite.contains_OnContained()
		t = { "one", "two", "three" }
		test.istrue( table.contains(t, "two") )
	end

	function suite.contains_OnNotContained()
		t = { "one", "two", "three" }
		test.isfalse( table.contains(t, "four") )
	end


--
-- table.flatten() tests
--

	function suite.flatten_OnMixedValues()
		t = { "a", { "b", "c" }, "d" }
		test.isequal({ "a", "b", "c", "d" }, table.flatten(t))
	end


--
-- table.implode() tests
--

	function suite.implode()
		t = { "one", "two", "three", "four" }
		test.isequal("[one], [two], [three], [four]", table.implode(t, "[", "]", ", "))
	end


--
-- table.isempty() tests
--

	function suite.isempty_ReturnsTrueOnEmpty()
		test.istrue(table.isempty({}))
	end

	function suite.isempty_ReturnsFalseOnNotEmpty()
		test.isfalse(table.isempty({ 1 }))
	end