1#!/usr/bin/expect -f 2proc begin_strcut_test {_from _length} { 3 global spawn_id from length 4 set from $_from 5 set length $_length 6 7 spawn tests/strcut Japanese UTF-8 $_from $_length 8 set timeout 1 9 10 expect_after { 11 "\[^\r\n\]*\r\n" { fail $test } 12 } 13} 14 15begin_strcut_test -1 2 16 17set test "asciish characters ($from, $length)" 18send "testtest\r" 19expect { 20 -ex "***ERROR***\r\n" { pass $test } 21} 22 23set test "non-asciish characters ($from, $length)" 24send "テストテスト\r" 25expect { 26 -ex "***ERROR***\r\n" { pass $test } 27} 28 29close 30begin_strcut_test 2 -1 31 32set test "asciish characters ($from, $length)" 33send "testtest\r" 34expect { 35 -ex "***ERROR***\r\n" { pass $test } 36} 37 38set test "non-asciish characters ($from, $length)" 39send "テストテスト\r" 40expect { 41 -ex "***ERROR***\r\n" { pass $test } 42} 43 44close 45begin_strcut_test 3 2 46 47set test "asciish characters ($from, $length)" 48send "testtest\r" 49expect { 50 -ex "%74%74 (2)\r\n" { pass $test } 51} 52 53set test "non-asciish characters ($from, $length)" 54send "テストテスト\r" 55expect { 56 -ex "(0)\r\n" { pass $test } 57} 58 59close 60begin_strcut_test 5 8 61 62set test "asciish characters ($from, $length)" 63send "testtest\r" 64expect { 65 -ex "%65%73%74 (3)\r\n" { pass $test } 66} 67 68set test "non-asciish characters ($from, $length)" 69send "テストテスト\r" 70expect { 71 -ex "%e3%82%b9%e3%83%88 (6)\r\n" { pass $test } 72} 73 74close 75begin_strcut_test 1 15 76 77set test "asciish characters ($from, $length)" 78send "testestestestestes\r" 79expect { 80 "%65%73%74%65%73%74%65%73%74%65%73%74%65%73%74 (15)\r\n" { pass $test } 81} 82 83set test "non-asciish characters ($from, $length)" 84send "テストテスト\r" 85expect { 86 -ex "%e3%83%86%e3%82%b9%e3%83%88%e3%83%86%e3%82%b9 (15)\r\n" { pass $test } 87} 88close 89 90 91# vim: sts=4 sw=4 ts=4 et encoding=UTF-8 92