MCPcopy Create free account
hub / github.com/cinder/Cinder / readTest

Method readTest

test/streamFileTest/src/streamFileTestApp.cpp:50–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49template<typename S>
50void streamFileTestApp::readTest( fs::path filePath )
51{
52 console() << " File: " << filePath << std::endl;
53 {
54 shared_ptr<S> s = S::create( fopen( filePath.string().c_str(), "rb" ) );
55 for( size_t d = 0; d < DATA_SIZE; ++d ) {
56 uint8_t b;
57 s->read( &b );
58 if( ! dataChecksOut( &b, 1, d ) )
59 throw;
60 }
61 console() << " Passed single byte reads" << std::endl;
62 }
63
64 {
65 shared_ptr<S> s = S::create( fopen( filePath.string().c_str(), "rb" ) );
66 for( size_t d = 0; d < DATA_SIZE; d += 4 ) {
67 uint8_t b[4];
68 s->readLittle( reinterpret_cast<uint32_t*>( &b ) );
69 if( ! dataChecksOut( &b, 4, d ) )
70 throw;
71 }
72 console() << " Passed 4-byte reads" << std::endl;
73 }
74
75 for( int pass = 0; pass < 1000; ++pass ) {
76 shared_ptr<S> s = S::create( fopen( filePath.string().c_str(), "rb" ) );
77 size_t readSize;
78 const int MAX_READ_SIZE = 1024;
79 uint8_t buffer[MAX_READ_SIZE];
80 for( size_t d = 0; d < DATA_SIZE; d += readSize ) {
81 readSize = std::min<int>( DATA_SIZE - d, randInt(MAX_READ_SIZE) );
82 s->readData( buffer, readSize );
83 if( ! dataChecksOut( buffer, readSize, d ) )
84 throw;
85 }
86 }
87 console() << " Passed random readData" << std::endl;
88
89 for( int pass = 0; pass < 1000; ++pass ) {
90 shared_ptr<S> s = S::create( fopen( filePath.string().c_str(), "rb" ) );
91 size_t readSize;
92 const int MAX_READ_SIZE = 1024;
93 uint8_t buffer[MAX_READ_SIZE];
94 for( size_t d = 0; d < DATA_SIZE; d += readSize ) {
95 readSize = s->readDataAvailable( buffer, randInt(MAX_READ_SIZE) );
96 if( ! dataChecksOut( buffer, readSize, d ) )
97 throw;
98 }
99 }
100 console() << " Passed random readDataAvailable" << std::endl;
101
102 for( int pass = 0; pass < 1000; ++pass ) {
103 shared_ptr<S> s = S::create( fopen( filePath.string().c_str(), "rb" ) );
104 size_t readSize;
105 const int MAX_READ_SIZE = 1024;
106 uint8_t buffer[MAX_READ_SIZE];
107 for( size_t d = 0; d < DATA_SIZE; d += readSize ) {

Callers

nothing calls this directly

Calls 10

dataChecksOutFunction · 0.85
randIntFunction · 0.85
randBoolFunction · 0.85
readLittleMethod · 0.80
readDataMethod · 0.80
createFunction · 0.50
c_strMethod · 0.45
stringMethod · 0.45
readMethod · 0.45
readDataAvailableMethod · 0.45

Tested by

no test coverage detected