Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_string.lua « tests - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d22713c59fdff76c6c3b9bf742f82c7958267acf (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--
-- tests/test_string.lua
-- Automated test suite for the new string functions.
-- Copyright (c) 2008 Jason Perkins and the Premake project
--


	T.string = { }


--
-- string.endswith() tests
--

	function T.string.endswith_ReturnsTrue_OnMatch()
		test.istrue(string.endswith("Abcdef", "def"))
	end

	function T.string.endswith_ReturnsFalse_OnMismatch()
		test.isfalse(string.endswith("Abcedf", "efg"))
	end
	
	function T.string.endswith_ReturnsFalse_OnLongerNeedle()
		test.isfalse(string.endswith("Abc", "Abcdef"))
	end
	
	function T.string.endswith_ReturnsFalse_OnNilHaystack()
		test.isfalse(string.endswith(nil, "ghi"))
	end

	function T.string.endswith_ReturnsFalse_OnNilNeedle()
		test.isfalse(string.endswith("Abc", nil))
	end
	
	function T.string.endswith_ReturnsTrue_OnExactMatch()
		test.istrue(string.endswith("/", "/"))
	end



--
-- string.explode() tests
--

	function T.string.explode_ReturnsParts_OnValidCall()
		test.isequal({"aaa","bbb","ccc"}, string.explode("aaa/bbb/ccc", "/", true))
	end



--
-- string.startswith() tests
--

	function T.string.startswith_OnMatch()
		test.istrue(string.startswith("Abcdef", "Abc"))
	end

	function T.string.startswith_OnMismatch()
		test.isfalse(string.startswith("Abcdef", "ghi"))
	end

	function T.string.startswith_OnLongerNeedle()
		test.isfalse(string.startswith("Abc", "Abcdef"))
	end

	function T.string.startswith_OnEmptyHaystack()
		test.isfalse(string.startswith("", "Abc"))
	end

	function T.string.startswith_OnEmptyNeedle()
		test.istrue(string.startswith("Abcdef", ""))
	end