diff options
| author | OpportunityLiu <[email protected]> | 2019-06-08 13:34:02 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-06-08 13:34:02 +0800 |
| commit | 1af88102687e493cab40e62b0a2b8b7d42417ae6 (patch) | |
| tree | 272a80b424e68024a9ecda138159864d9659fe5a /tests/test/test.lua | |
| parent | e165a8e43abed4eb2eca64c3b5adefb57cd65600 (diff) | |
improve test lib
Diffstat (limited to 'tests/test/test.lua')
| -rw-r--r-- | tests/test/test.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test/test.lua b/tests/test/test.lua new file mode 100644 index 000000000..246814cdc --- /dev/null +++ b/tests/test/test.lua @@ -0,0 +1,53 @@ +function test_are_same(t) + t:are_same(1, 1) + t:are_same("1", "1") + t:are_same(nil, nil) + t:are_same(true, true) + t:are_same(1.34, 1.34) + t:are_same(test_are_same, test_are_same) + + t:are_not_same({}, {}) + t:are_not_same(1, "1") +end + +function test_are_equal(t) + t:are_equal(1, 1) + t:are_equal("1", "1") + t:are_equal(nil, nil) + t:are_equal(true, true) + t:are_equal(1.34, 1.34) + t:are_equal(test_are_same, test_are_same) + t:are_equal({}, {}) + t:are_equal({ a = 1 }, { a = 1 }) + t:are_equal({ a = { a= 1}}, { a = {a=1} }) + + t:are_not_equal(1, "1") + t:are_not_equal({ a = 1 }, { a = 1, b = 2 }) + t:are_not_equal({ a = 1, c = 3 }, { a = 1, b = 2 }) + t:are_not_equal({ a = 1}, { a = 1, b = 2 }) + t:are_not_equal({ a = { a= 1}}, { a = {a=2} }) +end + + +function test_require(t) + t:require(true) + t:require({}) + t:require(0) + t:require("") + + t:require_not(false) + t:require_not(nil) +end + +function test_will_raise(t) + t:will_raise(function () + raise("error: xxx") + end, "error") + t:will_raise(function () + raise(" ") + end, "%s") + t:will_raise(function () + raise("") + end) +end + |
