summaryrefslogtreecommitdiffstats
path: root/lib/cbrt_test.go
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-11-14 00:42:13 -0500
committersiddharth ravikumar <s@ricketyspace.net>2022-11-14 00:42:13 -0500
commite7d6b059fc68154dde96cafeac10f3c5265df115 (patch)
treed784c24823fc8f0f332bfd5e2943be94d11385d9 /lib/cbrt_test.go
parentffbfd33359e1e5a5241bed64af60f01fd4c0de0f (diff)
lib: add `BigCubeRoot`
Diffstat (limited to 'lib/cbrt_test.go')
-rw-r--r--lib/cbrt_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/cbrt_test.go b/lib/cbrt_test.go
new file mode 100644
index 0000000..a5722c8
--- /dev/null
+++ b/lib/cbrt_test.go
@@ -0,0 +1,23 @@
+// Copyright © 2021 siddharth ravikumar <s@ricketyspace.net>
+// SPDX-License-Identifier: ISC
+
+package lib
+
+import (
+ "math/big"
+ "testing"
+)
+
+func TestBigCubeRoot(t *testing.T) {
+ a := big.NewFloat(612)
+ acr := BigCubeRoot(a)
+ if acr == nil {
+ t.Errorf("Could not find cube root of %v\n", a)
+ return
+ }
+ expected := big.NewFloat(8.490184748)
+ if big.NewFloat(0).Sub(acr, expected).Cmp(bigCubeRootTolerance) != -1 {
+ t.Errorf("Could not find cube root of %v (%v)\n", a, acr)
+ return
+ }
+}