diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-11 20:13:57 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-11 20:13:57 +0800 |
commit | 682fc4ac4a593b1abbc2a18a5a4bec7714b77b8c (patch) | |
tree | c5758df27189d4b4f48211e85898f0c9b159feaa | |
parent | c5746e3b0baf4cf60b029693b337e8152a33ce6c (diff) |
Add more arc test
-rw-r--r-- | svgbob/src/map/circle_map.rs | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/svgbob/src/map/circle_map.rs b/svgbob/src/map/circle_map.rs index 7ac1028..56ff681 100644 --- a/svgbob/src/map/circle_map.rs +++ b/svgbob/src/map/circle_map.rs @@ -728,4 +728,108 @@ mod tests { let (arc, _) = endorse_arc(&groups).unwrap(); assert_eq!(arc.radius, 2.5); } + + #[test] + fn test_arc5_bottom_right() { + let art = r#" + ) + -' + "#; + let cell_buffer = CellBuffer::from(art); + let mut spans: Vec<Span> = cell_buffer.group_adjacents(); + assert_eq!(spans.len(), 1); + let span1 = spans.remove(0); + let groups = span1.get_contacts(&Settings::default()); + for (i, group) in groups.iter().enumerate() { + println!("group{}\n{}", i, group); + } + let (arc, _) = endorse_arc(&groups).unwrap(); + assert_eq!(arc.radius, 2.5); + } + + #[test] + fn test_arc20_top_right() { + let art = r#" + ''''-._ + `. + \ + . + | + | + "#; + let cell_buffer = CellBuffer::from(art); + let mut spans: Vec<Span> = cell_buffer.group_adjacents(); + assert_eq!(spans.len(), 1); + let span1 = spans.remove(0); + let groups = span1.get_contacts(&Settings::default()); + for (i, group) in groups.iter().enumerate() { + println!("group{}\n{}", i, group); + } + let (arc, _) = endorse_arc(&groups).unwrap(); + assert_eq!(arc.radius, 10.5); //also matched the arc21 radius and since larger it will matched it instead of arc20 + } + + #[test] + fn test_arc20_top_left() { + let art = r#" + _.-'''' + ,' + / + . + | + | + "#; + let cell_buffer = CellBuffer::from(art); + let mut spans: Vec<Span> = cell_buffer.group_adjacents(); + assert_eq!(spans.len(), 1); + let span1 = spans.remove(0); + let groups = span1.get_contacts(&Settings::default()); + for (i, group) in groups.iter().enumerate() { + println!("group{}\n{}", i, group); + } + let (arc, _) = endorse_arc(&groups).unwrap(); + assert_eq!(arc.radius, 10.5); //also matched the arc21 radius and since larger it will matched it instead of arc20 + } + + #[test] + fn test_arc20_bottom_left() { + let art = r#" + | + | + \ + `._ + '-.... + "#; + let cell_buffer = CellBuffer::from(art); + let mut spans: Vec<Span> = cell_buffer.group_adjacents(); + assert_eq!(spans.len(), 1); + let span1 = spans.remove(0); + let groups = span1.get_contacts(&Settings::default()); + for (i, group) in groups.iter().enumerate() { + println!("group{}\n{}", i, group); + } + let (arc, _) = endorse_arc(&groups).unwrap(); + assert_eq!(arc.radius, 10.0); + } + + #[test] + fn test_arc20_bottom_right() { + let art = r#" + | + | + / + _.' + ....-' + "#; + let cell_buffer = CellBuffer::from(art); + let mut spans: Vec<Span> = cell_buffer.group_adjacents(); + assert_eq!(spans.len(), 1); + let span1 = spans.remove(0); + let groups = span1.get_contacts(&Settings::default()); + for (i, group) in groups.iter().enumerate() { + println!("group{}\n{}", i, group); + } + let (arc, _) = endorse_arc(&groups).unwrap(); + assert_eq!(arc.radius, 10.0); + } } |