Updated Changes and fixed a couple indents.
[perl-fuse.git] / test / write.t
1 #!/usr/bin/perl
2 use test::helper qw($_real $_point);
3 use Test::More;
4 plan tests => 15;
5 my ($data);
6 chdir($_point);
7 undef $/; # slurp it all
8 # create file
9 open($file, '>', 'writefile');
10 print $file "frogbing\n";
11 close($file);
12
13 # fetch contents of file
14 ok(open(FILE,"writefile"),"open");
15 $data = <FILE>;
16 close(FILE);
17 is(length($data),9,"right amount read");
18 is($data,"frogbing\n","right data read");
19
20 # overwrite part
21 ok(open(FILE,'+<',"writefile"),"open");
22 ok(seek(FILE,2,0),"seek");
23 ok(print(FILE "ib"),"print");
24 close(FILE);
25
26 # fetch contents of file
27 ok(open(FILE,"writefile"),"open");
28 $data = <FILE>;
29 close(FILE);
30 is(length($data),9,"right amount read");
31 is($data,"fribbing\n","right data read");
32
33 # overwrite part, append some
34 ok(open(FILE,'+<',"writefile"),"open");
35 ok(seek(FILE,7,0),"seek");
36 ok(print(FILE "gle"),"print");
37 close(FILE);
38
39 # fetch contents of file
40 ok(open(FILE,"writefile"),"open");
41 $data = <FILE>;
42 close(FILE);
43 is(length($data),10,"right amount read");
44 is($data,"fribbingle","right data read");
45
46 # kill file
47 unlink("writefile");