ares/rust/ibig/tests/cmp.rs
Edward Amsden a7005c7049 Ares -> Sword (#12)
* Update README.md

* Rename ares -> sword

* Workspace

* Cargo-only CI
2024-08-22 10:46:38 -05:00

34 lines
1.1 KiB
Rust

use core::cmp::Ordering;
use ibig::{ibig, ubig};
#[test]
fn test_cmp() {
assert_eq!(ubig!(500).cmp(&ubig!(500)), Ordering::Equal);
assert!(ubig!(100) < ubig!(500));
assert!(ubig!(500) > ubig!(100));
assert!(ubig!(0x10000000000000000) > ubig!(100));
assert!(ubig!(100) < ubig!(_0x100000000000000000000000000000000));
assert!(
ubig!(_0x100000000000000020000000000000003) < ubig!(_0x100000000000000030000000000000002)
);
assert!(
ubig!(_0x100000000000000030000000000000002) > ubig!(_0x100000000000000020000000000000003)
);
assert_eq!(
ubig!(_0x100000000000000030000000000000002)
.cmp(&ubig!(_0x100000000000000030000000000000002)),
Ordering::Equal
);
assert_eq!(ibig!(500).cmp(&ibig!(500)), Ordering::Equal);
assert_eq!(ibig!(-500).cmp(&ibig!(-500)), Ordering::Equal);
assert!(ibig!(5) < ibig!(10));
assert!(ibig!(10) > ibig!(5));
assert!(ibig!(-5) < ibig!(10));
assert!(ibig!(-15) < ibig!(10));
assert!(ibig!(10) > ibig!(-5));
assert!(ibig!(10) > ibig!(-15));
assert!(ibig!(-10) < ibig!(-5));
assert!(ibig!(-5) > ibig!(-10));
}