Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/serde_json/tests/lexical/exponent.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / serde_json / tests / lexical / exponent.rs` 36 lines ยท 1288 bytes Raw Blame History 1 // Adapted from https://github.com/Alexhuszagh/rust-lexical. 2 3 use crate::lexical::exponent::*; 4 5 #[test] 6 fn scientific_exponent_test() { 7 // 0 digits in the integer 8 assert_eq!(scientific_exponent(0, 0, 5), -6); 9 assert_eq!(scientific_exponent(10, 0, 5), 4); 10 assert_eq!(scientific_exponent(-10, 0, 5), -16); 11 12 // >0 digits in the integer 13 assert_eq!(scientific_exponent(0, 1, 5), 0); 14 assert_eq!(scientific_exponent(0, 2, 5), 1); 15 assert_eq!(scientific_exponent(0, 2, 20), 1); 16 assert_eq!(scientific_exponent(10, 2, 20), 11); 17 assert_eq!(scientific_exponent(-10, 2, 20), -9); 18 19 // Underflow 20 assert_eq!(scientific_exponent(i32::MIN, 0, 0), i32::MIN); 21 assert_eq!(scientific_exponent(i32::MIN, 0, 5), i32::MIN); 22 23 // Overflow 24 assert_eq!(scientific_exponent(i32::MAX, 0, 0), i32::MAX - 1); 25 assert_eq!(scientific_exponent(i32::MAX, 5, 0), i32::MAX); 26 } 27 28 #[test] 29 fn mantissa_exponent_test() { 30 assert_eq!(mantissa_exponent(10, 5, 0), 5); 31 assert_eq!(mantissa_exponent(0, 5, 0), -5); 32 assert_eq!(mantissa_exponent(i32::MAX, 5, 0), i32::MAX - 5); 33 assert_eq!(mantissa_exponent(i32::MAX, 0, 5), i32::MAX); 34 assert_eq!(mantissa_exponent(i32::MIN, 5, 0), i32::MIN); 35 assert_eq!(mantissa_exponent(i32::MIN, 0, 5), i32::MIN + 5); 36 }