about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Davis <ariel.z.davis@icloud.com>2023-05-05 17:22:23 -0700
committerAriel Davis <ariel.z.davis@icloud.com>2023-05-06 00:49:23 -0700
commit663e11c4b053943426533a60cb61a52598bb203b (patch)
treecd692537bbd437912b64f79f4df002b9f45426d3
parentda5c63c8f90b7cf66d94626352141dc3f0585b6e (diff)
downloadrust-663e11c4b053943426533a60cb61a52598bb203b.tar.gz
rust-663e11c4b053943426533a60cb61a52598bb203b.zip
Move some tests
-rw-r--r--lib/line-index/src/tests.rs64
-rw-r--r--lib/line-index/tests/it.rs63
2 files changed, 64 insertions, 63 deletions
diff --git a/lib/line-index/src/tests.rs b/lib/line-index/src/tests.rs
index 4b58cfc47dd..31c01c20ee3 100644
--- a/lib/line-index/src/tests.rs
+++ b/lib/line-index/src/tests.rs
@@ -1,38 +1,4 @@
-use super::*;
-
-#[test]
-fn test_line_index() {
-    let text = "hello\nworld";
-    let table = [
-        (00, 0, 0),
-        (01, 0, 1),
-        (05, 0, 5),
-        (06, 1, 0),
-        (07, 1, 1),
-        (08, 1, 2),
-        (10, 1, 4),
-        (11, 1, 5),
-        (12, 1, 6),
-    ];
-
-    let index = LineIndex::new(text);
-    for (offset, line, col) in table {
-        assert_eq!(index.line_col(offset.into()), LineCol { line, col });
-    }
-
-    let text = "\nhello\nworld";
-    let table = [(0, 0, 0), (1, 1, 0), (2, 1, 1), (6, 1, 5), (7, 2, 0)];
-    let index = LineIndex::new(text);
-    for (offset, line, col) in table {
-        assert_eq!(index.line_col(offset.into()), LineCol { line, col });
-    }
-}
-
-#[test]
-fn test_char_len() {
-    assert_eq!('メ'.len_utf8(), 3);
-    assert_eq!('メ'.len_utf16(), 1);
-}
+use super::LineIndex;
 
 #[test]
 fn test_empty_index() {
@@ -43,31 +9,3 @@ const C: char = 'x';
     );
     assert_eq!(col_index.line_wide_chars.len(), 0);
 }
-
-#[test]
-fn test_splitlines() {
-    fn r(lo: u32, hi: u32) -> TextRange {
-        TextRange::new(lo.into(), hi.into())
-    }
-
-    let text = "a\nbb\nccc\n";
-    let line_index = LineIndex::new(text);
-
-    let actual = line_index.lines(r(0, 9)).collect::<Vec<_>>();
-    let expected = vec![r(0, 2), r(2, 5), r(5, 9)];
-    assert_eq!(actual, expected);
-
-    let text = "";
-    let line_index = LineIndex::new(text);
-
-    let actual = line_index.lines(r(0, 0)).collect::<Vec<_>>();
-    let expected = vec![];
-    assert_eq!(actual, expected);
-
-    let text = "\n";
-    let line_index = LineIndex::new(text);
-
-    let actual = line_index.lines(r(0, 1)).collect::<Vec<_>>();
-    let expected = vec![r(0, 1)];
-    assert_eq!(actual, expected)
-}
diff --git a/lib/line-index/tests/it.rs b/lib/line-index/tests/it.rs
new file mode 100644
index 00000000000..fcaf0e4a8c9
--- /dev/null
+++ b/lib/line-index/tests/it.rs
@@ -0,0 +1,63 @@
+use line_index::{LineCol, LineIndex, TextRange};
+
+#[test]
+fn test_line_index() {
+    let text = "hello\nworld";
+    let table = [
+        (00, 0, 0),
+        (01, 0, 1),
+        (05, 0, 5),
+        (06, 1, 0),
+        (07, 1, 1),
+        (08, 1, 2),
+        (10, 1, 4),
+        (11, 1, 5),
+        (12, 1, 6),
+    ];
+
+    let index = LineIndex::new(text);
+    for (offset, line, col) in table {
+        assert_eq!(index.line_col(offset.into()), LineCol { line, col });
+    }
+
+    let text = "\nhello\nworld";
+    let table = [(0, 0, 0), (1, 1, 0), (2, 1, 1), (6, 1, 5), (7, 2, 0)];
+    let index = LineIndex::new(text);
+    for (offset, line, col) in table {
+        assert_eq!(index.line_col(offset.into()), LineCol { line, col });
+    }
+}
+
+#[test]
+fn test_char_len() {
+    assert_eq!('メ'.len_utf8(), 3);
+    assert_eq!('メ'.len_utf16(), 1);
+}
+
+#[test]
+fn test_splitlines() {
+    fn r(lo: u32, hi: u32) -> TextRange {
+        TextRange::new(lo.into(), hi.into())
+    }
+
+    let text = "a\nbb\nccc\n";
+    let line_index = LineIndex::new(text);
+
+    let actual = line_index.lines(r(0, 9)).collect::<Vec<_>>();
+    let expected = vec![r(0, 2), r(2, 5), r(5, 9)];
+    assert_eq!(actual, expected);
+
+    let text = "";
+    let line_index = LineIndex::new(text);
+
+    let actual = line_index.lines(r(0, 0)).collect::<Vec<_>>();
+    let expected = vec![];
+    assert_eq!(actual, expected);
+
+    let text = "\n";
+    let line_index = LineIndex::new(text);
+
+    let actual = line_index.lines(r(0, 1)).collect::<Vec<_>>();
+    let expected = vec![r(0, 1)];
+    assert_eq!(actual, expected)
+}