Skip to content

Commit 6ddad98

Browse files
Merge pull request #42 from mikhailofff/main
Add tests for string slice edge cases
2 parents 1ed13fe + a85f280 commit 6ddad98

3 files changed

Lines changed: 280 additions & 172 deletions

File tree

iOverlay/src/string/clip.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl IntClip for [IntPoint] {
247247
#[cfg(test)]
248248
mod tests {
249249
use alloc::vec;
250-
use i_float::int::point::IntPoint;
250+
use i_float::int::point::IntPoint;
251251
use i_shape::int::path::IntPath;
252252
use crate::core::fill_rule::FillRule;
253253
use crate::string::clip::{ClipRule, IntClip};
@@ -344,11 +344,11 @@ use i_float::int::point::IntPoint;
344344
];
345345

346346
let result_0 = rect.clip_path(&path, FillRule::NonZero,
347-
ClipRule { invert: false, boundary_included: false },
347+
ClipRule { invert: false, boundary_included: false },
348348
);
349349

350350
let result_1 = rect.clip_path(&path, FillRule::NonZero,
351-
ClipRule { invert: false, boundary_included: true },
351+
ClipRule { invert: false, boundary_included: true },
352352
);
353353

354354
assert_eq!(result_0.len(), 3);

iOverlay/src/string/extract.rs

Lines changed: 0 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ mod tests {
225225
use crate::core::fill_rule::FillRule;
226226
use crate::string::overlay::StringOverlay;
227227
use crate::string::rule::StringRule;
228-
use crate::string::slice::IntSlice;
229228
use alloc::vec;
230229
use i_float::int::point::IntPoint;
231230

@@ -238,56 +237,6 @@ mod tests {
238237
IntPoint::new(10, 10),
239238
]];
240239

241-
let result = paths.slice_by_line(
242-
[IntPoint::new(-20, 0), IntPoint::new(20, 0)],
243-
FillRule::NonZero,
244-
);
245-
246-
assert_eq!(result.len(), 2);
247-
assert_eq!(result[0].len(), 1);
248-
assert_eq!(result[0][0].len(), 4);
249-
assert_eq!(result[1].len(), 1);
250-
assert_eq!(result[1][0].len(), 4);
251-
}
252-
253-
#[test]
254-
fn test_1() {
255-
let paths = vec![
256-
vec![
257-
IntPoint::new(-10, 10),
258-
IntPoint::new(-10, -10),
259-
IntPoint::new(10, -10),
260-
IntPoint::new(10, 10),
261-
],
262-
vec![
263-
IntPoint::new(-5, -5),
264-
IntPoint::new(-5, 5),
265-
IntPoint::new(5, 5),
266-
IntPoint::new(5, -5),
267-
],
268-
];
269-
270-
let result = paths.slice_by_line(
271-
[IntPoint::new(-20, 0), IntPoint::new(20, 0)],
272-
FillRule::NonZero,
273-
);
274-
275-
assert_eq!(result.len(), 2);
276-
assert_eq!(result[0].len(), 1);
277-
assert_eq!(result[0][0].len(), 8);
278-
assert_eq!(result[1].len(), 1);
279-
assert_eq!(result[1][0].len(), 8);
280-
}
281-
282-
#[test]
283-
fn test_2() {
284-
let paths = vec![vec![
285-
IntPoint::new(-10, 10),
286-
IntPoint::new(-10, -10),
287-
IntPoint::new(10, -10),
288-
IntPoint::new(10, 10),
289-
]];
290-
291240
let window = vec![
292241
IntPoint::new(-5, -5),
293242
IntPoint::new(-5, 5),
@@ -303,122 +252,4 @@ mod tests {
303252

304253
assert_eq!(r.len(), 2);
305254
}
306-
307-
#[test]
308-
fn test_3() {
309-
let paths = vec![
310-
vec![
311-
IntPoint::new(0, 0),
312-
IntPoint::new(35, 0),
313-
IntPoint::new(35, 20),
314-
IntPoint::new(0, 20),
315-
],
316-
vec![
317-
IntPoint::new(5, 5),
318-
IntPoint::new(5, 15),
319-
IntPoint::new(15, 15),
320-
IntPoint::new(15, 5),
321-
],
322-
vec![
323-
IntPoint::new(20, 5),
324-
IntPoint::new(20, 15),
325-
IntPoint::new(30, 15),
326-
IntPoint::new(30, 5),
327-
],
328-
];
329-
330-
let result = paths.slice_by_line(
331-
[IntPoint::new(15, 10), IntPoint::new(20, 10)],
332-
FillRule::NonZero,
333-
);
334-
335-
assert_eq!(result.len(), 1);
336-
assert_eq!(result[0].len(), 3);
337-
}
338-
339-
#[test]
340-
fn test_4() {
341-
let paths = vec![
342-
vec![
343-
IntPoint::new(0, 0),
344-
IntPoint::new(35, 0),
345-
IntPoint::new(35, 20),
346-
IntPoint::new(0, 20),
347-
],
348-
vec![
349-
IntPoint::new(5, 5),
350-
IntPoint::new(5, 15),
351-
IntPoint::new(15, 15),
352-
IntPoint::new(15, 5),
353-
],
354-
vec![
355-
IntPoint::new(20, 5),
356-
IntPoint::new(20, 15),
357-
IntPoint::new(30, 15),
358-
IntPoint::new(30, 5),
359-
],
360-
];
361-
362-
let result = paths.slice_by_lines(
363-
&vec![
364-
[IntPoint::new(15, 5), IntPoint::new(20, 5)],
365-
[IntPoint::new(15, 15), IntPoint::new(20, 15)],
366-
],
367-
FillRule::NonZero,
368-
);
369-
370-
assert_eq!(result.len(), 2);
371-
assert_eq!(result[0].len(), 2);
372-
assert_eq!(result[1].len(), 1);
373-
}
374-
375-
#[test]
376-
fn test_5() {
377-
let paths = vec![
378-
vec![
379-
IntPoint::new(0, 0),
380-
IntPoint::new(35, 0),
381-
IntPoint::new(35, 35),
382-
IntPoint::new(0, 35),
383-
],
384-
vec![
385-
IntPoint::new(5, 5),
386-
IntPoint::new(5, 15),
387-
IntPoint::new(15, 15),
388-
IntPoint::new(15, 5),
389-
],
390-
vec![
391-
IntPoint::new(20, 5),
392-
IntPoint::new(20, 15),
393-
IntPoint::new(30, 15),
394-
IntPoint::new(30, 5),
395-
],
396-
vec![
397-
IntPoint::new(5, 20),
398-
IntPoint::new(5, 30),
399-
IntPoint::new(15, 30),
400-
IntPoint::new(15, 20),
401-
],
402-
vec![
403-
IntPoint::new(20, 20),
404-
IntPoint::new(20, 30),
405-
IntPoint::new(30, 30),
406-
IntPoint::new(30, 20),
407-
],
408-
];
409-
410-
let result = paths.slice_by_lines(
411-
&vec![
412-
[IntPoint::new(10, 15), IntPoint::new(10, 20)],
413-
[IntPoint::new(25, 15), IntPoint::new(25, 20)],
414-
[IntPoint::new(15, 10), IntPoint::new(20, 10)],
415-
[IntPoint::new(15, 25), IntPoint::new(20, 25)],
416-
],
417-
FillRule::NonZero,
418-
);
419-
420-
assert_eq!(result.len(), 2);
421-
assert_eq!(result[0].len(), 2);
422-
assert_eq!(result[1].len(), 1);
423-
}
424255
}

0 commit comments

Comments
 (0)