-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbig_int_unit_test.gd
52 lines (40 loc) · 1.38 KB
/
big_int_unit_test.gd
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
extends Label
# The test case
func test_expected_behavior():
print("------> start test big int operations <------")
var a = BigInt.new()
a.from_string("12345678901234567890")
var b = BigInt.new()
b.from_string("98765432109876543210")
var sum = a.add(b)
assert(sum.get_string() == "111111111011111111100", "sum operation failed!")
print("pass: sum operation")
var sub = a.sub(b)
assert(sub.get_string() == "-86419753208641975320", "sub operation failed!")
print("pass: sub operation")
var div = a.div(b)
assert(div.get_string() == "0", "div operation failed!")
print("pass: div operation")
var mul = a.mul(b)
print("mul: ", mul.get_string())
assert(mul.get_string() == "1219326311370217952237463801111263526900", "mul operation failed!")
print("pass: mul operation")
var mod = b.mod(a)
print("mod: ", mod.get_string())
assert(mod.get_string() == "900000000090", "mod operation failed!")
print("pass: mod operation")
var cmp = a.cmp(b)
assert(cmp == -1, "cmp operation failed!")
print("pass: cmp operation")
print("------> test big int operations done <------")
pass
func test_unexpected_behavior():
pass
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
test_expected_behavior()
test_unexpected_behavior()
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass