use_astronomical_constants/
lib.rs1#![forbid(unsafe_code)]
2
3pub const ASTRONOMICAL_UNIT: f64 = 149_597_870_700.0;
7
8pub const LIGHT_YEAR: f64 = 9.460_730_472_580_8e15;
10
11pub const PARSEC: f64 = 3.085_677_581_491_367e16;
13
14pub const SOLAR_MASS: f64 = 1.988_47e30;
16
17#[cfg(test)]
18mod tests {
19 use super::{ASTRONOMICAL_UNIT, LIGHT_YEAR, PARSEC, SOLAR_MASS};
20
21 fn runtime(value: f64) -> f64 {
22 value
23 }
24
25 #[test]
26 fn larger_astronomical_distances_exceed_smaller_ones() {
27 assert!(runtime(LIGHT_YEAR) > runtime(ASTRONOMICAL_UNIT));
28 assert!(runtime(PARSEC) > runtime(LIGHT_YEAR));
29 }
30
31 #[test]
32 fn representative_stellar_mass_is_positive() {
33 assert!(runtime(SOLAR_MASS) > 0.0);
34 }
35
36 #[test]
37 fn parsec_exceeds_astronomical_unit() {
38 assert!(runtime(PARSEC) > runtime(ASTRONOMICAL_UNIT));
39 }
40}