aboutsummaryrefslogtreecommitdiff
path: root/std/math/log.zig
diff options
context:
space:
mode:
authorBenoitJGirard <BenoitJGirard@users.noreply.github.com>2019-02-17 14:38:55 -0500
committerGitHub <noreply@github.com>2019-02-17 14:38:55 -0500
commit6daa041932ae5ab03eed953dacf3ca506078390c (patch)
tree0f51f6c2ff84dde51b61bba6799e5c5abccf91b4 /std/math/log.zig
parentf0ec308e26ff957c7fbb50ccc69d3d549c42c4da (diff)
parent8d2a902945ef97f28152c3d5a68bb974809c8539 (diff)
downloadzig-6daa041932ae5ab03eed953dacf3ca506078390c.tar.gz
zig-6daa041932ae5ab03eed953dacf3ca506078390c.zip
Merge pull request #2 from ziglang/master
Refreshing fork.
Diffstat (limited to 'std/math/log.zig')
-rw-r--r--std/math/log.zig26
1 files changed, 13 insertions, 13 deletions
diff --git a/std/math/log.zig b/std/math/log.zig
index 20b6d055e8..21cffcc078 100644
--- a/std/math/log.zig
+++ b/std/math/log.zig
@@ -2,7 +2,7 @@ const std = @import("../index.zig");
const math = std.math;
const builtin = @import("builtin");
const TypeId = builtin.TypeId;
-const assert = std.debug.assert;
+const expect = std.testing.expect;
pub fn log(comptime T: type, base: T, x: T) T {
if (base == 2) {
@@ -41,25 +41,25 @@ pub fn log(comptime T: type, base: T, x: T) T {
}
test "math.log integer" {
- assert(log(u8, 2, 0x1) == 0);
- assert(log(u8, 2, 0x2) == 1);
- assert(log(i16, 2, 0x72) == 6);
- assert(log(u32, 2, 0xFFFFFF) == 23);
- assert(log(u64, 2, 0x7FF0123456789ABC) == 62);
+ expect(log(u8, 2, 0x1) == 0);
+ expect(log(u8, 2, 0x2) == 1);
+ expect(log(i16, 2, 0x72) == 6);
+ expect(log(u32, 2, 0xFFFFFF) == 23);
+ expect(log(u64, 2, 0x7FF0123456789ABC) == 62);
}
test "math.log float" {
const epsilon = 0.000001;
- assert(math.approxEq(f32, log(f32, 6, 0.23947), -0.797723, epsilon));
- assert(math.approxEq(f32, log(f32, 89, 0.23947), -0.318432, epsilon));
- assert(math.approxEq(f64, log(f64, 123897, 12389216414), 1.981724596, epsilon));
+ expect(math.approxEq(f32, log(f32, 6, 0.23947), -0.797723, epsilon));
+ expect(math.approxEq(f32, log(f32, 89, 0.23947), -0.318432, epsilon));
+ expect(math.approxEq(f64, log(f64, 123897, 12389216414), 1.981724596, epsilon));
}
test "math.log float_special" {
- assert(log(f32, 2, 0.2301974) == math.log2(f32(0.2301974)));
- assert(log(f32, 10, 0.2301974) == math.log10(f32(0.2301974)));
+ expect(log(f32, 2, 0.2301974) == math.log2(f32(0.2301974)));
+ expect(log(f32, 10, 0.2301974) == math.log10(f32(0.2301974)));
- assert(log(f64, 2, 213.23019799993) == math.log2(f64(213.23019799993)));
- assert(log(f64, 10, 213.23019799993) == math.log10(f64(213.23019799993)));
+ expect(log(f64, 2, 213.23019799993) == math.log2(f64(213.23019799993)));
+ expect(log(f64, 10, 213.23019799993) == math.log10(f64(213.23019799993)));
}