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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
# Commands covered: sound configure
#
package require -exact snack 2.2
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import ::tcltest::*
}
test configure-1.1 {configure command, bad args} {
set s [snack::sound snd]
set res [list [catch {$s configure -junk} msg] $msg]
$s destroy
set res
} {1 {bad option "-junk": must be -load, -file, -channel, -rate, -frequency, -channels, -encoding, -format, -byteorder, -buffersize, -skiphead, -guessproperties, -precision, -changecommand, -fileformat, or -debug}}
test configure-2.1 {configure command, get option -load} {
set s [snack::sound snd -load ex1.wav]
set res [$s configure -load]
$s destroy
set res
} {ex1.wav}
test configure-2.2 {configure command, get option -file} {
set s [snack::sound snd -file ex1.wav]
set res [$s configure -file]
$s destroy
set res
} {ex1.wav}
test configure-2.3 {configure command, get option -rate} {
set s [snack::sound snd -load ex1.wav]
set res [$s configure -rate]
$s destroy
set res
} 16000
test configure-2.4 {configure command, get option -encoding} {
set s [snack::sound snd -load ex1.wav]
set res [$s configure -encoding]
$s destroy
set res
} Lin16
test configure-2.5 {configure command, get option -channels} {
set s [snack::sound snd -load ex1.wav]
set res [$s configure -channels]
$s destroy
set res
} 1
test configure-2.6 {configure command, get option -byteorder} {
set s [snack::sound snd -load ex1.wav]
set res [$s configure -byteorder]
$s destroy
set res
} littleEndian
test configure-3.1 {configure command, set option -load} {
set s [snack::sound snd]
$s configure -load ex1.wav
set res [$s cget -load]
$s destroy
set res
} {ex1.wav}
test configure-3.2 {configure command, set option -file} {
set s [snack::sound snd]
$s configure -file ex1.wav
set res [$s cget -file]
$s destroy
set res
} {ex1.wav}
test configure-3.3 {configure command, set option -rate} {
set s [snack::sound snd]
$s configure -rate 8000
set res [$s cget -rate]
$s destroy
set res
} 8000
test configure-3.4 {configure command, set option -rate} {
set s [snack::sound snd]
$s configure -rate 44100
set res [$s cget -rate]
$s destroy
set res
} 44100
test configure-3.5 {configure command, set option -encoding} {
set s [snack::sound snd]
$s configure -encoding Lin16
set res [$s cget -encoding]
$s destroy
set res
} Lin16
test configure-3.6 {configure command, set option -encoding} {
set s [snack::sound snd]
$s configure -encoding Mulaw
set res [$s cget -encoding]
$s destroy
set res
} Mulaw
test configure-3.7 {configure command, set option -encoding} {
set s [snack::sound snd]
$s configure -encoding Float
set res [$s cget -encoding]
$s destroy
set res
} Float
test configure-3.8 {configure command, set option -encoding} {
set s [snack::sound snd]
catch {$s configure -encoding junk} msg
$s destroy
set msg
} {Unknown encoding}
test configure-3.9 {configure command, set option -encoding} {
set s [snack::sound snd]
$s configure -channels 2
set res [$s cget -channels]
$s destroy
set res
} 2
test configure-3.10 {configure command, set option -byteorder} {
set s [snack::sound snd]
$s configure -byteorder littleEndian
set res [$s cget -byteorder]
$s destroy
set res
} littleEndian
test configure-3.11 {configure command, set option -precision} {
set s [snack::sound snd]
$s configure -precision double
set res [$s cget -precision]
$s destroy
set res
} double
test configure-4.1 {configure command} {
set s [snack::sound snd]
set res [$s configure]
$s destroy
set res
} {0 16000 0 0 Lin16 1}
test configure-5.1 {configure command, set option -encoding} {
set s [snack::sound snd]
catch {$s configure -channels 2 -encoding} msg
$s destroy
set msg
} {No argument given for -encoding option}
# cleanup
::tcltest::cleanupTests
return
|