]> git.proxmox.com Git - rustc.git/blobdiff - vendor/compiler_builtins/libm/src/math/ceilf.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / vendor / compiler_builtins / libm / src / math / ceilf.rs
index 151a4f210420a110a0af3c57664193eab25d6b2c..f1edbd061bf7e9f12f00e261118499961b355021 100644 (file)
@@ -3,7 +3,6 @@ use core::f32;
 /// Ceil (f32)
 ///
 /// Finds the nearest integer greater than or equal to `x`.
-#[inline]
 #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
 pub fn ceilf(x: f32) -> f32 {
     // On wasm32 we know that LLVM's intrinsic will compile to an optimized
@@ -40,3 +39,25 @@ pub fn ceilf(x: f32) -> f32 {
     }
     f32::from_bits(ui)
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use core::f32::*;
+
+    #[test]
+    fn sanity_check() {
+        assert_eq!(ceilf(1.1), 2.0);
+        assert_eq!(ceilf(2.9), 3.0);
+    }
+
+    /// The spec: https://en.cppreference.com/w/cpp/numeric/math/ceil
+    #[test]
+    fn spec_tests() {
+        // Not Asserted: that the current rounding mode has no effect.
+        assert!(ceilf(NAN).is_nan());
+        for f in [0.0, -0.0, INFINITY, NEG_INFINITY].iter().copied() {
+            assert_eq!(ceilf(f), f);
+        }
+    }
+}