#![deny(missing_docs)]
#[macro_use]
mod macros;
mod impls;
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
pub struct SCell<T> {
data: T,
}
#[cfg(test)]
mod tests {
use super::SCell;
#[test]
fn overflow_add() {
let a = SCell::<i32>::new(std::i32::MAX) + SCell::<i32>::new(1);
assert!(a.is_none());
}
#[test]
fn overflow_sub() {
let a = SCell::<i32>::new(std::i32::MIN) - SCell::<i32>::new(1);
assert!(a.is_none());
}
#[test]
fn overflow_mul() {
let a = SCell::<i32>::new(std::i32::MAX) * SCell::<i32>::new(2);
assert!(a.is_none());
}
#[test]
fn overflow_div() {
let a = SCell::<i32>::new(std::i32::MIN) / SCell::<i32>::new(-1);
assert!(a.is_none());
}
#[test]
fn overflow_abs() {
let a = SCell::<i32>::new(std::i32::MIN).abs();
assert!(a.is_none());
}
#[test]
fn test_fromstr() {
let a = "2184".parse::<SCell<i32>>().unwrap();
assert_eq!(a, SCell::<i32>::new(2184));
}
}