From ec05778d5718a7912e506764d443a78d6a6179e3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 5 Nov 2012 22:41:51 +0000 Subject: Converted tabs to spaces with tabconv. --- src/unit/file.unit | 160 ++++++++++++++++++++++++++--------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'src/unit/file.unit') diff --git a/src/unit/file.unit b/src/unit/file.unit index 7140d03..c0358ac 100644 --- a/src/unit/file.unit +++ b/src/unit/file.unit @@ -14,87 +14,87 @@ suite File { - test writeFull - { - Bu::File sf("testfile1", Bu::File::WriteNew ); - for( int c = 0; c < 256; c++ ) - { - unsigned char ch = (unsigned char)c; - sf.write( &ch, 1 ); - unitTest( sf.tell() == c+1 ); - } - //unitTest( sf.canRead() == false ); - //unitTest( sf.canWrite() == true ); - //unitTest( sf.canSeek() == true ); - sf.close(); - struct stat sdat; - stat("testfile1", &sdat ); - unitTest( sdat.st_size == 256 ); - } + test writeFull + { + Bu::File sf("testfile1", Bu::File::WriteNew ); + for( int c = 0; c < 256; c++ ) + { + unsigned char ch = (unsigned char)c; + sf.write( &ch, 1 ); + unitTest( sf.tell() == c+1 ); + } + //unitTest( sf.canRead() == false ); + //unitTest( sf.canWrite() == true ); + //unitTest( sf.canSeek() == true ); + sf.close(); + struct stat sdat; + stat("testfile1", &sdat ); + unitTest( sdat.st_size == 256 ); + } - test readBlocks - { - Bu::File sf("testfile1", Bu::File::Read ); - unsigned char buf[50]; - size_t total = 0; - for(;;) - { - size_t s = sf.read( buf, 50 ); - for( size_t c = 0; c < s; c++ ) - { - unitTest( buf[c] == (unsigned char)(c+total) ); - } - total += s; - if( s < 50 ) - { - unitTest( total == 256 ); - unitTest( sf.isEos() == false ); - unitTest( sf.read( buf, 1 ) == 0 ); - unitTest( sf.isEos() == true ); - // EOS is only set when an attempt to read past the end of - // the stream is made, not when a short block is returned. - break; - } - } - sf.close(); - } + test readBlocks + { + Bu::File sf("testfile1", Bu::File::Read ); + unsigned char buf[50]; + size_t total = 0; + for(;;) + { + size_t s = sf.read( buf, 50 ); + for( size_t c = 0; c < s; c++ ) + { + unitTest( buf[c] == (unsigned char)(c+total) ); + } + total += s; + if( s < 50 ) + { + unitTest( total == 256 ); + unitTest( sf.isEos() == false ); + unitTest( sf.read( buf, 1 ) == 0 ); + unitTest( sf.isEos() == true ); + // EOS is only set when an attempt to read past the end of + // the stream is made, not when a short block is returned. + break; + } + } + sf.close(); + } - test readError1 - { - try - { - Bu::File sf("doesn'texist", Bu::File::Read ); - unitFailed("No exception thrown"); - } - catch( Bu::FileException &e ) - { - return; - } - } + test readError1 + { + try + { + Bu::File sf("doesn'texist", Bu::File::Read ); + unitFailed("No exception thrown"); + } + catch( Bu::FileException &e ) + { + return; + } + } - test readError2 - { - Bu::File sf("testfile1", Bu::File::Read ); - char buf[256]; - int r = sf.read( buf, 256 ); - unitTest( r == 256 ); - // You have to read past the end to set the EOS flag. - unitTest( sf.isEos() == false ); - try - { - if( sf.read( buf, 5 ) > 0 ) - { - unitFailed("Non-zero read result"); - } - else - { - sf.close(); - } - } - catch( Bu::FileException &e ) - { - sf.close(); - return; - } - } + test readError2 + { + Bu::File sf("testfile1", Bu::File::Read ); + char buf[256]; + int r = sf.read( buf, 256 ); + unitTest( r == 256 ); + // You have to read past the end to set the EOS flag. + unitTest( sf.isEos() == false ); + try + { + if( sf.read( buf, 5 ) > 0 ) + { + unitFailed("Non-zero read result"); + } + else + { + sf.close(); + } + } + catch( Bu::FileException &e ) + { + sf.close(); + return; + } + } } -- cgit v1.2.3