File: reverse.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 (88 lines) | stat: -rw-r--r-- 2,284 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
# Commands covered: sound reverse
#

package require -exact snack 2.2

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

test reverse-1.1 {reverse command, ex1.wav} {
  set s [snack::sound snd -load ex1.wav]
  $s reverse -start 5000 -end 10000
  set res [list [$s sample 4999] [$s sample 5000] [$s sample 10000] [$s sample 10001]]
  $s destroy
  set res
} {6384 779 7443 514}

test reverse-1.2 {reverse command, stereo} {
  set s [snack::sound snd -channels 2]
  $s length 20000
  $s sample 5000 17 4711
  $s sample 10000 1 2
  $s reverse -start 5000 -end 10000
  set res [list [$s sample 4999] [$s sample 5000] [$s sample 10000] [$s sample 10001]]
  $s destroy
  set res
} {{0 0} {1 2} {17 4711} {0 0}}

test reverse-1.3 {reverse command, 3-channel} {
  set s [snack::sound snd -channels 3]
  $s length 20000
  $s sample 5000 17 4711 18
  $s sample 10000 1 2 3
  $s reverse -start 5000 -end 10000
  set res [list [$s sample 4999] [$s sample 5000] [$s sample 10000] [$s sample 10001]]
  $s destroy
  set res
} {{0 0 0} {1 2 3} {17 4711 18} {0 0 0}}

test reverse-1.4 {reverse command, even length} {
  set s [snack::sound snd -channels 2]
  $s length 4
  $s sample 0 1 2
  $s sample 1 3 4
  $s sample 2 5 6
  $s sample 3 7 8
  $s reverse -start 1 -end 2
  set res [list [$s sample 0] [$s sample 1] [$s sample 2] [$s sample 3]]
  $s destroy
  set res
} {{1 2} {5 6} {3 4} {7 8}}

test reverse-1.5 {reverse command, odd length} {
  set s [snack::sound snd -channels 2]
  $s length 5
  $s sample 0 1 2
  $s sample 1 3 4
  $s sample 2 5 6
  $s sample 3 7 8
  $s sample 4 9 0
  $s reverse -start 1 -end 3
  set res [list [$s sample 0] [$s sample 1] [$s sample 2] [$s sample 3] [$s sample 4]]
  $s destroy
  set res
} {{1 2} {7 8} {5 6} {3 4} {9 0}}

test reverse-1.6 {reverse command, missing -end option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s reverse -start 5000 -end} msg
  $s destroy
  set msg
} {No argument given for -end option}

test reverse-2.1 {reverse command, -progress option} {
  set res ""
  proc prog {msg frac} {
    lappend ::res $frac
  }
  set s [snack::sound snd -load ex1.wav]
  $s reverse -progress prog
  $s destroy
  set res
} {0.0 1.0}

# cleanup
::tcltest::cleanupTests
return