]> gitweb.factorcode.org Git - factor.git/blob - extra/crypto/xor/xor-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / extra / crypto / xor / xor-tests.factor
1 USING: continuations crypto.xor kernel strings tools.test ;
2 IN: crypto.xor.tests
3
4 ! No key
5 [ ""        dup  xor-crypt           ] [ T{ empty-xor-key } = ] must-fail-with
6 [ { }       dup  xor-crypt           ] [ T{ empty-xor-key } = ] must-fail-with
7 [ V{ }      dup  xor-crypt           ] [ T{ empty-xor-key } = ] must-fail-with
8 [ "" "asdf" dupd xor-crypt xor-crypt ] [ T{ empty-xor-key } = ] must-fail-with
9
10 ! a xor a = 0
11 { "\0\0\0\0\0\0\0" } [ "abcdefg" dup xor-crypt ] unit-test
12
13 { { 15 15 15 15 } } [ { 10 10 10 10 } { 5 5 5 5 } xor-crypt ] unit-test
14
15 { "asdf" } [ "asdf" "key" [ xor-crypt ] [ xor-crypt ] bi >string ] unit-test
16 { "" } [ "" "key" xor-crypt >string ] unit-test
17 { "a longer message...!" } [
18     "a longer message...!"
19     "." [ xor-crypt ] [ xor-crypt ] bi >string
20 ] unit-test
21 { "a longer message...!" } [
22     "a longer message...!"
23     "a very long key, longer than the message even."
24     [ xor-crypt ] [ xor-crypt ] bi >string
25 ] unit-test