generated from ElnuDev/rust-project
parent
63f6b61f91
commit
053066d204
@ -0,0 +1,46 @@
|
|||||||
|
use crate::svg::{SVGMeasure, SVGUnit};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn add() {
|
||||||
|
let m_10cm = SVGMeasure::new(10.0, SVGUnit::Centimeter);
|
||||||
|
let m_5mm = SVGMeasure::new(5.0, SVGUnit::Millimeter);
|
||||||
|
assert_eq!(m_10cm + m_5mm, SVGMeasure::new(10.5, SVGUnit::Centimeter));
|
||||||
|
assert_eq!(m_5mm + m_10cm, SVGMeasure::new(105.0, SVGUnit::Millimeter));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn sub() {
|
||||||
|
let m_10cm = SVGMeasure::new(10.0, SVGUnit::Centimeter);
|
||||||
|
let m_5mm = SVGMeasure::new(5.0, SVGUnit::Millimeter);
|
||||||
|
assert_eq!(m_10cm - m_5mm, SVGMeasure::new(9.5, SVGUnit::Centimeter));
|
||||||
|
assert_eq!(m_5mm - m_10cm, SVGMeasure::new(-95.0, SVGUnit::Millimeter));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mul() {
|
||||||
|
let m_10cm = SVGMeasure::new(10.0, SVGUnit::Centimeter);
|
||||||
|
assert_eq!(m_10cm * 5.0, SVGMeasure::new(50.0, SVGUnit::Centimeter));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn div() {
|
||||||
|
let m_10cm = SVGMeasure::new(10.0, SVGUnit::Centimeter);
|
||||||
|
assert_eq!(m_10cm / 5.0, SVGMeasure::new(2.0, SVGUnit::Centimeter));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn eq() {
|
||||||
|
let m_1in = SVGMeasure::new(1.0, SVGUnit::Inch);
|
||||||
|
assert_eq!(m_1in, m_1in);
|
||||||
|
let m_1cm = SVGMeasure::new(1.0, SVGUnit::Centimeter);
|
||||||
|
let m_10mm = SVGMeasure::new(10.0, SVGUnit::Millimeter);
|
||||||
|
assert_eq!(m_1cm, m_10mm);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ne() {
|
||||||
|
// Testing negative difference, there should be absolute value in PartialEq impl
|
||||||
|
let a = SVGMeasure::new(1.0, SVGUnit::Pixel);
|
||||||
|
let b = SVGMeasure::new(10.0, SVGUnit::Pixel);
|
||||||
|
assert_ne!(a, b);
|
||||||
|
}
|
Loading…
Reference in new issue