Audio-GSM
view release on metacpan or search on metacpan
t/Audio-GSM.t view on Meta::CPAN
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Audio-GSM.t'
#########################
# change 'tests => 2' to 'tests => last_test_to_print';
use Test::More (tests => 6);
BEGIN { use_ok('Audio::GSM') };
my $fail = 0;
foreach my $constname (qw(
GSM_MAGIC GSM_MAJOR GSM_MINOR GSM_OPT_FAST GSM_OPT_FRAME_CHAIN
GSM_OPT_FRAME_INDEX GSM_OPT_LTP_CUT GSM_OPT_VERBOSE GSM_OPT_WAV49
GSM_PATCHLEVEL NeedFunctionPrototypes)) {
next if (eval "my \$a = $constname; 1");
if ($@ =~ /^Your vendor has not defined Audio::GSM macro $constname/) {
print "# pass: $@";
} else {
print "# fail: $@";
$fail = 1;
}
}
ok( $fail == 0 , 'Constants' );
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $gsm = new_ok('Audio::GSM');
ok(
$gsm->option(GSM_OPT_WAV49) == 0
&& $gsm->option(GSM_OPT_WAV49, 0) == 0
&& $gsm->option(GSM_OPT_WAV49, 1) == 0
&& $gsm->option(GSM_OPT_WAV49, 1) == 1
&& $gsm->option(GSM_OPT_WAV49) == 1,
'option'
);
my $gsmData = pack('H*', '265899A122842483D1B7EF43C1AA253E51CDCC4701412F3942CE41D7E1548FB1611E99F36E457835146F95561EB10D1C54AB59254212FEB679F81AE974CEABB10093');
my $pcmData = pack('H*', '00000000000000000000000000000000000000000000000000000001FFFF0002FFFE0002FFFE00010000FFFE0007FFF1006C011C019701C40193016A00BBFFB4FEC9FE26FE54FF14001B011B01CD025C02A803420345035C03E003EA0401044904D404AC04B2044603D8039D02A302A0...
is(length($gsm->encode($pcmData)), 65, 'encode');
is(length($gsm->decode($gsmData)), 640, 'decode');
( run in 2.417 seconds using v1.01-cache-2.11-cpan-364913b4093 )