diff options
author | Aleksey Kladov <[email protected]> | 2021-02-12 18:24:10 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-02-16 16:17:32 +0000 |
commit | 2cb4ac9eb4cb02e7d14ec50a9e7d8e9fe49a4ec1 (patch) | |
tree | d70cb9c9c61359ba0b171e3e38267e42bcb00b0b /crates/ide_db/src/line_index | |
parent | cc49502ab47bcd20c90589226282b8f3c3df5190 (diff) |
Prepare for utf-8 offsets
Diffstat (limited to 'crates/ide_db/src/line_index')
-rw-r--r-- | crates/ide_db/src/line_index/tests.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/ide_db/src/line_index/tests.rs b/crates/ide_db/src/line_index/tests.rs index 05f7484e8..1a109654e 100644 --- a/crates/ide_db/src/line_index/tests.rs +++ b/crates/ide_db/src/line_index/tests.rs | |||
@@ -4,23 +4,23 @@ use super::*; | |||
4 | fn test_line_index() { | 4 | fn test_line_index() { |
5 | let text = "hello\nworld"; | 5 | let text = "hello\nworld"; |
6 | let index = LineIndex::new(text); | 6 | let index = LineIndex::new(text); |
7 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | 7 | assert_eq!(index.line_col(0.into()), LineColUtf16 { line: 0, col: 0 }); |
8 | assert_eq!(index.line_col(1.into()), LineCol { line: 0, col_utf16: 1 }); | 8 | assert_eq!(index.line_col(1.into()), LineColUtf16 { line: 0, col: 1 }); |
9 | assert_eq!(index.line_col(5.into()), LineCol { line: 0, col_utf16: 5 }); | 9 | assert_eq!(index.line_col(5.into()), LineColUtf16 { line: 0, col: 5 }); |
10 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 0 }); | 10 | assert_eq!(index.line_col(6.into()), LineColUtf16 { line: 1, col: 0 }); |
11 | assert_eq!(index.line_col(7.into()), LineCol { line: 1, col_utf16: 1 }); | 11 | assert_eq!(index.line_col(7.into()), LineColUtf16 { line: 1, col: 1 }); |
12 | assert_eq!(index.line_col(8.into()), LineCol { line: 1, col_utf16: 2 }); | 12 | assert_eq!(index.line_col(8.into()), LineColUtf16 { line: 1, col: 2 }); |
13 | assert_eq!(index.line_col(10.into()), LineCol { line: 1, col_utf16: 4 }); | 13 | assert_eq!(index.line_col(10.into()), LineColUtf16 { line: 1, col: 4 }); |
14 | assert_eq!(index.line_col(11.into()), LineCol { line: 1, col_utf16: 5 }); | 14 | assert_eq!(index.line_col(11.into()), LineColUtf16 { line: 1, col: 5 }); |
15 | assert_eq!(index.line_col(12.into()), LineCol { line: 1, col_utf16: 6 }); | 15 | assert_eq!(index.line_col(12.into()), LineColUtf16 { line: 1, col: 6 }); |
16 | 16 | ||
17 | let text = "\nhello\nworld"; | 17 | let text = "\nhello\nworld"; |
18 | let index = LineIndex::new(text); | 18 | let index = LineIndex::new(text); |
19 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | 19 | assert_eq!(index.line_col(0.into()), LineColUtf16 { line: 0, col: 0 }); |
20 | assert_eq!(index.line_col(1.into()), LineCol { line: 1, col_utf16: 0 }); | 20 | assert_eq!(index.line_col(1.into()), LineColUtf16 { line: 1, col: 0 }); |
21 | assert_eq!(index.line_col(2.into()), LineCol { line: 1, col_utf16: 1 }); | 21 | assert_eq!(index.line_col(2.into()), LineColUtf16 { line: 1, col: 1 }); |
22 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 5 }); | 22 | assert_eq!(index.line_col(6.into()), LineColUtf16 { line: 1, col: 5 }); |
23 | assert_eq!(index.line_col(7.into()), LineCol { line: 2, col_utf16: 0 }); | 23 | assert_eq!(index.line_col(7.into()), LineColUtf16 { line: 2, col: 0 }); |
24 | } | 24 | } |
25 | 25 | ||
26 | #[test] | 26 | #[test] |