rust/landgen/src/wavefront_collapse/tile_image.rs
author unC0Rr
Fri, 03 Feb 2023 15:59:18 +0100
branchtransitional_engine
changeset 15917 60b5639cc3a5
parent 15916 e82de0410da5
child 15918 9bd828451d77
permissions -rw-r--r--
Add WIP for generation of rules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     1
use super::transform::RotationTransform;
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
     2
use std::rc::Rc;
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     3
use vec2d::Vec2D;
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
     4
15917
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
     5
#[derive(PartialEq, Clone, Debug)]
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     6
pub struct Edge<I: PartialEq + Clone> {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     7
    id: I,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     8
    symmetrical: bool,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
     9
    reverse: bool,
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    10
}
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    11
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    12
impl<I: PartialEq + Clone> Edge<I> {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    13
    pub fn new(id: I, symmetrical: bool) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    14
        Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    15
            id,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    16
            symmetrical,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    17
            reverse: false,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    18
        }
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
    pub fn reversed(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    22
        Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    23
            id: self.id.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    24
            symmetrical: self.symmetrical,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    25
            reverse: !self.symmetrical && !self.reverse,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    26
        }
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
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    29
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    30
#[derive(Clone)]
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    31
pub struct TileImage<T, I: PartialEq + Clone> {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    32
    image: Rc<Vec2D<T>>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    33
    transform: RotationTransform,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    34
    top: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    35
    right: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    36
    bottom: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    37
    left: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    38
}
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    39
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    40
impl<T: Copy, I: PartialEq + Clone> TileImage<T, I> {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    41
    pub fn new(
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    42
        image: Vec2D<T>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    43
        top: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    44
        right: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    45
        bottom: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    46
        left: Edge<I>,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    47
    ) -> Self {
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    48
        Self {
15915
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
    49
            image: Rc::new(image),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    50
            transform: RotationTransform::default(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    51
            top,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    52
            right,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    53
            bottom,
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    54
            left,
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    55
        }
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    56
    }
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    57
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    58
    pub fn mirrored(&self) -> Self {
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    59
        Self {
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    60
            image: self.image.clone(),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    61
            transform: self.transform.mirror(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    62
            top: self.top.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    63
            right: self.left.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    64
            bottom: self.bottom.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    65
            left: self.right.reversed(),
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    66
        }
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    67
    }
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    68
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    69
    pub fn flipped(&self) -> Self {
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    70
        Self {
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    71
            image: self.image.clone(),
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    72
            transform: self.transform.flip(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    73
            top: self.bottom.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    74
            right: self.right.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    75
            bottom: self.top.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    76
            left: self.left.reversed(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    77
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    78
    }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    79
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    80
    pub fn rotated90(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    81
        Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    82
            image: self.image.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    83
            transform: self.transform.rotate90(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    84
            top: self.left.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    85
            right: self.top.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    86
            bottom: self.right.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    87
            left: self.bottom.clone(),
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    88
        }
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
    89
    }
15915
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
    90
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    91
    pub fn rotated180(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    92
        Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    93
            image: self.image.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    94
            transform: self.transform.rotate90(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    95
            top: self.bottom.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    96
            right: self.left.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    97
            bottom: self.top.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    98
            left: self.right.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
    99
        }
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   100
    }
15915
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
   101
15916
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   102
    pub fn rotated270(&self) -> Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   103
        Self {
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   104
            image: self.image.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   105
            transform: self.transform.rotate90(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   106
            top: self.left.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   107
            right: self.top.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   108
            bottom: self.right.clone(),
e82de0410da5 Rework how rules are defined, add transformations for tiles
unC0Rr
parents: 15915
diff changeset
   109
            left: self.bottom.clone(),
15915
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
   110
        }
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
   111
    }
15917
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   112
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   113
    pub fn right_edge(&self) -> &Edge<I> {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   114
        &self.right
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   115
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   116
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   117
    pub fn bottom_edge(&self) -> &Edge<I> {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   118
        &self.bottom
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   119
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   120
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   121
    pub fn left_edge(&self) -> &Edge<I> {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   122
        &self.left
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   123
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   124
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   125
    pub fn top_edge(&self) -> &Edge<I> {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   126
        &self.top
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   127
    }
15913
c5684cc62de8 Switch to Vec2D in wavefront algorithm
unC0Rr
parents:
diff changeset
   128
}
15915
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
   129
8f093b1b18bc Add loading of tiles from png
unC0Rr
parents: 15913
diff changeset
   130
#[cfg(test)]
15917
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   131
mod tests {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   132
    use super::*;
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   133
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   134
    #[test]
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   135
    fn test_edge_new() {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   136
        let edge = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   137
        assert_eq!(edge.id, 1);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   138
        assert_eq!(edge.symmetrical, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   139
        assert_eq!(edge.reverse, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   140
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   141
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   142
    #[test]
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   143
    fn test_edge_reversed() {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   144
        let edge = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   145
        let reversed = edge.reversed();
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   146
        assert_eq!(reversed.id, edge.id);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   147
        assert_eq!(reversed.symmetrical, edge.symmetrical);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   148
        assert_eq!(reversed.reverse, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   149
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   150
        let edge = Edge::new(1, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   151
        let reversed = edge.reversed();
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   152
        assert_eq!(reversed.id, edge.id);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   153
        assert_eq!(reversed.symmetrical, edge.symmetrical);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   154
        assert_eq!(reversed.reverse, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   155
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   156
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   157
    #[test]
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   158
    fn test_edge_equality() {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   159
        let edge1 = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   160
        let edge2 = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   161
        assert_eq!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   162
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   163
        let edge1 = Edge::new(1, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   164
        let edge2 = Edge::new(1, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   165
        assert_eq!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   166
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   167
        let edge1 = Edge::new(1, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   168
        let edge2 = Edge::new(2, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   169
        assert_ne!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   170
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   171
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   172
    #[test]
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   173
    fn test_edge_equality_with_reverse() {
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   174
        let edge1 = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   175
        let edge2 = edge1.reversed();
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   176
        assert_eq!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   177
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   178
        let edge1 = Edge::new(1, false);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   179
        let edge2 = edge1.reversed();
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   180
        assert_ne!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   181
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   182
        let edge1 = Edge::new(1, true);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   183
        let edge2 = edge1.reversed().reversed();
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   184
        assert_eq!(edge1, edge2);
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   185
    }
60b5639cc3a5 Add WIP for generation of rules
unC0Rr
parents: 15916
diff changeset
   186
}