From: Nicholas Clark Date: Tue, 6 Sep 2011 16:38:21 +0000 (+0200) Subject: Add tests for POSIX::Termios->get[io]speed(). X-Git-Tag: v5.15.3~116^2~27 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/5118227b39245912907b3e190edaef8ddb6fb605 Add tests for POSIX::Termios->get[io]speed(). --- diff --git a/ext/POSIX/t/termios.t b/ext/POSIX/t/termios.t index 636efe1..2f592d5 100644 --- a/ext/POSIX/t/termios.t +++ b/ext/POSIX/t/termios.t @@ -67,4 +67,29 @@ if (defined $termios) { } } +{ + my $t = POSIX::Termios->new(); + isa_ok($t, "POSIX::Termios", "checking the type of the object"); + + # B0 is special + my @baud = (B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, + B2400, B4800, B9600, B19200, B38400); + + # On some platforms (eg Linux-that-I-tested), ispeed and ospeed are both + # "stored" in the same bits of c_cflag (as the man page documents) + # *as well as in struct members* (which you would assume obviates the need + # for using c_cflag), and the get*() functions return the value encoded + # within c_cflag, hence it's not possible to set/get them independently. + foreach my $out (@baud) { + is($t->setispeed(0), '0 but true', "setispeed(0)"); + is($t->setospeed($out), '0 but true', "setospeed($out)"); + is($t->getospeed(), $out, "getospeed() for $out"); + } + foreach my $in (@baud) { + is($t->setospeed(0), '0 but true', "setospeed(0)"); + is($t->setispeed($in), '0 but true', "setispeed($in)"); + is($t->getispeed(), $in, "getispeed() for $in"); + } +} + done_testing();