File: length.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 (69 lines) | stat: -rw-r--r-- 1,568 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
# Commands covered: sound length
#

package require -exact snack 2.2

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

test length-1.1 {length command, get length in samples} {
  set s [snack::sound snd -load ex1.wav]
  set res [$s length -unit samples]
  $s destroy
  set res
} {15820}

test length-1.2 {length command, set length in samples} {
  set s [snack::sound snd]
  $s length 1000000 -unit samples
  set res [$s length]
  $s destroy
  set res
} {1000000}

test length-1.3 {length command, set length in seconds} {
  set s [snack::sound snd]
  $s length 10 -unit seconds
  set res [$s length]
  $s destroy
  set res
} {160000}

test length-1.4 {length command, get length in seconds} {
  set s [snack::sound snd]
  $s length 16000
  set res [$s length -unit seconds]
  $s destroy
  set res
} {1.0}

test length-1.5 {length command, set length for linked sound} {
  set s [snack::sound snd -file ""]
  catch {$s length 1000000} msg
  $s destroy
  set msg
} {setting sound length only works with in-memory sounds}

test length-2.1 {length command, set length in samples, change channels} {
  set s [snack::sound snd -channels 2]
  $s length 1000000
  $s configure -channels 1
  set res [$s length]
  $s destroy
  set res
} {2000000}

test length-2.2 {length command, set length in samples, change channels} {
  set s [snack::sound snd -channels 1]
  $s length 900000
  $s configure -channels 9
  set res [$s length]
  $s destroy
  set res
} {100000}

# cleanup
::tcltest::cleanupTests
return