use crate::all::*;
#[test]
fn pz_from() -> NumeraResult<()> {
use core::num::NonZeroU8;
assert_eq![Pz8::new(100)?, NonZeroU8::new(100).unwrap().into()];
assert_eq![Pz16::new(100)?, NonZeroU8::new(100).unwrap().into()];
assert_eq![Pz16::new(200)?, Pz8::new(200)?.into()];
assert_eq![Pz8::new(251)?, Prime8::new(251)?.into()];
assert_eq![Pz16::new(251)?, Prime8::new(251)?.into()];
Ok(())
}
#[test]
#[cfg(feature = "try_from")]
fn pz_try_from() -> NumeraResult<()> {
use core::num::{NonZeroI16, NonZeroI8, NonZeroU16};
assert_eq![Pz8::new(100)?, NonZeroU16::new(100).unwrap().try_into()?];
assert![TryInto::<Pz8>::try_into(NonZeroU16::new(500).unwrap()).is_err()];
assert_eq![Pz8::new(100)?, 100_i8.try_into()?];
assert_eq![Pz8::new(200)?, 200_i16.try_into()?];
assert_eq![Pz16::new(100)?, 100_i8.try_into()?];
assert![TryInto::<Pz8>::try_into(0_i8).is_err()];
assert![TryInto::<Pz8>::try_into(-100_i8).is_err()];
assert![TryInto::<Pz8>::try_into(500_i16).is_err()];
assert_eq![Pz8::new(200)?, 200_u8.try_into()?];
assert_eq![Pz8::new(200)?, 200_u16.try_into()?];
assert_eq![Pz16::new(200)?, 200_u8.try_into()?];
assert![TryInto::<Pz8>::try_into(0_u8).is_err()];
assert![TryInto::<Pz8>::try_into(500_u16).is_err()];
assert_eq![Pz8::new(100)?, NonZeroI8::new(100).unwrap().try_into()?];
assert_eq![Pz8::new(200)?, NonZeroI16::new(200).unwrap().try_into()?];
assert_eq![Pz16::new(100)?, NonZeroI8::new(100).unwrap().try_into()?];
assert![TryInto::<Pz8>::try_into(NonZeroI8::new(-100).unwrap()).is_err()];
assert![TryInto::<Pz8>::try_into(NonZeroI16::new(500).unwrap()).is_err()];
assert_eq![Pz8::new(200)?, Pz16::new(200)?.try_into()?];
assert![TryInto::<Pz8>::try_into(Pz16::new(500)?).is_err()];
assert_eq![Pz8::new(251)?, Pz16::new(251)?.try_into()?];
assert![TryInto::<Pz8>::try_into(Pz16::new(521)?).is_err()];
assert_eq![Pz8::new(100)?, Z8::new(100).try_into()?];
assert_eq![Pz8::new(100)?, Z16::new(100).try_into()?];
assert_eq![Pz16::new(100)?, Z8::new(100).try_into()?];
assert![TryInto::<Pz8>::try_into(Z8::new(0)).is_err()];
assert![TryInto::<Pz8>::try_into(Z8::new(-100)).is_err()];
assert![TryInto::<Pz8>::try_into(Z16::new(500)).is_err()];
assert_eq![Pz8::new(100)?, N0z8::new(100)?.try_into()?];
assert_eq![Pz8::new(100)?, N0z16::new(100)?.try_into()?];
assert_eq![Pz16::new(100)?, N0z8::new(100)?.try_into()?];
assert![TryInto::<Pz8>::try_into(N0z8::new(-100)?).is_err()];
assert![TryInto::<Pz8>::try_into(N0z16::new(500)?).is_err()];
assert![TryInto::<Pz8>::try_into(Nz8::new_neg(100)?).is_err()];
assert![TryInto::<Pz8>::try_into(Npz8::new_neg(100)).is_err()];
Ok(())
}
#[test]
fn pz_for() -> NumeraResult<()> {
use core::num::{NonZeroU16, NonZeroU8};
assert_eq![NonZeroU8::new(200).unwrap(), Pz8::new(200)?.into()];
assert_eq![NonZeroU16::new(200).unwrap(), Pz8::new(200)?.into()];
Ok(())
}
#[test]
#[cfg(feature = "try_from")]
fn pz_try_for() -> NumeraResult<()> {
use core::num::{NonZeroI8, NonZeroU8};
assert_eq![NonZeroU8::new(200).unwrap(), Pz16::new(200)?.try_into()?];
assert![TryInto::<NonZeroU8>::try_into(Pz16::new(300)?).is_err()];
assert_eq![200_u8, Pz8::new(200)?.try_into()?];
assert![TryInto::<u8>::try_into(Pz16::new(300)?).is_err()];
assert_eq![NonZeroI8::new(100).unwrap(), Pz16::new(100)?.try_into()?];
assert![TryInto::<NonZeroI8>::try_into(Pz16::new(200)?).is_err()];
assert_eq![100_i8, Pz8::new(100)?.try_into()?];
assert![TryInto::<i8>::try_into(Pz8::new(200)?).is_err()];
Ok(())
}