mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 20:40:48 +01:00
25 lines
430 B
Go
25 lines
430 B
Go
|
package decimal
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestSqrt(t *testing.T) {
|
||
|
tables := []struct {
|
||
|
x Decimal
|
||
|
n Decimal
|
||
|
}{
|
||
|
{One, One},
|
||
|
{Four, Two},
|
||
|
{Sixteen, Four},
|
||
|
{Two, NewFromFloat(1.4142135623730951)},
|
||
|
}
|
||
|
|
||
|
for _, table := range tables {
|
||
|
result := table.x.Sqrt()
|
||
|
if result.NotEqual(table.n) {
|
||
|
t.Errorf("Sqrt of (%v) was incorrect, got: %v, want: %v.", table.x.String(), result.String(), table.n.String())
|
||
|
}
|
||
|
}
|
||
|
}
|