aboutsummaryrefslogtreecommitdiff
path: root/helix-core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/tests')
-rw-r--r--helix-core/tests/indent.rs35
1 files changed, 34 insertions, 1 deletions
diff --git a/helix-core/tests/indent.rs b/helix-core/tests/indent.rs
index b3c543d6..f558f86f 100644
--- a/helix-core/tests/indent.rs
+++ b/helix-core/tests/indent.rs
@@ -1,5 +1,5 @@
use helix_core::{
- indent::{treesitter_indent_for_pos, IndentStyle},
+ indent::{indent_level_for_line, treesitter_indent_for_pos, IndentStyle},
syntax::Loader,
Syntax,
};
@@ -17,6 +17,39 @@ fn test_treesitter_indent_rust_2() {
// test_treesitter_indent("commands.rs", "source.rust");
}
+#[test]
+fn test_indent_level_for_line_with_spaces() {
+ let tab_width: usize = 4;
+ let indent_width: usize = 4;
+
+ let line = ropey::Rope::from_str(" Indented with 8 spaces");
+
+ let indent_level = indent_level_for_line(line.slice(0..), tab_width, indent_width);
+ assert_eq!(indent_level, 2)
+}
+
+#[test]
+fn test_indent_level_for_line_with_tabs() {
+ let tab_width: usize = 4;
+ let indent_width: usize = 4;
+
+ let line = ropey::Rope::from_str("\t\tIndented with 2 tabs");
+
+ let indent_level = indent_level_for_line(line.slice(0..), tab_width, indent_width);
+ assert_eq!(indent_level, 2)
+}
+
+#[test]
+fn test_indent_level_for_line_with_spaces_and_tabs() {
+ let tab_width: usize = 4;
+ let indent_width: usize = 4;
+
+ let line = ropey::Rope::from_str(" \t \tIndented with mix of spaces and tabs");
+
+ let indent_level = indent_level_for_line(line.slice(0..), tab_width, indent_width);
+ assert_eq!(indent_level, 2)
+}
+
fn test_treesitter_indent(file_name: &str, lang_scope: &str) {
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_dir.push("tests/data/indent");