aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/line_index_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/line_index_utils.rs')
-rw-r--r--crates/ra_ide_db/src/line_index_utils.rs42
1 files changed, 0 insertions, 42 deletions
diff --git a/crates/ra_ide_db/src/line_index_utils.rs b/crates/ra_ide_db/src/line_index_utils.rs
index 435b06511..75a498151 100644
--- a/crates/ra_ide_db/src/line_index_utils.rs
+++ b/crates/ra_ide_db/src/line_index_utils.rs
@@ -297,45 +297,3 @@ impl RunningLineCol {
297 self.col_adjust += range.len() - TextUnit::from(1); 297 self.col_adjust += range.len() - TextUnit::from(1);
298 } 298 }
299} 299}
300
301#[cfg(test)]
302mod test {
303 use proptest::{prelude::*, proptest};
304 use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
305 use ra_text_edit::TextEdit;
306
307 use crate::line_index;
308
309 use super::*;
310
311 #[derive(Debug)]
312 struct ArbTextWithEditAndOffset {
313 text: String,
314 edit: TextEdit,
315 edited_text: String,
316 offset: TextUnit,
317 }
318
319 fn arb_text_with_edit_and_offset() -> BoxedStrategy<ArbTextWithEditAndOffset> {
320 arb_text_with_edit()
321 .prop_flat_map(|x| {
322 let edited_text = x.edit.apply(&x.text);
323 let arb_offset = arb_offset(&edited_text);
324 (Just(x), Just(edited_text), arb_offset).prop_map(|(x, edited_text, offset)| {
325 ArbTextWithEditAndOffset { text: x.text, edit: x.edit, edited_text, offset }
326 })
327 })
328 .boxed()
329 }
330
331 proptest! {
332 #[test]
333 fn test_translate_offset_with_edit(x in arb_text_with_edit_and_offset()) {
334 let expected = line_index::to_line_col(&x.edited_text, x.offset);
335 let line_index = LineIndex::new(&x.text);
336 let actual = translate_offset_with_edit(&line_index, x.offset, &x.edit);
337
338 assert_eq!(actual, expected);
339 }
340 }
341}