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/memory_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/memory_spec.lua')
-rw-r--r-- | test/unit/memory_spec.lua | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/unit/memory_spec.lua b/test/unit/memory_spec.lua index bd72c8bf47..8be55fdbf3 100644 --- a/test/unit/memory_spec.lua +++ b/test/unit/memory_spec.lua @@ -1,4 +1,4 @@ -local helpers = require("test.unit.helpers")(after_each) +local helpers = require('test.unit.helpers')(after_each) local itp = helpers.gen_itp(it) local cimport = helpers.cimport @@ -11,7 +11,7 @@ local cimp = cimport('stdlib.h', './src/nvim/memory.h') describe('xstrlcat()', function() local function test_xstrlcat(dst, src, dsize) - assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests + assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests local dst_cstr = cstr(dsize, dst) local src_cstr = to_cstr(src) eq(string.len(dst .. src), cimp.xstrlcat(dst_cstr, src_cstr, dsize)) @@ -19,34 +19,32 @@ describe('xstrlcat()', function() end local function test_xstrlcat_overlap(dst, src_idx, dsize) - assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests + assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests local dst_cstr = cstr(dsize, dst) - local src_cstr = dst_cstr + src_idx -- pointer into `dst` (overlaps) - eq(string.len(dst) + string.len(dst) - src_idx, - cimp.xstrlcat(dst_cstr, src_cstr, dsize)) + local src_cstr = dst_cstr + src_idx -- pointer into `dst` (overlaps) + eq(string.len(dst) + string.len(dst) - src_idx, cimp.xstrlcat(dst_cstr, src_cstr, dsize)) return ffi.string(dst_cstr) end itp('concatenates strings', function() eq('ab', test_xstrlcat('a', 'b', 3)) eq('ab', test_xstrlcat('a', 'b', 4096)) - eq('ABCיהZdefgiיהZ', test_xstrlcat('ABCיהZ', 'defgiיהZ', 4096)) - eq('b', test_xstrlcat('', 'b', 4096)) - eq('a', test_xstrlcat('a', '', 4096)) + eq('ABCיהZdefgiיהZ', test_xstrlcat('ABCיהZ', 'defgiיהZ', 4096)) + eq('b', test_xstrlcat('', 'b', 4096)) + eq('a', test_xstrlcat('a', '', 4096)) end) itp('concatenates overlapping strings', function() - eq('abcabc', test_xstrlcat_overlap('abc', 0, 7)) - eq('abca', test_xstrlcat_overlap('abc', 0, 5)) - eq('abcb', test_xstrlcat_overlap('abc', 1, 5)) - eq('abcc', test_xstrlcat_overlap('abc', 2, 10)) - eq('abcabc', test_xstrlcat_overlap('abc', 0, 2343)) + eq('abcabc', test_xstrlcat_overlap('abc', 0, 7)) + eq('abca', test_xstrlcat_overlap('abc', 0, 5)) + eq('abcb', test_xstrlcat_overlap('abc', 1, 5)) + eq('abcc', test_xstrlcat_overlap('abc', 2, 10)) + eq('abcabc', test_xstrlcat_overlap('abc', 0, 2343)) end) itp('truncates if `dsize` is too small', function() eq('a', test_xstrlcat('a', 'b', 2)) eq('', test_xstrlcat('', 'b', 1)) - eq('ABCיהZd', test_xstrlcat('ABCיהZ', 'defgiיהZ', 10)) + eq('ABCיהZd', test_xstrlcat('ABCיהZ', 'defgiיהZ', 10)) end) - end) |