PageRenderTime 12ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/t/core_rwops.t

http://github.com/PerlGameDev/SDL
Perl | 66 lines | 55 code | 7 blank | 4 comment | 0 complexity | d33bed08909d1511bff0ea8a0474ded1 MD5 | raw file
 1#!/usr/bin/perl -w
 2use strict;
 3use warnings;
 4use SDL;
 5use Test::More;
 6use SDL::RWOps;
 7my @done = qw/
 8	new_file
 9	seek
10	close
11	/;
12can_ok( 'SDL::RWOps', @done );
13
14open FH, '>', '.rwops';
15print FH 'rwops';
16close FH;
17
18my $file = SDL::RWOps->new_file( '.rwops', 'rw' );
19isa_ok( $file, 'SDL::RWOps', '[from_file] returns RWOps' );
20
21#0        SEEK_SET
22#1        SEEK_CUR
23#2        SEEK_END
24my $len = $file->seek( 0, 0 );
25is( $len, 0, '[seek] gets seek_end' );
26$len = $file->seek( 0, 1 );
27is( $len, 0, '[seek] gets seek_start' );
28$len = $file->seek( 0, 2 );
29is( $len, 5, '[seek] gets seek_cur' );
30SKIP:
31{
32	skip( 'crashing', 1 );
33	my $char;
34	my $blocks = $file->read( $char, 16, 1 );
35	is( $blocks, 5, '[read] got ' . $char );
36}
37$file->close();
38unlink '.rwops';
39my @left = qw/
40	from_fp
41	from_mem
42	from_const_mem
43	alloc
44	free
45	tell
46	read
47	write
48	/;
49
50my $why =
51	  '[Percentage Completion] '
52	. int( 100 * ( $#done + 1 ) / ( $#done + $#left + 2 ) )
53	. "\% implementation. "
54	. ( $#done + 1 ) . " / "
55	. ( $#done + $#left + 2 );
56
57TODO:
58{
59	local $TODO = $why;
60	fail "Not Implmented $_" foreach (@left)
61
62}
63print "$why\n";
64
65done_testing;
66sleep(2);