diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 15:00:41 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-03-09 15:00:41 -0700 |
commit | 7a7f497b483cd65e340064f23ed1c73425ecba0a (patch) | |
tree | d5c99ea22a1e10300d06165f8ac96df6b0dc59e1 /test/unit/indent_spec.lua | |
parent | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (diff) | |
parent | ade1b12f49c3b3914c74847d791eb90ea90b56b7 (diff) | |
download | rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.gz rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.tar.bz2 rneovim-7a7f497b483cd65e340064f23ed1c73425ecba0a.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpost
Diffstat (limited to 'test/unit/indent_spec.lua')
-rw-r--r-- | test/unit/indent_spec.lua | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/test/unit/indent_spec.lua b/test/unit/indent_spec.lua index ec86822b55..7902918c54 100644 --- a/test/unit/indent_spec.lua +++ b/test/unit/indent_spec.lua @@ -1,10 +1,12 @@ -local helpers = require("test.unit.helpers")(after_each) +local helpers = require('test.unit.helpers')(after_each) local itp = helpers.gen_itp(it) -local eq = helpers.eq +local to_cstr = helpers.to_cstr +local ffi = helpers.ffi +local eq = helpers.eq -local indent = helpers.cimport("./src/nvim/indent.h") -local globals = helpers.cimport("./src/nvim/globals.h") +local indent = helpers.cimport('./src/nvim/indent.h') +local globals = helpers.cimport('./src/nvim/globals.h') describe('get_sts_value', function() itp([[returns 'softtabstop' when it is non-negative]], function() @@ -28,3 +30,31 @@ describe('get_sts_value', function() eq(tabstop, indent.get_sts_value()) end) end) + +describe('indent_size_ts()', function() + itp('works for spaces', function() + local line = to_cstr((' '):rep(7) .. 'a ') + eq(7, indent.indent_size_ts(line, 100, nil)) + end) + + itp('works for tabs and spaces', function() + local line = to_cstr(' \t \t \t\t a ') + eq(19, indent.indent_size_ts(line, 4, nil)) + end) + + itp('works for tabs and spaces with empty vts', function() + local vts = ffi.new('int[1]') -- zero initialized => first element (size) == 0 + local line = to_cstr(' \t \t \t\t a ') + eq(23, indent.indent_size_ts(line, 4, vts)) + end) + + itp('works for tabs and spaces with vts', function() + local vts = ffi.new('int[3]') + vts[0] = 2 -- zero indexed + vts[1] = 7 + vts[2] = 2 + + local line = to_cstr(' \t \t \t\t a ') + eq(18, indent.indent_size_ts(line, 4, vts)) + end) +end) |