1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
# -*- tcl -*-
# Commands covered: otp_words
#
# This file contains a collection of tests for one or more of the trf
# commands of the TRF extension. Sourcing this file into Tcl runs the
# tests and generates output for errors. No output means no errors were
# found.
#
# Copyright (c) 1995 Andreas Kupries (andreas_kupries@users.sourceforge.net)
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# $Id: otp_words.test,v 1.1 1999/05/30 11:45:48 aku Exp $
if {[string compare test [info procs test]] == 1} then {source defs}
test otp_words-1.0 {otp_words, conversion errors} {
catch {otp_words -mode encode XX} msg
set msg
} {input string must be a multiple of 64-bits}
test otp_words-1.1 {otp_words, conversion errors} {
catch {otp_words -mode encode XXXXYYYYZ} msg
set msg
} {input string must be a multiple of 64-bits}
test otp_words-1.2 {otp_words, conversion errors} {
catch {otp_words -mode decode 101010090010101010200} msg
set msg
} {word too long}
test otp_words-1.3 {otp_words, conversion errors} {
catch {otp_words -mode decode XXXX} msg
set msg
} {too few words}
test otp_words-1.4 {otp_words, conversion errors} {
catch {otp_words -mode decode {XXXX XXXX}} msg
set msg
} {empty word}
test otp_words-1.5 {otp_words, conversion errors} {
catch {otp_words -mode decode {XXX YYY ZZZ AAA BBB CCC}} msg
set msg
} {unknown word "XXX"}
foreach {index string encode} {
1 {9E87 6134 D904 99DD} {INCH SEA ANNE LONG AHEM TOUR}
2 {7965 E054 36F5 029F} {EASE OIL FUM CURE AWRY AVIS}
3 {50FE 1962 C496 5880} {BAIL TUFT BITS GANG CHEF THY}
4 {8706 6DD9 644B F206} {FULL PEW DOWN ONCE MORT ARC}
5 {7CD3 4C10 40AD D14B} {FACT HOOF AT FIST SITE KENT}
6 {5AA3 7A81 F212 146C} {BODE HOP JAKE STOW JUT RAP}
7 {F205 7539 43DE 4CF9} {ULAN NEW ARMY FUSE SUIT EYED}
8 {DDCD AC95 6F23 4937} {SKIM CULT LOB SLAM POE HOWL}
9 {B203 E28F A525 BE47} {LONG IVY JULY AJAR BOND LEE}
} {
regsub -all { } $string {} ostring
set ostring [hex -mode decode $ostring]
test otp_words-2.$index {otp_words, encode string} {
otp_words -mode encode $ostring
} $encode ;#{}
test otp_words-3.$index {otp_words, decode string} {
otp_words -mode decode $encode
} $ostring ;#{}
# redundant tests following
test otp_words-4.$index {otp_words, encode/decode identity} {
otp_words -mode decode [otp_words -mode encode $ostring]
} $ostring ;#{}
test otp_words-5.$index {otp_words, decode/encode identity} {
otp_words -mode encode [otp_words -mode decode $encode]
} $encode ;#{}
}
|