@@ -22,3 +22,62 @@ endfunc
2222func Test_head_only_3 ()
2323 call Common_head_only (' VimCrypt~03!abc' )
2424endfunc
25+
26+ func Crypt_uncrypt (method)
27+ exe " set cryptmethod=" . a: method
28+ " If the blowfish test fails 'cryptmethod' will be 'zip' now.
29+ call assert_equal (a: method , &cryptmethod )
30+
31+ split Xtest.txt
32+ let text = [' 01234567890123456789012345678901234567' ,
33+ \ ' line 2 foo bar blah' ,
34+ \ ' line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ]
35+ call setline (1 , text)
36+ call feedkeys (" :X\<CR> foobar\<CR> foobar\<CR> " , ' xt' )
37+ w !
38+ bwipe!
39+ call feedkeys (" :split Xtest.txt\<CR> foobar\<CR> " , ' xt' )
40+ call assert_equal (text, getline (1 , 3 ))
41+ set key = cryptmethod &
42+ bwipe!
43+ call delete (' Xtest.txt' )
44+ endfunc
45+
46+ func Test_crypt_zip ()
47+ call Crypt_uncrypt (' zip' )
48+ endfunc
49+
50+ func Test_crypt_blowfish ()
51+ call Crypt_uncrypt (' blowfish' )
52+ endfunc
53+
54+ func Test_crypt_blowfish2 ()
55+ call Crypt_uncrypt (' blowfish2' )
56+ endfunc
57+
58+ func Uncrypt_stable (method, crypted_text, key , uncrypted_text)
59+ split Xtest.txt
60+ set bin noeol key = fenc = latin1
61+ exe " set cryptmethod=" . a: method
62+ call setline (1 , a: crypted_text )
63+ w !
64+ bwipe!
65+ set nobin
66+ call feedkeys (" :split Xtest.txt\<CR> " . a: key . " \<CR> " , ' xt' )
67+ call assert_equal (a: uncrypted_text , getline (1 , len (a: uncrypted_text )))
68+ bwipe!
69+ call delete (' Xtest.txt' )
70+ set key =
71+ endfunc
72+
73+ func Test_uncrypt_zip ()
74+ call Uncrypt_stable (' zip' , " VimCrypt~01!\u0006\u001c lV'\u00de }Mg\u00a0\u00ea\u00a3 V\u00a9\u00e7\u0007 E#3\u008e 2U\u00e9\u0097 " , " foofoo" , [" 1234567890" , " aábbccddeëff" ])
75+ endfunc
76+
77+ func Test_uncrypt_blowfish ()
78+ call Uncrypt_stable (' blowfish' , " VimCrypt~02!k)\u00be\u0017\u0097 #\u0016\u00dd S\u009c\u00f5 =\u00ba\u00e0\u00c8 #\u00a5 M\u00b4\u0086 J\u00c3 A\u00cd\u00a5 M\u00b4\u0086 !\u0080\u0015\u009b\u00f5\u000f\u00e1\u00d2\u0019\u0082\u0016\u0098\u00f7\u000d\u00da " , " barbar" , [" asdfasdfasdf" , " 0001112223333" ])
79+ endfunc
80+
81+ func Test_uncrypt_blowfish2 ()
82+ call Uncrypt_stable (' blowfish' , " VimCrypt~03!\u001e\u00d1 N\u00e3 ;\u00d3\u00c0\u00a0 ^C)\u0004\u00f7\u007f .\u00b6\u00ab F\u000e S\u0019\u00e0\u008b 6\u00d2 [T\u00cb\u00a7\u0085\u00d8\u00be 9\u000b\u0081 2\u000b Q\u00b3\u00cc @\u0097\u000f\u00df\u009a\u00ad Iv\u00aa .\u00d8\u00c9\u00ee\u009e `\u00bd $\u00af %\u00d0 " , " barburp" , [" abcdefghijklmnopqrstuvwxyz" , " !@#$%^&*()_+=-`~" ])
83+ endfunc
0 commit comments