]> git.cworth.org Git - obsolete/notmuch-old/blob - test/hex-escaping
revert: Removed top level --stderr= option
[obsolete/notmuch-old] / test / hex-escaping
1 #!/usr/bin/env bash
2 test_description="hex encoding and decoding"
3 . ./test-lib.sh
4
5 test_begin_subtest "round trip"
6 find $TEST_DIRECTORY/corpus -type f -print | sort | xargs cat > EXPECTED
7 $TEST_DIRECTORY/hex-xcode --direction=encode < EXPECTED | $TEST_DIRECTORY/hex-xcode --direction=decode > OUTPUT
8 test_expect_equal_file OUTPUT EXPECTED
9
10 test_begin_subtest "punctuation"
11 tag1='comic_swear=$&^%$^%\\//-+$^%$'
12 tag_enc1=$($TEST_DIRECTORY/hex-xcode --direction=encode "$tag1")
13 test_expect_equal "$tag_enc1" "comic_swear=%24%26%5e%25%24%5e%25%5c%5c%2f%2f-+%24%5e%25%24"
14
15 test_begin_subtest "round trip newlines"
16 printf 'this\n tag\t has\n spaces\n' > EXPECTED.$test_count
17 $TEST_DIRECTORY/hex-xcode --direction=encode  < EXPECTED.$test_count |\
18         $TEST_DIRECTORY/hex-xcode --direction=decode > OUTPUT.$test_count
19 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
20
21 test_begin_subtest "round trip 8bit chars"
22 echo '%c3%91%c3%a5%c3%b0%c3%a3%c3%a5%c3%a9-%c3%8f%c3%8a' > EXPECTED.$test_count
23 $TEST_DIRECTORY/hex-xcode --direction=decode  < EXPECTED.$test_count |\
24     $TEST_DIRECTORY/hex-xcode --direction=encode > OUTPUT.$test_count
25 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
26
27 test_begin_subtest "round trip (in-place)"
28 find $TEST_DIRECTORY/corpus -type f -print | sort | xargs cat > EXPECTED
29 $TEST_DIRECTORY/hex-xcode --in-place --direction=encode < EXPECTED |\
30      $TEST_DIRECTORY/hex-xcode --in-place --direction=decode > OUTPUT
31 test_expect_equal_file OUTPUT EXPECTED
32
33 test_begin_subtest "punctuation (in-place)"
34 tag1='comic_swear=$&^%$^%\\//-+$^%$'
35 tag_enc1=$($TEST_DIRECTORY/hex-xcode --in-place --direction=encode "$tag1")
36 test_expect_equal "$tag_enc1" "comic_swear=%24%26%5e%25%24%5e%25%5c%5c%2f%2f-+%24%5e%25%24"
37
38 test_begin_subtest "round trip newlines (in-place)"
39 printf 'this\n tag\t has\n spaces\n' > EXPECTED.$test_count
40 $TEST_DIRECTORY/hex-xcode --in-place --direction=encode  < EXPECTED.$test_count |\
41     $TEST_DIRECTORY/hex-xcode --in-place --direction=decode > OUTPUT.$test_count
42 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
43
44 test_begin_subtest "round trip 8bit chars (in-place)"
45 echo '%c3%91%c3%a5%c3%b0%c3%a3%c3%a5%c3%a9-%c3%8f%c3%8a' > EXPECTED.$test_count
46 $TEST_DIRECTORY/hex-xcode --in-place --direction=decode  < EXPECTED.$test_count |\
47     $TEST_DIRECTORY/hex-xcode --in-place --direction=encode > OUTPUT.$test_count
48 test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count
49
50 test_done