Ver código fonte

Fix Hz unit in tests

David Peter 2 anos atrás
pai
commit
712d8fae37
1 arquivos alterados com 17 adições e 3 exclusões
  1. 17 3
      insect/src/unit.rs

+ 17 - 3
insect/src/unit.rs

@@ -184,6 +184,11 @@ impl Unit {
         Self::new_base("meter")
     }
 
+    #[cfg(test)]
+    pub fn centimeter() -> Self {
+        Self::new_base("meter").with_prefix(Prefix::centi())
+    }
+
     #[cfg(test)]
     pub fn millimeter() -> Self {
         Self::new_base("meter").with_prefix(Prefix::milli())
@@ -201,7 +206,16 @@ impl Unit {
 
     #[cfg(test)]
     pub fn hertz() -> Self {
-        Self::new_derived("hertz", Number::from_f64(1.0), Unit::second())
+        Self::new_derived(
+            "hertz",
+            Number::from_f64(1.0),
+            Unit::second().power(Ratio::from_integer(-1)),
+        )
+    }
+
+    #[cfg(test)]
+    pub fn hour() -> Self {
+        Self::new_derived("hour", Number::from_f64(3600.0), Self::second())
     }
 
     #[cfg(test)]
@@ -210,8 +224,8 @@ impl Unit {
     }
 
     #[cfg(test)]
-    pub fn hour() -> Self {
-        Self::new_derived("hour", Number::from_f64(3600.0), Self::second())
+    pub fn bit() -> Self {
+        Self::new_base("bit")
     }
 }