diff options
| author | Marc Tiehuis <marctiehuis@gmail.com> | 2017-06-20 23:01:04 +1200 |
|---|---|---|
| committer | Marc Tiehuis <marctiehuis@gmail.com> | 2017-06-20 23:10:22 +1200 |
| commit | 5bbec42a4edb3f6758a9d67fcf763c660ac3f204 (patch) | |
| tree | 3dc324d083f142935df53c5900edfc04c0f956f8 /std/math/cbrt.zig | |
| parent | c9fc8bd802f5ed52c4cc78b93f18fc5dc9b6bb7f (diff) | |
| download | zig-5bbec42a4edb3f6758a9d67fcf763c660ac3f204.tar.gz zig-5bbec42a4edb3f6758a9d67fcf763c660ac3f204.zip | |
Add math special case tests and general fixes
- Should cover special case inputs for most functions
- Fixed a number of runtime panicking behaviour reliant on shift
overflow/division by zero etc.
Diffstat (limited to 'std/math/cbrt.zig')
| -rw-r--r-- | std/math/cbrt.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/std/math/cbrt.zig b/std/math/cbrt.zig index ac6e90576e..3674f10c34 100644 --- a/std/math/cbrt.zig +++ b/std/math/cbrt.zig @@ -1,3 +1,9 @@ +// Special Cases: +// +// - cbrt(+-0) = +-0 +// - cbrt(+-inf) = +-inf +// - cbrt(nan) = nan + const math = @import("index.zig"); const assert = @import("../debug.zig").assert; @@ -135,3 +141,19 @@ test "math.cbrt64" { assert(math.approxEq(f64, cbrt64(37.45), 3.345676, epsilon)); assert(math.approxEq(f64, cbrt64(123123.234375), 49.748501, epsilon)); } + +test "math.cbrt.special" { + assert(cbrt32(0.0) == 0.0); + assert(cbrt32(-0.0) == -0.0); + assert(math.isPositiveInf(cbrt32(math.inf(f32)))); + assert(math.isNegativeInf(cbrt32(-math.inf(f32)))); + assert(math.isNan(cbrt32(math.nan(f32)))); +} + +test "math.cbrt64.special" { + assert(cbrt64(0.0) == 0.0); + assert(cbrt64(-0.0) == -0.0); + assert(math.isPositiveInf(cbrt64(math.inf(f64)))); + assert(math.isNegativeInf(cbrt64(-math.inf(f64)))); + assert(math.isNan(cbrt64(math.nan(f64)))); +} |
