add tests for EguiHelper trait

This commit is contained in:
Simon Gardling
2022-05-18 13:53:01 -04:00
parent 6258b0ac16
commit 3ef1feedb1
4 changed files with 45 additions and 7 deletions

View File

@@ -114,3 +114,40 @@ fn invalid_hashed_storage() {
use ytbn_graphing_software::hashed_storage_read;
assert_eq!(hashed_storage_read("aaaa"), None);
}
#[test]
fn to_tuple() {
use egui::plot::Value;
use ytbn_graphing_software::EguiHelper;
let data_raw = vec![(0.0, 1.0), (1.0, 3.0), (2.0, 4.0)];
let data: Vec<Value> = data_raw.iter().map(|(x, y)| Value::new(*x, *y)).collect();
let tupled_data = data.to_tuple();
assert_eq!(tupled_data, data_raw);
}
#[test]
fn to_line() {
use egui::plot::{Line, Value};
use ytbn_graphing_software::EguiHelper;
let data_raw: Vec<Value> = vec![(0.0, 1.0), (1.0, 3.0), (2.0, 4.0)]
.iter()
.map(|(x, y)| Value::new(*x, *y))
.collect();
let data: Line = data_raw.clone().to_line();
assert_eq!(*data.get_series().get_values(), data_raw);
}
#[test]
fn to_points() {
use egui::plot::{Points, Value};
use ytbn_graphing_software::EguiHelper;
let data_raw: Vec<Value> = vec![(0.0, 1.0), (1.0, 3.0), (2.0, 4.0)]
.iter()
.map(|(x, y)| Value::new(*x, *y))
.collect();
let data: Points = data_raw.clone().to_points();
assert_eq!(*data.get_series().get_values(), data_raw);
}