26 int64 juce_fileSetPosition (
void* handle, int64 pos);
50 jassert (buffer !=
nullptr && bytesToRead >= 0);
52 auto num = readInternal (buffer, (
size_t) bytesToRead);
53 currentPosition += (int64) num;
65 return currentPosition;
73 if (pos != currentPosition)
74 currentPosition = juce_fileSetPosition (fileHandle, pos);
76 return currentPosition == pos;
84 struct FileInputStreamTests :
public UnitTest 86 FileInputStreamTests()
87 :
UnitTest (
"FileInputStream", UnitTestCategories::streams)
90 void runTest()
override 92 const MemoryBlock data (
"abcdefghijklmnopqrstuvwxyz", 26);
104 size_t numBytesRead = 0;
107 while (numBytesRead < data.
getSize())
109 numBytesRead += (size_t) stream.
read (&readBuffer[numBytesRead], 3);
111 expectEquals (stream.
getPosition(), (int64) numBytesRead);
120 expect (readBuffer == data);
131 const int numBytesToSkip = 5;
133 while (numBytesRead < data.
getSize())
136 numBytesRead += numBytesToSkip;
137 numBytesRead = std::min (numBytesRead, data.
getSize());
139 expectEquals (stream.
getPosition(), (int64) numBytesRead);
152 static FileInputStreamTests fileInputStreamTests;
size_t getSize() const noexcept
bool appendData(const void *dataToAppend, size_t numberOfBytes) const
void * getData() noexcept
static File createTempFile(StringRef fileNameEnding)