upgrade to JUCE 5.4.3. Remove (probably) unused JUCE modules. Remove VST2 target (it's been end-of-life'd by Steinberg and by JUCE)
This commit is contained in:
@ -76,4 +76,79 @@ bool FileInputStream::setPosition (int64 pos)
|
||||
return currentPosition == pos;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_UNIT_TESTS
|
||||
|
||||
struct FileInputStreamTests : public UnitTest
|
||||
{
|
||||
FileInputStreamTests()
|
||||
: UnitTest ("FileInputStream", "Streams")
|
||||
{}
|
||||
|
||||
void runTest() override
|
||||
{
|
||||
const MemoryBlock data ("abcdefghijklmnopqrstuvwxyz", 26);
|
||||
File f (File::createTempFile (".txt"));
|
||||
f.appendData (data.getData(), data.getSize());
|
||||
FileInputStream stream (f);
|
||||
|
||||
beginTest ("Read");
|
||||
|
||||
expectEquals (stream.getPosition(), (int64) 0);
|
||||
expectEquals (stream.getTotalLength(), (int64) data.getSize());
|
||||
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
|
||||
expect (! stream.isExhausted());
|
||||
|
||||
size_t numBytesRead = 0;
|
||||
MemoryBlock readBuffer (data.getSize());
|
||||
|
||||
while (numBytesRead < data.getSize())
|
||||
{
|
||||
numBytesRead += (size_t) stream.read (&readBuffer[numBytesRead], 3);
|
||||
|
||||
expectEquals (stream.getPosition(), (int64) numBytesRead);
|
||||
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
|
||||
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
|
||||
}
|
||||
|
||||
expectEquals (stream.getPosition(), (int64) data.getSize());
|
||||
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
|
||||
expect (stream.isExhausted());
|
||||
|
||||
expect (readBuffer == data);
|
||||
|
||||
beginTest ("Skip");
|
||||
|
||||
stream.setPosition (0);
|
||||
expectEquals (stream.getPosition(), (int64) 0);
|
||||
expectEquals (stream.getTotalLength(), (int64) data.getSize());
|
||||
expectEquals (stream.getNumBytesRemaining(), stream.getTotalLength());
|
||||
expect (! stream.isExhausted());
|
||||
|
||||
numBytesRead = 0;
|
||||
const int numBytesToSkip = 5;
|
||||
|
||||
while (numBytesRead < data.getSize())
|
||||
{
|
||||
stream.skipNextBytes (numBytesToSkip);
|
||||
numBytesRead += numBytesToSkip;
|
||||
numBytesRead = std::min (numBytesRead, data.getSize());
|
||||
|
||||
expectEquals (stream.getPosition(), (int64) numBytesRead);
|
||||
expectEquals (stream.getNumBytesRemaining(), (int64) (data.getSize() - numBytesRead));
|
||||
expect (stream.isExhausted() == (numBytesRead == data.getSize()));
|
||||
}
|
||||
|
||||
expectEquals (stream.getPosition(), (int64) data.getSize());
|
||||
expectEquals (stream.getNumBytesRemaining(), (int64) 0);
|
||||
expect (stream.isExhausted());
|
||||
|
||||
f.deleteFile();
|
||||
}
|
||||
};
|
||||
|
||||
static FileInputStreamTests fileInputStreamTests;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
Reference in New Issue
Block a user