diff --git a/numerical/factorial_test.go b/numerical/factorial_test.go new file mode 100644 index 0000000..1c3c364 --- /dev/null +++ b/numerical/factorial_test.go @@ -0,0 +1,23 @@ +package numerical + +import "testing" + +// Testfactorial tests factorial function +func Testfactorial(t *testing.T) { + + if factorial(2) != 2 { + t.Error("[Error] factorial(2) is wrong") + } + + if factorial(3) != 6 { + t.Error("[Error] factorial(3) is wrong") + } + + if factorial(0) != 1 { + t.Error("[Error] factorial(0) is wrong") + } + + if factorial(5) != 120 { + t.Error("[Error] factorial(5) is wrong") + } +} diff --git a/numerical/fast_pow_test.go b/numerical/fast_pow_test.go new file mode 100644 index 0000000..1def84b --- /dev/null +++ b/numerical/fast_pow_test.go @@ -0,0 +1,23 @@ +package numerical + +import "testing" + +// TestFastPow tests fastpow function +func TestFastPow(t *testing.T) { + + if FastPow(2, 10) != 1024 { + t.Error("[Error] FastPow(2, 10) is wrong") + } + + if FastPow(1, 10) != 1 { + t.Error("[Error] FastPow(1, 10) is wrong") + } + + if FastPow(0, 15) != 0 { + t.Error("[Error] FastPow(0, 15) is wrong") + } + + if FastPow(10, 2) != 100 { + t.Error("[Error] FastPow(0, 15) is wrong") + } +}