-
Notifications
You must be signed in to change notification settings - Fork 3
/
tests.rs
50 lines (44 loc) · 1.51 KB
/
tests.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::Edges;
use bevy_image::{prelude::Image, CompressedImageFormats, ImageSampler, ImageType};
use bevy_render::render_asset::RenderAssetUsages;
use std::path::Path;
#[test]
fn same_image_same_edges() {
let dynamic_image = image::open(Path::new("assets/car.png")).unwrap();
let dynamic_edges = Edges::from(dynamic_image);
let bevy_image = Image::from_buffer(
include_bytes!("../assets/car.png"), // buffer
ImageType::Extension("png"),
CompressedImageFormats::default(),
true,
ImageSampler::default(),
RenderAssetUsages::default(),
)
.unwrap();
let bevy_edges = Edges::try_from(bevy_image).unwrap();
assert_eq!(dynamic_edges.single_raw(), bevy_edges.single_raw());
assert_eq!(
dynamic_edges.single_translated(),
bevy_edges.single_translated()
);
}
#[test]
fn same_images_same_edges() {
let dynamic_image = image::open(Path::new("assets/boulders.png")).unwrap();
let dynamic_edges = Edges::from(dynamic_image);
let bevy_image = Image::from_buffer(
include_bytes!("../assets/boulders.png"), // buffer
ImageType::Extension("png"),
CompressedImageFormats::default(),
true,
ImageSampler::default(),
RenderAssetUsages::default(),
)
.unwrap();
let bevy_edges = Edges::try_from(bevy_image).unwrap();
assert_eq!(dynamic_edges.multi_raw(), bevy_edges.multi_raw());
assert_eq!(
dynamic_edges.multi_translated(),
bevy_edges.multi_translated()
);
}