File: maxmin.test

package info (click to toggle)
snack 2.2.10-dfsg1-12.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,024 kB
  • sloc: ansic: 35,473; sh: 8,557; tcl: 1,065; python: 701; makefile: 565
file content (104 lines) | stat: -rw-r--r-- 2,830 bytes parent folder | download | duplicates (9)
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
# Commands covered: sound max/min
#

package require -exact snack 2.2

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

test maxmin-1.1 {max/min commands} {
  set s [snack::sound snd -load ex1.wav]
  set res [list [$s max] [$s min]]
  $s destroy
  set res
} {14264 -8288}

test maxmin-1.2 {max/min commands with a specified range} {
  set s [snack::sound snd -load ex1.wav]
  set res [list [$s max -start 0 -end 4] [$s min -start 0 -end 4]]
  $s destroy
  set res
} {1201 1169}

test maxmin-1.3 {max command, with missing argument for -end option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s max -start 0 -end} msg
  $s destroy
  set msg
} {No argument given for -end option}

test maxmin-1.4 {min command, with missing argument for -end option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s min -start 0 -end} msg
  $s destroy
  set msg
} {No argument given for -end option}

test maxmin-2.1 {max command, 2 channels} {
  set s [snack::sound snd -channels 2]
  $s length 1000
  $s sample 500 1000 0
  $s sample 501 0 1000
  set res [list [$s max -start 0 -end 500 -channel 0] \
		[$s max -start 0 -end 500 -channel 1] \
		[$s max -start 501 -end -1 -channel 0] \
		[$s max -start 501 -end -1 -channel 1]]
  $s destroy
  set res
} {1000 0 0 1000}

test maxmin-2.2 {min command, 2 channels} {
  set s [snack::sound snd -channels 2]
  $s length 1000
  $s sample 500 -1000 0
  $s sample 501 0 -1000
  set res [list [$s min -start 0 -end 500 -channel 0] \
		[$s min -start 0 -end 500 -channel 1] \
		[$s min -start 501 -end -1 -channel 0] \
		[$s min -start 501 -end -1 -channel 1]]
  $s destroy
  set res
} {-1000 0 0 -1000}

test maxmin-2.3 {max command, 3 channels} {
  set s [snack::sound snd -channels 3]
  $s length 1000
  $s sample 500 0 0 1000
  $s sample 501 0 1000 0
  set res [list [$s max -start 0 -end 500 -channel 0] \
		[$s max -start 0 -end 500 -channel 1] \
		[$s max -start 0 -end 500 -channel 2] \
		[$s max -start 501 -end -1 -channel 0] \
		[$s max -start 501 -end -1 -channel 1] \
		[$s max -start 501 -end -1 -channel 2]]
  $s destroy
  set res
} {0 0 1000 0 1000 0}

test maxmin-2.4 {min command, 3 channels} {
  set s [snack::sound snd -channels 3]
  $s length 1000
  $s sample 500 0 0 -1000
  $s sample 501 0 -1000 0
  set res [list [$s min -start 0 -end 500 -channel 0] \
		[$s min -start 0 -end 500 -channel 1] \
		[$s min -start 0 -end 500 -channel 2] \
		[$s min -start 501 -end -1 -channel 0] \
		[$s min -start 501 -end -1 -channel 1] \
		[$s min -start 501 -end -1 -channel 2]]
  $s destroy
  set res
} {0 0 -1000 0 -1000 0}

test maxmin-3.1 {max/min commands, empty sound} {
  set s [snack::sound snd]
  set res [list [$s max] [$s min]]
  $s destroy
  set res
} {0 0}

# cleanup
::tcltest::cleanupTests
return