4128
|
1 Tests for sha256() function. vim: set ft=vim et ts=2 sw=2 :
|
|
2
|
|
3 STARTTEST
|
|
4 :so small.vim
|
|
5 :if !has('cryptv') || !exists('*sha256')
|
|
6 e! test.ok
|
|
7 wq! test.out
|
|
8 :endif
|
|
9 :"
|
|
10 :let testcase='test for empty string: '
|
|
11 :if sha256("") ==# 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
12 : let res='ok'
|
|
13 :else
|
|
14 : let res='ng'
|
|
15 :endif
|
|
16 :$put =testcase.res
|
|
17 :"
|
|
18 :let testcase='test for 1 char: '
|
|
19 :if sha256("a") ==# 'ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'
|
|
20 : let res='ok'
|
|
21 :else
|
|
22 : let res='ng'
|
|
23 :endif
|
|
24 :$put =testcase.res
|
|
25 :"
|
|
26 :let testcase='test for 3 chars: '
|
|
27 :if sha256("abc") ==# 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
|
|
28 : let res='ok'
|
|
29 :else
|
|
30 : let res='ng'
|
|
31 :endif
|
|
32 :$put =testcase.res
|
|
33 :"
|
|
34 :let testcase='test for contains meta char: '
|
|
35 :if sha256("foo\nbar") ==# '807eff6267f3f926a21d234f7b0cf867a86f47e07a532f15e8cc39ed110ca776'
|
|
36 : let res='ok'
|
|
37 :else
|
|
38 : let res='ng'
|
|
39 :endif
|
|
40 :$put =testcase.res
|
|
41 :"
|
|
42 :let testcase='test for contains non-ascii char: '
|
|
43 :if sha256("\xde\xad\xbe\xef") ==# '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953'
|
|
44 : let res='ok'
|
|
45 :else
|
|
46 : let res='ng'
|
|
47 :endif
|
|
48 :$put =testcase.res
|
|
49 "
|
|
50 :/^start:/,$wq! test.out
|
|
51 ENDTEST
|
|
52
|
|
53 start:
|