Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7a61f871
Kaydet (Commit)
7a61f871
authored
Ock 03, 1997
tarafından
Roger E. Masse
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Updated to include the verbose flag from test_support
üst
549ab711
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
test_audioop.py
Lib/test/test_audioop.py
+45
-0
No files found.
Lib/test/test_audioop.py
Dosyayı görüntüle @
7a61f871
# Test audioop.
# Test audioop.
import
audioop
import
audioop
from
test_support
import
verbose
def
gendata1
():
def
gendata1
():
return
'
\0\1\2
'
return
'
\0\1\2
'
def
gendata2
():
def
gendata2
():
if
verbose
:
print
'getsample'
if
audioop
.
getsample
(
'
\0\1
'
,
2
,
0
)
==
1
:
if
audioop
.
getsample
(
'
\0\1
'
,
2
,
0
)
==
1
:
return
'
\0\0\0\1\0\2
'
return
'
\0\0\0\1\0\2
'
else
:
else
:
return
'
\0\0\1\0\2\0
'
return
'
\0\0\1\0\2\0
'
def
gendata4
():
def
gendata4
():
if
verbose
:
print
'getsample'
if
audioop
.
getsample
(
'
\0\0\0\1
'
,
4
,
0
)
==
1
:
if
audioop
.
getsample
(
'
\0\0\0\1
'
,
4
,
0
)
==
1
:
return
'
\0\0\0\0\0\0\0\1\0\0\0\2
'
return
'
\0\0\0\0\0\0\0\1\0\0\0\2
'
else
:
else
:
return
'
\0\0\0\0\1\0\0\0\2\0\0\0
'
return
'
\0\0\0\0\1\0\0\0\2\0\0\0
'
def
testmax
(
data
):
def
testmax
(
data
):
if
verbose
:
print
'max'
if
audioop
.
max
(
data
[
0
],
1
)
<>
2
or
\
if
audioop
.
max
(
data
[
0
],
1
)
<>
2
or
\
audioop
.
max
(
data
[
1
],
2
)
<>
2
or
\
audioop
.
max
(
data
[
1
],
2
)
<>
2
or
\
audioop
.
max
(
data
[
2
],
4
)
<>
2
:
audioop
.
max
(
data
[
2
],
4
)
<>
2
:
...
@@ -24,6 +31,8 @@ def testmax(data):
...
@@ -24,6 +31,8 @@ def testmax(data):
return
1
return
1
def
testminmax
(
data
):
def
testminmax
(
data
):
if
verbose
:
print
'minmax'
if
audioop
.
minmax
(
data
[
0
],
1
)
<>
(
0
,
2
)
or
\
if
audioop
.
minmax
(
data
[
0
],
1
)
<>
(
0
,
2
)
or
\
audioop
.
minmax
(
data
[
1
],
2
)
<>
(
0
,
2
)
or
\
audioop
.
minmax
(
data
[
1
],
2
)
<>
(
0
,
2
)
or
\
audioop
.
minmax
(
data
[
2
],
4
)
<>
(
0
,
2
):
audioop
.
minmax
(
data
[
2
],
4
)
<>
(
0
,
2
):
...
@@ -31,6 +40,8 @@ def testminmax(data):
...
@@ -31,6 +40,8 @@ def testminmax(data):
return
1
return
1
def
testmaxpp
(
data
):
def
testmaxpp
(
data
):
if
verbose
:
print
'maxpp'
if
audioop
.
maxpp
(
data
[
0
],
1
)
<>
0
or
\
if
audioop
.
maxpp
(
data
[
0
],
1
)
<>
0
or
\
audioop
.
maxpp
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
maxpp
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
maxpp
(
data
[
2
],
4
)
<>
0
:
audioop
.
maxpp
(
data
[
2
],
4
)
<>
0
:
...
@@ -38,6 +49,8 @@ def testmaxpp(data):
...
@@ -38,6 +49,8 @@ def testmaxpp(data):
return
1
return
1
def
testavg
(
data
):
def
testavg
(
data
):
if
verbose
:
print
'avg'
if
audioop
.
avg
(
data
[
0
],
1
)
<>
1
or
\
if
audioop
.
avg
(
data
[
0
],
1
)
<>
1
or
\
audioop
.
avg
(
data
[
1
],
2
)
<>
1
or
\
audioop
.
avg
(
data
[
1
],
2
)
<>
1
or
\
audioop
.
avg
(
data
[
2
],
4
)
<>
1
:
audioop
.
avg
(
data
[
2
],
4
)
<>
1
:
...
@@ -45,6 +58,8 @@ def testavg(data):
...
@@ -45,6 +58,8 @@ def testavg(data):
return
1
return
1
def
testavgpp
(
data
):
def
testavgpp
(
data
):
if
verbose
:
print
'avgpp'
if
audioop
.
avgpp
(
data
[
0
],
1
)
<>
0
or
\
if
audioop
.
avgpp
(
data
[
0
],
1
)
<>
0
or
\
audioop
.
avgpp
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
avgpp
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
avgpp
(
data
[
2
],
4
)
<>
0
:
audioop
.
avgpp
(
data
[
2
],
4
)
<>
0
:
...
@@ -59,6 +74,8 @@ def testrms(data):
...
@@ -59,6 +74,8 @@ def testrms(data):
return
1
return
1
def
testcross
(
data
):
def
testcross
(
data
):
if
verbose
:
print
'cross'
if
audioop
.
cross
(
data
[
0
],
1
)
<>
0
or
\
if
audioop
.
cross
(
data
[
0
],
1
)
<>
0
or
\
audioop
.
cross
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
cross
(
data
[
1
],
2
)
<>
0
or
\
audioop
.
cross
(
data
[
2
],
4
)
<>
0
:
audioop
.
cross
(
data
[
2
],
4
)
<>
0
:
...
@@ -66,6 +83,8 @@ def testcross(data):
...
@@ -66,6 +83,8 @@ def testcross(data):
return
1
return
1
def
testadd
(
data
):
def
testadd
(
data
):
if
verbose
:
print
'add'
data2
=
[]
data2
=
[]
for
d
in
data
:
for
d
in
data
:
str
=
''
str
=
''
...
@@ -79,6 +98,8 @@ def testadd(data):
...
@@ -79,6 +98,8 @@ def testadd(data):
return
1
return
1
def
testbias
(
data
):
def
testbias
(
data
):
if
verbose
:
print
'bias'
# Note: this test assumes that avg() works
# Note: this test assumes that avg() works
d1
=
audioop
.
bias
(
data
[
0
],
1
,
100
)
d1
=
audioop
.
bias
(
data
[
0
],
1
,
100
)
d2
=
audioop
.
bias
(
data
[
1
],
2
,
100
)
d2
=
audioop
.
bias
(
data
[
1
],
2
,
100
)
...
@@ -90,6 +111,8 @@ def testbias(data):
...
@@ -90,6 +111,8 @@ def testbias(data):
return
1
return
1
def
testlin2lin
(
data
):
def
testlin2lin
(
data
):
if
verbose
:
print
'lin2lin'
# too simple: we test only the size
# too simple: we test only the size
for
d1
in
data
:
for
d1
in
data
:
for
d2
in
data
:
for
d2
in
data
:
...
@@ -106,12 +129,16 @@ def testadpcm2lin(data):
...
@@ -106,12 +129,16 @@ def testadpcm2lin(data):
return
1
return
1
def
testlin2adpcm
(
data
):
def
testlin2adpcm
(
data
):
if
verbose
:
print
'lin2adpcm'
# Very cursory test
# Very cursory test
if
audioop
.
lin2adpcm
(
'
\0\0\0\0
'
,
1
,
None
)
<>
(
'
\0\0
'
,
(
0
,
0
)):
if
audioop
.
lin2adpcm
(
'
\0\0\0\0
'
,
1
,
None
)
<>
(
'
\0\0
'
,
(
0
,
0
)):
return
0
return
0
return
1
return
1
def
testlin2ulaw
(
data
):
def
testlin2ulaw
(
data
):
if
verbose
:
print
'lin2ulaw'
if
audioop
.
lin2ulaw
(
data
[
0
],
1
)
<>
'
\377\347\333
'
or
\
if
audioop
.
lin2ulaw
(
data
[
0
],
1
)
<>
'
\377\347\333
'
or
\
audioop
.
lin2ulaw
(
data
[
1
],
2
)
<>
'
\377\377\377
'
or
\
audioop
.
lin2ulaw
(
data
[
1
],
2
)
<>
'
\377\377\377
'
or
\
audioop
.
lin2ulaw
(
data
[
2
],
4
)
<>
'
\377\377\377
'
:
audioop
.
lin2ulaw
(
data
[
2
],
4
)
<>
'
\377\377\377
'
:
...
@@ -119,6 +146,8 @@ def testlin2ulaw(data):
...
@@ -119,6 +146,8 @@ def testlin2ulaw(data):
return
1
return
1
def
testulaw2lin
(
data
):
def
testulaw2lin
(
data
):
if
verbose
:
print
'ulaw2lin'
# Cursory
# Cursory
d
=
audioop
.
lin2ulaw
(
data
[
0
],
1
)
d
=
audioop
.
lin2ulaw
(
data
[
0
],
1
)
if
audioop
.
ulaw2lin
(
d
,
1
)
<>
data
[
0
]:
if
audioop
.
ulaw2lin
(
d
,
1
)
<>
data
[
0
]:
...
@@ -126,6 +155,8 @@ def testulaw2lin(data):
...
@@ -126,6 +155,8 @@ def testulaw2lin(data):
return
1
return
1
def
testmul
(
data
):
def
testmul
(
data
):
if
verbose
:
print
'mul'
data2
=
[]
data2
=
[]
for
d
in
data
:
for
d
in
data
:
str
=
''
str
=
''
...
@@ -139,11 +170,15 @@ def testmul(data):
...
@@ -139,11 +170,15 @@ def testmul(data):
return
1
return
1
def
testreverse
(
data
):
def
testreverse
(
data
):
if
verbose
:
print
'reverse'
if
audioop
.
reverse
(
data
[
0
],
1
)
<>
'
\2\1\0
'
:
if
audioop
.
reverse
(
data
[
0
],
1
)
<>
'
\2\1\0
'
:
return
0
return
0
return
1
return
1
def
testtomono
(
data
):
def
testtomono
(
data
):
if
verbose
:
print
'tomono'
data2
=
''
data2
=
''
for
d
in
data
[
0
]:
for
d
in
data
[
0
]:
data2
=
data2
+
d
+
d
data2
=
data2
+
d
+
d
...
@@ -152,6 +187,8 @@ def testtomono(data):
...
@@ -152,6 +187,8 @@ def testtomono(data):
return
1
return
1
def
testtostereo
(
data
):
def
testtostereo
(
data
):
if
verbose
:
print
'tostereo'
data2
=
''
data2
=
''
for
d
in
data
[
0
]:
for
d
in
data
[
0
]:
data2
=
data2
+
d
+
d
data2
=
data2
+
d
+
d
...
@@ -160,21 +197,29 @@ def testtostereo(data):
...
@@ -160,21 +197,29 @@ def testtostereo(data):
return
1
return
1
def
testfindfactor
(
data
):
def
testfindfactor
(
data
):
if
verbose
:
print
'findfactor'
if
audioop
.
findfactor
(
data
[
1
],
data
[
1
])
<>
1.0
:
if
audioop
.
findfactor
(
data
[
1
],
data
[
1
])
<>
1.0
:
return
0
return
0
return
1
return
1
def
testfindfit
(
data
):
def
testfindfit
(
data
):
if
verbose
:
print
'findfit'
if
audioop
.
findfit
(
data
[
1
],
data
[
1
])
<>
(
0
,
1.0
):
if
audioop
.
findfit
(
data
[
1
],
data
[
1
])
<>
(
0
,
1.0
):
return
0
return
0
return
1
return
1
def
testfindmax
(
data
):
def
testfindmax
(
data
):
if
verbose
:
print
'findmax'
if
audioop
.
findmax
(
data
[
1
],
1
)
<>
2
:
if
audioop
.
findmax
(
data
[
1
],
1
)
<>
2
:
return
0
return
0
return
1
return
1
def
testgetsample
(
data
):
def
testgetsample
(
data
):
if
verbose
:
print
'getsample'
for
i
in
range
(
3
):
for
i
in
range
(
3
):
if
audioop
.
getsample
(
data
[
0
],
1
,
i
)
<>
i
or
\
if
audioop
.
getsample
(
data
[
0
],
1
,
i
)
<>
i
or
\
audioop
.
getsample
(
data
[
1
],
2
,
i
)
<>
i
or
\
audioop
.
getsample
(
data
[
1
],
2
,
i
)
<>
i
or
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment