author | unC0Rr |
Sun, 12 Feb 2023 14:19:02 +0100 | |
branch | transitional_engine |
changeset 15918 | 9bd828451d77 |
parent 15917 | 60b5639cc3a5 |
child 15919 | 659c92124c26 |
permissions | -rw-r--r-- |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
1 |
use super::transform::Transform; |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
2 |
use integral_geometry::Size; |
15913 | 3 |
use std::rc::Rc; |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
4 |
use vec2d::Vec2D; |
15913 | 5 |
|
15917 | 6 |
#[derive(PartialEq, Clone, Debug)] |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
7 |
pub struct Edge<I: PartialEq + Clone> { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
8 |
id: I, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
9 |
symmetrical: bool, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
10 |
reverse: bool, |
15913 | 11 |
} |
12 |
||
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
13 |
impl<I: PartialEq + Clone> Edge<I> { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
14 |
pub fn new(id: I, symmetrical: bool) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
15 |
Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
16 |
id, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
17 |
symmetrical, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
18 |
reverse: false, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
19 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
20 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
21 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
22 |
pub fn reversed(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
23 |
Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
24 |
id: self.id.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
25 |
symmetrical: self.symmetrical, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
26 |
reverse: !self.symmetrical && !self.reverse, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
27 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
28 |
} |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
29 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
30 |
pub fn is_compatible(&self, other: &Self) -> bool { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
31 |
self.id == other.id && (self.reverse != other.reverse || self.symmetrical) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
32 |
} |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
33 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
34 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
35 |
#[derive(Clone)] |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
36 |
pub struct TileImage<T, I: PartialEq + Clone> { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
37 |
image: Rc<Vec2D<T>>, |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
38 |
transform: Transform, |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
39 |
top: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
40 |
right: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
41 |
bottom: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
42 |
left: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
43 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
44 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
45 |
impl<T: Copy, I: PartialEq + Clone> TileImage<T, I> { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
46 |
pub fn new( |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
47 |
image: Vec2D<T>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
48 |
top: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
49 |
right: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
50 |
bottom: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
51 |
left: Edge<I>, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
52 |
) -> Self { |
15913 | 53 |
Self { |
15915 | 54 |
image: Rc::new(image), |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
55 |
transform: Transform::default(), |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
56 |
top, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
57 |
right, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
58 |
bottom, |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
59 |
left, |
15913 | 60 |
} |
61 |
} |
|
62 |
||
63 |
pub fn mirrored(&self) -> Self { |
|
64 |
Self { |
|
65 |
image: self.image.clone(), |
|
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
66 |
transform: self.transform.mirror(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
67 |
top: self.top.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
68 |
right: self.left.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
69 |
bottom: self.bottom.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
70 |
left: self.right.reversed(), |
15913 | 71 |
} |
72 |
} |
|
73 |
||
74 |
pub fn flipped(&self) -> Self { |
|
75 |
Self { |
|
76 |
image: self.image.clone(), |
|
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
77 |
transform: self.transform.flip(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
78 |
top: self.bottom.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
79 |
right: self.right.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
80 |
bottom: self.top.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
81 |
left: self.left.reversed(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
82 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
83 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
84 |
|
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
85 |
pub fn rotated90(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
86 |
Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
87 |
image: self.image.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
88 |
transform: self.transform.rotate90(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
89 |
top: self.left.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
90 |
right: self.top.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
91 |
bottom: self.right.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
92 |
left: self.bottom.clone(), |
15913 | 93 |
} |
94 |
} |
|
15915 | 95 |
|
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
96 |
pub fn rotated180(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
97 |
Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
98 |
image: self.image.clone(), |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
99 |
transform: self.transform.rotate180(), |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
100 |
top: self.bottom.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
101 |
right: self.left.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
102 |
bottom: self.top.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
103 |
left: self.right.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
104 |
} |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
105 |
} |
15915 | 106 |
|
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
107 |
pub fn rotated270(&self) -> Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
108 |
Self { |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
109 |
image: self.image.clone(), |
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
110 |
transform: self.transform.rotate270(), |
15916
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
111 |
top: self.left.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
112 |
right: self.top.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
113 |
bottom: self.right.clone(), |
e82de0410da5
Rework how rules are defined, add transformations for tiles
unC0Rr
parents:
15915
diff
changeset
|
114 |
left: self.bottom.clone(), |
15915 | 115 |
} |
116 |
} |
|
15917 | 117 |
|
118 |
pub fn right_edge(&self) -> &Edge<I> { |
|
119 |
&self.right |
|
120 |
} |
|
121 |
||
122 |
pub fn bottom_edge(&self) -> &Edge<I> { |
|
123 |
&self.bottom |
|
124 |
} |
|
125 |
||
126 |
pub fn left_edge(&self) -> &Edge<I> { |
|
127 |
&self.left |
|
128 |
} |
|
129 |
||
130 |
pub fn top_edge(&self) -> &Edge<I> { |
|
131 |
&self.top |
|
132 |
} |
|
15918
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
133 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
134 |
pub fn size(&self) -> Size { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
135 |
match self.transform { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
136 |
Transform::Rotate0(_) => self.image.size(), |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
137 |
Transform::Rotate90(_) => Size::new(self.image.size().height, self.image.size().width), |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
138 |
} |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
139 |
} |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
140 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
141 |
pub fn get(&self, row: usize, column: usize) -> Option<&T> { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
142 |
match self.transform { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
143 |
Transform::Rotate0(_) => { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
144 |
let image_row = if self.transform.is_flipped() { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
145 |
self.image.height().wrapping_sub(1).wrapping_sub(row) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
146 |
} else { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
147 |
row |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
148 |
}; |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
149 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
150 |
let image_column = if self.transform.is_mirrored() { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
151 |
self.image.width().wrapping_sub(1).wrapping_sub(column) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
152 |
} else { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
153 |
column |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
154 |
}; |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
155 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
156 |
self.image.get(image_row, image_column) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
157 |
}, |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
158 |
Transform::Rotate90(_) => { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
159 |
let image_row = if self.transform.is_flipped() { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
160 |
column |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
161 |
} else { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
162 |
self.image.height().wrapping_sub(1).wrapping_sub(column) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
163 |
}; |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
164 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
165 |
let image_column = if self.transform.is_mirrored() { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
166 |
self.image.width().wrapping_sub(1).wrapping_sub(row) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
167 |
} else { |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
168 |
row |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
169 |
}; |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
170 |
|
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
171 |
self.image.get(image_row, image_column) |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
172 |
}, |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
173 |
} |
9bd828451d77
Fix several issues with transformations, more work on getting generated image
unC0Rr
parents:
15917
diff
changeset
|
174 |
} |
15913 | 175 |
} |
15915 | 176 |
|
177 |
#[cfg(test)] |
|
15917 | 178 |
mod tests { |
179 |
use super::*; |
|
180 |
||
181 |
#[test] |
|
182 |
fn test_edge_new() { |
|
183 |
let edge = Edge::new(1, true); |
|
184 |
assert_eq!(edge.id, 1); |
|
185 |
assert_eq!(edge.symmetrical, true); |
|
186 |
assert_eq!(edge.reverse, false); |
|
187 |
} |
|
188 |
||
189 |
#[test] |
|
190 |
fn test_edge_reversed() { |
|
191 |
let edge = Edge::new(1, true); |
|
192 |
let reversed = edge.reversed(); |
|
193 |
assert_eq!(reversed.id, edge.id); |
|
194 |
assert_eq!(reversed.symmetrical, edge.symmetrical); |
|
195 |
assert_eq!(reversed.reverse, false); |
|
196 |
||
197 |
let edge = Edge::new(1, false); |
|
198 |
let reversed = edge.reversed(); |
|
199 |
assert_eq!(reversed.id, edge.id); |
|
200 |
assert_eq!(reversed.symmetrical, edge.symmetrical); |
|
201 |
assert_eq!(reversed.reverse, true); |
|
202 |
} |
|
203 |
||
204 |
#[test] |
|
205 |
fn test_edge_equality() { |
|
206 |
let edge1 = Edge::new(1, true); |
|
207 |
let edge2 = Edge::new(1, true); |
|
208 |
assert_eq!(edge1, edge2); |
|
209 |
||
210 |
let edge1 = Edge::new(1, false); |
|
211 |
let edge2 = Edge::new(1, false); |
|
212 |
assert_eq!(edge1, edge2); |
|
213 |
||
214 |
let edge1 = Edge::new(1, false); |
|
215 |
let edge2 = Edge::new(2, false); |
|
216 |
assert_ne!(edge1, edge2); |
|
217 |
} |
|
218 |
||
219 |
#[test] |
|
220 |
fn test_edge_equality_with_reverse() { |
|
221 |
let edge1 = Edge::new(1, true); |
|
222 |
let edge2 = edge1.reversed(); |
|
223 |
assert_eq!(edge1, edge2); |
|
224 |
||
225 |
let edge1 = Edge::new(1, false); |
|
226 |
let edge2 = edge1.reversed(); |
|
227 |
assert_ne!(edge1, edge2); |
|
228 |
||
229 |
let edge1 = Edge::new(1, true); |
|
230 |
let edge2 = edge1.reversed().reversed(); |
|
231 |
assert_eq!(edge1, edge2); |
|
232 |
} |
|
233 |
} |