ares/rust/ibig/tests/sign.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

39 lines
834 B
Rust

use ibig::{
ibig,
ops::{Abs, UnsignedAbs},
ubig,
};
#[test]
#[allow(clippy::double_neg)]
fn test_neg() {
assert_eq!(-ibig!(123), ibig!(-123));
assert_eq!(-ibig!(-123), ibig!(123));
assert_eq!(-ibig!(0), ibig!(0));
assert_eq!(-&ibig!(123), ibig!(-123));
}
#[test]
fn test_abs() {
assert_eq!(ibig!(123).abs(), ibig!(123));
assert_eq!(ibig!(-123).abs(), ibig!(123));
assert_eq!((&ibig!(-123)).abs(), ibig!(123));
}
#[test]
fn test_unsigned_abs() {
assert_eq!(ibig!(123).unsigned_abs(), ubig!(123));
assert_eq!(ibig!(-123).unsigned_abs(), ubig!(123));
assert_eq!((&ibig!(-123)).unsigned_abs(), ubig!(123));
}
#[test]
fn test_signum() {
assert_eq!(ibig!(-500).signum(), ibig!(-1));
assert_eq!(ibig!(0).signum(), ibig!(0));
assert_eq!(ibig!(500).signum(), ibig!(1));
}