Mercurial > vim
annotate src/testdir/test_crypt.vim @ 10557:018b7ecc58db v8.0.0168
patch 8.0.0168: not all float functionality is tested
commit https://github.com/vim/vim/commit/872004132f25cabe59352912889e042d6c7e6b4e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 10 16:31:20 2017 +0100
patch 8.0.0168: not all float functionality is tested
Problem: Still some float functionality is not covered by tests.
Solution: Add more tests. (Dominique Pelle, closes https://github.com/vim/vim/issues/1364)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 10 Jan 2017 16:45:04 +0100 |
parents | ebbc8d21105b |
children | 959cf4c63b18 |
rev | line source |
---|---|
10221
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for encryption. |
10231
cbee14cc4da6
commit https://github.com/vim/vim/commit/1eceadaf481e34ed8155011534159775697ce884
Christian Brabandt <cb@256bit.org>
parents:
10225
diff
changeset
|
2 |
cbee14cc4da6
commit https://github.com/vim/vim/commit/1eceadaf481e34ed8155011534159775697ce884
Christian Brabandt <cb@256bit.org>
parents:
10225
diff
changeset
|
3 if !has('cryptv') |
cbee14cc4da6
commit https://github.com/vim/vim/commit/1eceadaf481e34ed8155011534159775697ce884
Christian Brabandt <cb@256bit.org>
parents:
10225
diff
changeset
|
4 finish |
cbee14cc4da6
commit https://github.com/vim/vim/commit/1eceadaf481e34ed8155011534159775697ce884
Christian Brabandt <cb@256bit.org>
parents:
10225
diff
changeset
|
5 endif |
10221
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 func Common_head_only(text) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " This was crashing Vim |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 split Xtest.txt |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call setline(1, a:text) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 wq |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call feedkeys(":split Xtest.txt\<CR>foobar\<CR>", "tx") |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call delete('Xtest.txt') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_match('VimCrypt', getline(1)) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 bwipe! |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endfunc |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 func Test_head_only_2() |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call Common_head_only('VimCrypt~02!abc') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 endfunc |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 func Test_head_only_3() |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call Common_head_only('VimCrypt~03!abc') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 endfunc |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
25 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
26 func Crypt_uncrypt(method) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
27 exe "set cryptmethod=" . a:method |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
28 " If the blowfish test fails 'cryptmethod' will be 'zip' now. |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
29 call assert_equal(a:method, &cryptmethod) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
30 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
31 split Xtest.txt |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
32 let text = ['01234567890123456789012345678901234567', |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
33 \ 'line 2 foo bar blah', |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
34 \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'] |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
35 call setline(1, text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
36 call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
37 w! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
38 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
39 call feedkeys(":split Xtest.txt\<CR>foobar\<CR>", 'xt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
40 call assert_equal(text, getline(1, 3)) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
41 set key= cryptmethod& |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
42 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
43 call delete('Xtest.txt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
44 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
45 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
46 func Test_crypt_zip() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
47 call Crypt_uncrypt('zip') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
48 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
49 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
50 func Test_crypt_blowfish() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
51 call Crypt_uncrypt('blowfish') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
52 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
53 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
54 func Test_crypt_blowfish2() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
55 call Crypt_uncrypt('blowfish2') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
56 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
57 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
58 func Uncrypt_stable(method, crypted_text, key, uncrypted_text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
59 split Xtest.txt |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
60 set bin noeol key= fenc=latin1 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
61 exe "set cryptmethod=" . a:method |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
62 call setline(1, a:crypted_text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
63 w! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
64 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
65 set nobin |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
66 call feedkeys(":split Xtest.txt\<CR>" . a:key . "\<CR>", 'xt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
67 call assert_equal(a:uncrypted_text, getline(1, len(a:uncrypted_text))) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
68 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
69 call delete('Xtest.txt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
70 set key= |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
71 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
72 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
73 func Test_uncrypt_zip() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
74 call Uncrypt_stable('zip', "VimCrypt~01!\u0006\u001clV'\u00de}Mg\u00a0\u00ea\u00a3V\u00a9\u00e7\u0007E#3\u008e2U\u00e9\u0097", "foofoo", ["1234567890", "aábbccddeëff"]) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
75 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
76 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
77 func Test_uncrypt_blowfish() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
78 call Uncrypt_stable('blowfish', "VimCrypt~02!k)\u00be\u0017\u0097#\u0016\u00ddS\u009c\u00f5=\u00ba\u00e0\u00c8#\u00a5M\u00b4\u0086J\u00c3A\u00cd\u00a5M\u00b4\u0086!\u0080\u0015\u009b\u00f5\u000f\u00e1\u00d2\u0019\u0082\u0016\u0098\u00f7\u000d\u00da", "barbar", ["asdfasdfasdf", "0001112223333"]) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
79 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
80 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
81 func Test_uncrypt_blowfish2() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
82 call Uncrypt_stable('blowfish', "VimCrypt~03!\u001e\u00d1N\u00e3;\u00d3\u00c0\u00a0^C)\u0004\u00f7\u007f.\u00b6\u00abF\u000eS\u0019\u00e0\u008b6\u00d2[T\u00cb\u00a7\u0085\u00d8\u00be9\u000b\u00812\u000bQ\u00b3\u00cc@\u0097\u000f\u00df\u009a\u00adIv\u00aa.\u00d8\u00c9\u00ee\u009e`\u00bd$\u00af%\u00d0", "barburp", ["abcdefghijklmnopqrstuvwxyz", "!@#$%^&*()_+=-`~"]) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
83 endfunc |