Move LineWrapper test to line_wrapper.rs

This commit is contained in:
Max Brunsfeld
2021-07-22 20:42:18 -07:00
parent 5d22c6c4bd
commit 53fd3a1a92
2 changed files with 37 additions and 32 deletions
@@ -106,3 +106,40 @@ impl LineWrapper {
.width
}
}
#[cfg(test)]
mod tests {
use super::*;
#[gpui::test]
fn test_line_wrapper(cx: &mut gpui::MutableAppContext) {
let font_cache = cx.font_cache().clone();
let font_system = cx.platform().fonts();
let settings = Settings {
tab_size: 4,
buffer_font_family: font_cache.load_family(&["Courier"]).unwrap(),
buffer_font_size: 16.0,
..Settings::new(&font_cache).unwrap()
};
let mut wrapper = LineWrapper::new(font_system, font_cache, settings);
assert_eq!(
wrapper.wrap_line_with_shaping("aa bbb cccc ddddd eeee", 72.0),
&[7, 12, 18],
);
assert_eq!(
wrapper.wrap_line_without_shaping("aa bbb cccc ddddd eeee", 72.0),
&[7, 12, 18],
);
assert_eq!(
wrapper.wrap_line_with_shaping("aaa aaaaaaaaaaaaaaaaaa", 72.0),
&[4, 11, 18],
);
assert_eq!(
wrapper.wrap_line_without_shaping("aaa aaaaaaaaaaaaaaaaaa", 72.0),
&[4, 11, 18],
);
}
}
-32
View File
@@ -741,38 +741,6 @@ mod tests {
use rand::prelude::*;
use std::env;
#[gpui::test]
fn test_line_wrapper(cx: &mut gpui::MutableAppContext) {
let font_cache = cx.font_cache().clone();
let font_system = cx.platform().fonts();
let settings = Settings {
tab_size: 4,
buffer_font_family: font_cache.load_family(&["Courier"]).unwrap(),
buffer_font_size: 16.0,
..Settings::new(&font_cache).unwrap()
};
let mut wrapper = LineWrapper::new(font_system, font_cache, settings);
assert_eq!(
wrapper.wrap_line_with_shaping("aa bbb cccc ddddd eeee", 72.0),
&[7, 12, 18],
);
assert_eq!(
wrapper.wrap_line_without_shaping("aa bbb cccc ddddd eeee", 72.0),
&[7, 12, 18],
);
assert_eq!(
wrapper.wrap_line_with_shaping("aaa aaaaaaaaaaaaaaaaaa", 72.0),
&[4, 11, 18],
);
assert_eq!(
wrapper.wrap_line_without_shaping("aaa aaaaaaaaaaaaaaaaaa", 72.0),
&[4, 11, 18],
);
}
#[gpui::test]
fn test_random_wraps(cx: &mut gpui::MutableAppContext) {
let iterations = env::var("ITERATIONS")