Commit 82793402 authored by Florian Blasius's avatar Florian Blasius 🤘

[api update] fix tests.

parent d48d0e9b
use super::*;
use crate::properties::PropertySource;
#[test]
fn test_width() {
......
use super::*;
use crate::structs::*;
#[test]
fn test_builder_width() {
......
// use super::*;
// use crate::enums::Alignment;
// #[test]
// fn test_align_position() {
// let available_width = 100.0;
// let width = 50.0;
// let margin = Margin::default();
// let horizontal_alignment = HorizontalAlignment(Alignment::Stretch);
// assert_eq!(
// horizontal_alignment.align_position(available_width, width, margin),
// 0.0
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::Center);
// assert_eq!(
// horizontal_alignment.align_position(available_width, width, margin),
// 25.0
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::Start);
// assert_eq!(
// horizontal_alignment.align_position(available_width, width, margin),
// 0.0
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::End);
// assert_eq!(
// horizontal_alignment.align_position(available_width, width, margin),
// 50.0
// );
// }
// #[test]
// fn test_align_width() {
// let available_width = 100.0;
// let width = 50.0;
// let margin = Margin::default();
// let horizontal_alignment = HorizontalAlignment(Alignment::Stretch);
// assert_eq!(
// horizontal_alignment.align_width(available_width, width, margin),
// available_width
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::Center);
// assert_eq!(
// horizontal_alignment.align_width(available_width, width, margin),
// width
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::Start);
// assert_eq!(
// horizontal_alignment.align_width(available_width, width, margin),
// width
// );
// let horizontal_alignment = HorizontalAlignment(Alignment::End);
// assert_eq!(
// horizontal_alignment.align_width(available_width, width, margin),
// width
// );
// }
// #[test]
// fn test_into() {
// let horizontal_alignment: HorizontalAlignment = "Start".into();
// assert_eq!(horizontal_alignment.0, Alignment::Start);
// let horizontal_alignment: HorizontalAlignment = "start".into();
// assert_eq!(horizontal_alignment.0, Alignment::Start);
// let horizontal_alignment: HorizontalAlignment = "Center".into();
// assert_eq!(horizontal_alignment.0, Alignment::Center);
// let horizontal_alignment: HorizontalAlignment = "center".into();
// assert_eq!(horizontal_alignment.0, Alignment::Center);
// let horizontal_alignment: HorizontalAlignment = "End".into();
// assert_eq!(horizontal_alignment.0, Alignment::End);
// let horizontal_alignment: HorizontalAlignment = "end".into();
// assert_eq!(horizontal_alignment.0, Alignment::End);
// let horizontal_alignment: HorizontalAlignment = "Stretch".into();
// assert_eq!(horizontal_alignment.0, Alignment::Stretch);
// let horizontal_alignment: HorizontalAlignment = "stretch".into();
// assert_eq!(horizontal_alignment.0, Alignment::Stretch);
// let horizontal_alignment: HorizontalAlignment = "other".into();
// assert_eq!(horizontal_alignment.0, Alignment::Stretch);
// }
use super::*;
use crate::enums::Alignment;
#[test]
fn test_align_position() {
let available_width = 100.0;
let width = 50.0;
let margin = Margin::default();
let horizontal_alignment = HorizontalAlignment(Alignment::Stretch);
assert_eq!(
horizontal_alignment.align_x(available_width, width, margin.clone()),
0.0
);
let horizontal_alignment = HorizontalAlignment(Alignment::Center);
assert_eq!(
horizontal_alignment.align_x(available_width, width, margin.clone()),
25.0
);
let horizontal_alignment = HorizontalAlignment(Alignment::Start);
assert_eq!(
horizontal_alignment.align_x(available_width, width, margin.clone()),
0.0
);
let horizontal_alignment = HorizontalAlignment(Alignment::End);
assert_eq!(
horizontal_alignment.align_x(available_width, width, margin.clone()),
50.0
);
}
#[test]
fn test_align_width() {
let available_width = 100.0;
let width = 50.0;
let margin = Margin::default();
let horizontal_alignment = HorizontalAlignment(Alignment::Stretch);
assert_eq!(
horizontal_alignment.align_width(available_width, width, margin.clone()),
available_width
);
let horizontal_alignment = HorizontalAlignment(Alignment::Center);
assert_eq!(
horizontal_alignment.align_width(available_width, width, margin.clone()),
width
);
let horizontal_alignment = HorizontalAlignment(Alignment::Start);
assert_eq!(
horizontal_alignment.align_width(available_width, width, margin.clone()),
width
);
let horizontal_alignment = HorizontalAlignment(Alignment::End);
assert_eq!(
horizontal_alignment.align_width(available_width, width, margin.clone()),
width
);
}
#[test]
fn test_into() {
let horizontal_alignment: HorizontalAlignment = "Start".into();
assert_eq!(horizontal_alignment.0, Alignment::Start);
let horizontal_alignment: HorizontalAlignment = "start".into();
assert_eq!(horizontal_alignment.0, Alignment::Start);
let horizontal_alignment: HorizontalAlignment = "Center".into();
assert_eq!(horizontal_alignment.0, Alignment::Center);
let horizontal_alignment: HorizontalAlignment = "center".into();
assert_eq!(horizontal_alignment.0, Alignment::Center);
let horizontal_alignment: HorizontalAlignment = "End".into();
assert_eq!(horizontal_alignment.0, Alignment::End);
let horizontal_alignment: HorizontalAlignment = "end".into();
assert_eq!(horizontal_alignment.0, Alignment::End);
let horizontal_alignment: HorizontalAlignment = "Stretch".into();
assert_eq!(horizontal_alignment.0, Alignment::Stretch);
let horizontal_alignment: HorizontalAlignment = "stretch".into();
assert_eq!(horizontal_alignment.0, Alignment::Stretch);
let horizontal_alignment: HorizontalAlignment = "other".into();
assert_eq!(horizontal_alignment.0, Alignment::Stretch);
}
// use crate::structs::{Spacer, Thickness};
use crate::structs::{Spacer, Thickness};
// use super::*;
use super::*;
// #[test]
// fn test_set_left() {
// let left = 10.0;
#[test]
fn test_set_left() {
let left = 10.0;
// let mut margin = Margin::default();
// margin.set_left(left);
let mut margin = Margin::default();
margin.set_left(left);
// assert_eq!(margin.left(), left);
// }
assert_eq!(margin.left(), left);
}
// #[test]
// fn test_set_top() {
// let top = 10.0;
#[test]
fn test_set_top() {
let top = 10.0;
// let mut margin = Margin::default();
// margin.set_top(top);
let mut margin = Margin::default();
margin.set_top(top);
// assert_eq!(margin.top(), top);
// }
assert_eq!(margin.top(), top);
}
// #[test]
// fn test_set_right() {
// let right = 10.0;
#[test]
fn test_set_right() {
let right = 10.0;
// let mut margin = Margin::default();
// margin.set_right(right);
let mut margin = Margin::default();
margin.set_right(right);
// assert_eq!(margin.right(), right);
// }
assert_eq!(margin.right(), right);
}
// #[test]
// fn test_set_bottom() {
// let bottom = 10.0;
#[test]
fn test_set_bottom() {
let bottom = 10.0;
// let mut margin = Margin::default();
// margin.set_bottom(bottom);
let mut margin = Margin::default();
margin.set_bottom(bottom);
// assert_eq!(margin.bottom(), bottom);
// }
assert_eq!(margin.bottom(), bottom);
}
// #[test]
// fn test_set_thickness() {
// let thickness = Thickness {
// left: 10.0,
// right: 12.0,
// top: 14.0,
// bottom: 4.0,
// };
#[test]
fn test_set_thickness() {
let thickness = Thickness {
left: 10.0,
right: 12.0,
top: 14.0,
bottom: 4.0,
};
// let mut margin = Margin::default();
// margin.set_thickness(thickness);
let mut margin = Margin::default();
margin.set_thickness(thickness);
// assert_eq!(margin.thickness(), thickness);
// }
assert_eq!(margin.thickness(), thickness);
}
// #[test]
// fn test_into() {
// let margin: Margin = (10.0, 12.0, 13.0, 14.0).into();
#[test]
fn test_into() {
let margin: Margin = (10.0, 12.0, 13.0, 14.0).into();
// assert_eq!(margin.left(), 10.0);
// assert_eq!(margin.top(), 12.0);
// assert_eq!(margin.right(), 13.0);
// assert_eq!(margin.bottom(), 14.0);
assert_eq!(margin.left(), 10.0);
assert_eq!(margin.top(), 12.0);
assert_eq!(margin.right(), 13.0);
assert_eq!(margin.bottom(), 14.0);
// let margin: Margin = 10.0.into();
let margin: Margin = 10.0.into();
// assert_eq!(margin.left(), 10.0);
// assert_eq!(margin.top(), 10.0);
// assert_eq!(margin.right(), 10.0);
// assert_eq!(margin.bottom(), 10.0);
// }
assert_eq!(margin.left(), 10.0);
assert_eq!(margin.top(), 10.0);
assert_eq!(margin.right(), 10.0);
assert_eq!(margin.bottom(), 10.0);
}
......@@ -8,6 +8,5 @@ mod margin;
mod offset;
mod orientation;
mod padding;
mod point;
mod rows;
mod vertical_alignment;
// use super::*;
use super::*;
// #[test]
// fn test_into() {
// let offset: Offset = 14.0.into();
// assert_eq!(offset.0, 14.0);
// assert_eq!(offset.1, 14.0);
#[test]
fn test_into() {
let offset: Offset = 14.0.into();
assert_eq!((offset.0).0, 14.0);
assert_eq!((offset.0).1, 14.0);
// let offset: Offset = (14.0, 16.0).into();
// assert_eq!(offset.0, 14.0);
// assert_eq!(offset.1, 16.0);
// }
let offset: Offset = (14.0, 16.0).into();
assert_eq!((offset.0).0, 14.0);
assert_eq!((offset.0).1, 16.0);
}
// use super::*;
use super::*;
// #[test]
// fn test_into() {
// let vertical_alignment: Orientation = "Vertical".into();
// assert_eq!(vertical_alignment, Orientation::Vertical);
#[test]
fn test_into() {
let vertical_alignment: Orientation = "Vertical".into();
assert_eq!(vertical_alignment.0, OrientationValue::Vertical);
// let vertical_alignment: Orientation = "vertical".into();
// assert_eq!(vertical_alignment, Orientation::Vertical);
let vertical_alignment: Orientation = "vertical".into();
assert_eq!(vertical_alignment.0, OrientationValue::Vertical);
// let vertical_alignment: Orientation = "Horizontal".into();
// assert_eq!(vertical_alignment, Orientation::Horizontal);
let vertical_alignment: Orientation = "Horizontal".into();
assert_eq!(vertical_alignment.0, OrientationValue::Horizontal);
// let vertical_alignment: Orientation = "horizontal".into();
// assert_eq!(vertical_alignment, Orientation::Horizontal);
let vertical_alignment: Orientation = "horizontal".into();
assert_eq!(vertical_alignment.0, OrientationValue::Horizontal);
// let vertical_alignment: Orientation = "other".into();
// assert_eq!(vertical_alignment, Orientation::Vertical);
// }
let vertical_alignment: Orientation = "other".into();
assert_eq!(vertical_alignment.0, OrientationValue::Vertical);
}
// use crate::structs::{Spacer, Thickness};
use crate::structs::{Spacer, Thickness};
// use super::*;
use super::*;
// #[test]
// fn test_set_left() {
// let left = 10.0;
#[test]
fn test_set_left() {
let left = 10.0;
// let mut padding = Padding::default();
// padding.set_left(left);
let mut padding = Padding::default();
padding.set_left(left);
// assert_eq!(padding.left(), left);
// }
assert_eq!(padding.left(), left);
}
// #[test]
// fn test_set_top() {
// let top = 10.0;
#[test]
fn test_set_top() {
let top = 10.0;
// let mut padding = Padding::default();
// padding.set_top(top);
let mut padding = Padding::default();
padding.set_top(top);
// assert_eq!(padding.top(), top);
// }
assert_eq!(padding.top(), top);
}
// #[test]
// fn test_set_right() {
// let right = 10.0;
#[test]
fn test_set_right() {
let right = 10.0;
// let mut padding = Padding::default();
// padding.set_right(right);
let mut padding = Padding::default();
padding.set_right(right);
// assert_eq!(padding.right(), right);
// }
assert_eq!(padding.right(), right);
}
// #[test]
// fn test_set_bottom() {
// let bottom = 10.0;
#[test]
fn test_set_bottom() {
let bottom = 10.0;
// let mut padding = Padding::default();
// padding.set_bottom(bottom);
let mut padding = Padding::default();
padding.set_bottom(bottom);
// assert_eq!(padding.bottom(), bottom);
// }
assert_eq!(padding.bottom(), bottom);
}
// #[test]
// fn test_set_thickness() {
// let thickness = Thickness {
// left: 10.0,
// right: 12.0,
// top: 14.0,
// bottom: 4.0,
// };
#[test]
fn test_set_thickness() {
let thickness = Thickness {
left: 10.0,
right: 12.0,
top: 14.0,
bottom: 4.0,
};
// let mut padding = Padding::default();
// padding.set_thickness(thickness);
let mut padding = Padding::default();
padding.set_thickness(thickness);
// assert_eq!(padding.thickness(), thickness);
// }
assert_eq!(padding.thickness(), thickness);
}
// #[test]
// fn test_into() {
// let padding: Padding = (10.0, 12.0, 13.0, 14.0).into();
#[test]
fn test_into() {
let padding: Padding = (10.0, 12.0, 13.0, 14.0).into();
// assert_eq!(padding.left(), 10.0);
// assert_eq!(padding.top(), 12.0);
// assert_eq!(padding.right(), 13.0);
// assert_eq!(padding.bottom(), 14.0);
assert_eq!(padding.left(), 10.0);
assert_eq!(padding.top(), 12.0);
assert_eq!(padding.right(), 13.0);
assert_eq!(padding.bottom(), 14.0);
// let padding: Padding = 10.0.into();
let padding: Padding = 10.0.into();
// assert_eq!(padding.left(), 10.0);
// assert_eq!(padding.top(), 10.0);
// assert_eq!(padding.right(), 10.0);
// assert_eq!(padding.bottom(), 10.0);
// }
assert_eq!(padding.left(), 10.0);
assert_eq!(padding.top(), 10.0);
assert_eq!(padding.right(), 10.0);
assert_eq!(padding.bottom(), 10.0);
}
// use std::ops::{Add, Sub};
// use super::*;
// #[test]
// fn test_add() {
// let point = Point::new(5.0, 8.0);
// let other_point = Point::new(10.0, 12.0);
// let result = point.add(other_point);
// assert_eq!(result.x, 15.0);
// assert_eq!(result.y, 20.0);
// let neg_point = Point::new(-5.0, 8.0);
// let other_neg_point = Point::new(-7.0, -12.0);
// let result = neg_point.add(other_neg_point);
// assert_eq!(result.x, -12.0);
// assert_eq!(result.y, -4.0);
// }
// #[test]
// fn test_sub() {
// let point = Point::new(5.0, 8.0);
// let other_point = Point::new(10.0, 12.0);
// let result = point.sub(other_point);
// assert_eq!(result.x, -5.0);
// assert_eq!(result.y, -4.0);
// let neg_point = Point::new(-5.0, 8.0);
// let other_neg_point = Point::new(-7.0, -12.0);
// let result = neg_point.sub(other_neg_point);
// assert_eq!(result.x, 2.0);
// assert_eq!(result.y, 20.0);
// }
// use super::*;
use super::;*
// #[test]
// fn test_height() {
// let height = RowHeight::Height(64.0);
#[test]
fn test_height() {
let height = RowHeight::Height(64.0);
// let builder = RowBuilder::new();
// let row = builder.height(height).build();
let builder = RowBuilder::new();
let row = builder.height(height).build();
// assert_eq!(row.height, height);
// }
assert_eq!(row.height, height);
}
// #[test]
// fn test_min_height() {
// let min_height = 64.0;
#[test]
fn test_min_height() {
let min_height = 64.0;
// let builder = RowBuilder::new();
// let row = builder.min_height(min_height).build();
let builder = RowBuilder::new();
let row = builder.min_height(min_height).build();
// assert_eq!(row.min_height, min_height);
// }
assert_eq!(row.min_height, min_height);
}
// #[test]
// fn test_max_height() {
// let max_height = 64.0;
#[test]
fn test_max_height() {
let max_height = 64.0;
// let builder = RowBuilder::new();
// let row = builder.max_height(max_height).build();
let builder = RowBuilder::new();
let row = builder.max_height(max_height).build();
// assert_eq!(row.max_height, max_height);
// }
assert_eq!(row.max_height, max_height);
}
// #[test]
// fn test_set_current_height() {
// let out_one_height = 10.0;
// let out_two_height = 66.0;
// let in_height = 33.0;
// let min_height = 14.0;
// let max_height = 64.0;
#[test]
fn test_set_current_height() {
let out_one_height = 10.0;
let out_two_height = 66.0;
let in_height = 33.0;
let min_height = 14.0;
let max_height = 64.0;
// let builder = RowBuilder::new();
// let mut row = builder
// .min_height(min_height)
// .max_height(max_height)
// .build();
let builder = RowBuilder::new();
let mut row = builder.min_height(min_height).max_height(max_height).build();
// row.set_current_height(out_one_height);
// assert_eq!(row.current_height(), min_height);
row.set_current_height(out_one_height);
assert_eq!(row.current_height(), min_height);
// row.set_current_height(out_two_height);
// assert_eq!(row.current_height(), max_height);
row.set_current_height(out_two_height);
assert_eq!(row.current_height(), max_height);
// row.set_current_height(in_height);
// assert_eq!(row.current_height(), in_height);
// }
row.set_current_height(in_height);
assert_eq!(row.current_height(), in_height);
}
// #[test]
// fn test_row() {
// let height = RowHeight::Height(64.0);
#[test]
fn test_row() {
let builder = RowsBuilder::new();
let rows = builder.build();
// let builder = RowsBuilder::new();
// let rows = builder.build();
assert_eq!(rows.len(), 0);
// assert_eq!(rows.len(), 0);
let builder = RowsBuilder::new();
let rows = builder
.row(Row::create().build())
.row(Row::create().build())
.build();
// let builder = RowsBuilder::new();
// let rows = builder
// .row(Row::create().build())
// .row(Row::create().build())
// .build();
assert_eq!(rows.len(), 2);
}
// assert_eq!(rows.len(), 2);
// }
#[test]
fn test_row_height_into() {
let row: Row = "Auto".into();
assert_eq!(row.height(), RowHeight::Auto);
// #[test]
// fn test_row_height_into() {
// let row: Row = "Auto".into();
// assert_eq!(row.height(), RowHeight::Auto);
let row: Row = "auto".into();
assert_eq!(row.height(), RowHeight::Auto);
// let row: Row = "auto".into();
// assert_eq!(row.height(), RowHeight::Auto);
let row: Row = "Stretch".into();
assert_eq!(row.height(), RowHeight::Stretch);
// let row: Row = "Stretch".into();
// assert_eq!(row.height(), RowHeight::Stretch);
let row: Row = "stretch".into();
assert_eq!(row.height(), RowHeight::Stretch);
// let row: Row = "stretch".into();
// assert_eq!(row.height(), RowHeight::Stretch);
let row: Row = "*".into();
assert_eq!(row.height(), RowHeight::Stretch);
// let row: Row = "*".into();