Permalink
Browse files

Added tests for RWOps. can figure some stuff out

  • Loading branch information...
1 parent f9f1423 commit 26de90e0c37292c2f3fb733a0c4ffe79adda6d6d @kthakore kthakore committed Nov 20, 2009
Showing with 42 additions and 17 deletions.
  1. +4 −4 src/Core/objects/RWOps.xs
  2. +38 −13 t/core_rwops.t
View
8 src/Core/objects/RWOps.xs
@@ -27,7 +27,7 @@ rwops_alloc (CLASS)
SDL_RWops*
-rwops_from_file ( CLASS, file, mode )
+rwops_new_file ( CLASS, file, mode )
char* CLASS
char* file
char * mode
@@ -37,7 +37,7 @@ rwops_from_file ( CLASS, file, mode )
RETVAL
SDL_RWops*
-rwops_from_FP ( CLASS, fp, autoclose )
+rwops_new_FP ( CLASS, fp, autoclose )
char* CLASS
FILE* fp
int autoclose
@@ -47,7 +47,7 @@ rwops_from_FP ( CLASS, fp, autoclose )
RETVAL
SDL_RWops*
-rwops_from_mem ( CLASS, mem, size )
+rwops_new_mem ( CLASS, mem, size )
char* CLASS
char* mem
int size
@@ -57,7 +57,7 @@ rwops_from_mem ( CLASS, mem, size )
RETVAL
SDL_RWops*
-rwops_from_const_mem (CLASS, mem, size )
+rwops_new_const_mem (CLASS, mem, size )
char* CLASS
const char* mem
int size
View
51 t/core_rwops.t
@@ -3,21 +3,46 @@ use strict;
use SDL;
use Test::More;
use SDL::RWOps;
-my @done = qw//;
+my @done = qw/
+new_file
+seek
+close
+/;
+can_ok( 'SDL::RWOps', @done );
+
+open FH, '>', '.rwops';
+print FH 'rwops';
+close FH;
+
+my $file = SDL::RWOps->new_file('.rwops', 'rw');
+isa_ok( $file, 'SDL::RWOps', '[from_file] returns RWOps');
+#0 SEEK_SET
+#1 SEEK_CUR
+#2 SEEK_END
+my $len = $file->seek(0, 0);
+is( $len, 0, '[seek] gets seek_end');
+$len = $file->seek(0,1);
+is( $len, 0, '[seek] gets seek_start');
+$len = $file->seek(0,2);
+is( $len, 5, '[seek] gets seek_cur');
+TODO:
+{
+my $char;
+my $blocks = $file->read($char, 16, 1);
+is ( $blocks, 5, '[read] got '.$char);
+}
+$file->close();
+unlink '.rwops';
my @left = qw/
-rw_from_file
-rw_from_fp
-rw_from_mem
-rw_from_const_mem
-alloc_rw
-free_rw
-rw_seek
-rw_tell
-rw_read
-rw_write
-rw_close
-rw_ops
+from_fp
+from_mem
+from_const_mem
+alloc
+free
+tell
+read
+write
/;
my $why

0 comments on commit 26de90e

Please sign in to comment.