1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl 1.t'
3use strict;
4
5#########################
6
7use Test::More tests => 7;
8
9use_ok('Device::SerialPort'); # test
10
11#########################
12
13# We need to test that the "get_tick_count" function actually works
14# as expected, since we use it during other tests to verify toggle
15# speeds, hang ups, etc.
16
17can_ok('Device::SerialPort',qw(get_tick_count)); # test
18
19my $then;
20ok(defined($then = Device::SerialPort->get_tick_count),
21	"get_tick_count returns a number"); # test
22
23ok(sleep(2) <= 2, "sleep sleeps"); # test
24
25my $now;
26ok(defined($now = Device::SerialPort->get_tick_count),
27	"get_tick_count still returns a number"); # test
28
29ok( ($now-$then) >= 1000, "measured sleep as more than 1 second")
30	or diag("then: $then now: $now diff: ".($now-$then)); # test
31
32# Allow 100ms fudge-time for slow calls, etc
33ok( ($now-$then) <= 2100, "measured sleep as less than 2 seconds")
34	or diag("then: $then now: $now diff: ".($now-$then)); # test
35
36