diff --git a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp index 65f37d482f..d50abb3d85 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp @@ -406,7 +406,7 @@ bool ProjectTreeViewBase::mightContainSubItems() return item.getNumChildren() > 0; } -const String ProjectTreeViewBase::getUniqueName() const +String ProjectTreeViewBase::getUniqueName() const { jassert (item.getID().isNotEmpty()); return item.getID(); @@ -487,12 +487,12 @@ void ProjectTreeViewBase::itemSelectionChanged (bool isNowSelected) } } -const String ProjectTreeViewBase::getTooltip() +String ProjectTreeViewBase::getTooltip() { return String::empty; } -const var ProjectTreeViewBase::getDragSourceDescription() +var ProjectTreeViewBase::getDragSourceDescription() { delayedSelectionTimer = nullptr; return projectItemDragType; diff --git a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h index 93e95d1cec..89b75c174d 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h +++ b/extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h @@ -79,14 +79,14 @@ public: //============================================================================== // TreeViewItem stuff.. bool mightContainSubItems(); - const String getUniqueName() const; + String getUniqueName() const; void itemOpennessChanged (bool isNowOpen); void refreshSubItems(); bool canBeSelected() const { return true; } void itemDoubleClicked (const MouseEvent& e); void itemSelectionChanged (bool isNowSelected); - const String getTooltip(); - const var getDragSourceDescription(); + String getTooltip(); + var getDragSourceDescription(); //============================================================================== // Drag-and-drop stuff.. diff --git a/modules/juce_core/containers/juce_AbstractFifo.cpp b/modules/juce_core/containers/juce_AbstractFifo.cpp index e4889338dc..05ef3578e9 100644 --- a/modules/juce_core/containers/juce_AbstractFifo.cpp +++ b/modules/juce_core/containers/juce_AbstractFifo.cpp @@ -133,11 +133,6 @@ void AbstractFifo::finishedRead (int numRead) noexcept //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" -#include "../maths/juce_Random.h" -#include "../threads/juce_Thread.h" - - class AbstractFifoTests : public UnitTest { public: diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp index 362e4acf08..ce0d092338 100644 --- a/modules/juce_core/files/juce_File.cpp +++ b/modules/juce_core/files/juce_File.cpp @@ -901,11 +901,6 @@ File File::createTempFile (const String& fileNameEnding) //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" -#include "../maths/juce_Random.h" -#include "juce_MemoryMappedFile.h" - - class FileTests : public UnitTest { public: diff --git a/modules/juce_core/json/juce_JSON.cpp b/modules/juce_core/json/juce_JSON.cpp index d5569f3635..ff48b5ab76 100644 --- a/modules/juce_core/json/juce_JSON.cpp +++ b/modules/juce_core/json/juce_JSON.cpp @@ -525,10 +525,6 @@ void JSON::writeToStream (OutputStream& output, const var& data, const bool allO //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" -#include "../maths/juce_Random.h" - - class JSONTests : public UnitTest { public: diff --git a/modules/juce_core/streams/juce_MemoryInputStream.cpp b/modules/juce_core/streams/juce_MemoryInputStream.cpp index ee0338a8c8..1f621e4510 100644 --- a/modules/juce_core/streams/juce_MemoryInputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryInputStream.cpp @@ -95,10 +95,6 @@ int64 MemoryInputStream::getPosition() //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" -#include "../maths/juce_Random.h" -#include "juce_MemoryOutputStream.h" - class MemoryStreamTests : public UnitTest { public: diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.cpp b/modules/juce_core/streams/juce_MemoryOutputStream.cpp index 078407f824..ae6e3ba273 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.cpp +++ b/modules/juce_core/streams/juce_MemoryOutputStream.cpp @@ -103,17 +103,17 @@ void MemoryOutputStream::writeRepeatedByte (uint8 byte, int howMany) } } -const MemoryBlock& MemoryOutputStream::getMemoryBlock() const noexcept +MemoryBlock MemoryOutputStream::getMemoryBlock() const { - if (data.getSize() > size) - static_cast (data.getData()) [size] = 0; - - return data; + return MemoryBlock (getData(), getDataSize()); } const void* MemoryOutputStream::getData() const noexcept { - return getMemoryBlock().getData(); + if (data.getSize() > size) + static_cast (data.getData()) [size] = 0; + + return data.getData(); } bool MemoryOutputStream::setPosition (int64 newPosition) @@ -160,7 +160,8 @@ String MemoryOutputStream::toString() const OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead) { - return stream << streamToRead.getMemoryBlock(); + stream.write (streamToRead.getData(), streamToRead.getDataSize()); + return stream; } END_JUCE_NAMESPACE diff --git a/modules/juce_core/streams/juce_MemoryOutputStream.h b/modules/juce_core/streams/juce_MemoryOutputStream.h index baf1ce7121..af137a28ce 100644 --- a/modules/juce_core/streams/juce_MemoryOutputStream.h +++ b/modules/juce_core/streams/juce_MemoryOutputStream.h @@ -97,8 +97,8 @@ public: */ String toString() const; - /** Returns the memory block that is being used internally to hold the data. */ - const MemoryBlock& getMemoryBlock() const noexcept; + /** Returns a copy of the stream's data as a memory block. */ + MemoryBlock getMemoryBlock() const; //============================================================================== /** If the stream is writing to a user-supplied MemoryBlock, this will trim any excess diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 78af6eaf6c..669005db08 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -2095,10 +2095,6 @@ void String::Concatenator::append (const String& s) //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" -#include "../maths/juce_Random.h" -#include "juce_StringArray.h" - class StringTests : public UnitTest { public: diff --git a/modules/juce_core/threads/juce_ChildProcess.cpp b/modules/juce_core/threads/juce_ChildProcess.cpp index 9324fd114e..114a25aff0 100644 --- a/modules/juce_core/threads/juce_ChildProcess.cpp +++ b/modules/juce_core/threads/juce_ChildProcess.cpp @@ -63,8 +63,6 @@ String ChildProcess::readAllProcessOutput() //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" - class ChildProcessTests : public UnitTest { public: diff --git a/modules/juce_core/threads/juce_Thread.cpp b/modules/juce_core/threads/juce_Thread.cpp index 070dd7df2e..1767a66b7f 100644 --- a/modules/juce_core/threads/juce_Thread.cpp +++ b/modules/juce_core/threads/juce_Thread.cpp @@ -333,8 +333,6 @@ void SpinLock::enter() const noexcept //============================================================================== #if JUCE_UNIT_TESTS -#include "../unit_tests/juce_UnitTest.h" - class AtomicTests : public UnitTest { public: diff --git a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp index 812b82db75..e7bbe6840b 100644 --- a/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp +++ b/modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp @@ -195,4 +195,58 @@ bool GZIPCompressorOutputStream::setPosition (int64 /*newPosition*/) return false; } +//============================================================================== +#if JUCE_UNIT_TESTS + +class GZIPTests : public UnitTest +{ +public: + GZIPTests() : UnitTest ("GZIP") {} + + void runTest() + { + beginTest ("GZIP"); + Random rng; + + for (int i = 100; --i >= 0;) + { + MemoryOutputStream original, compressed, uncompressed; + + { + GZIPCompressorOutputStream zipper (&compressed, rng.nextInt (10), false); + + for (int j = rng.nextInt (100); --j >= 0;) + { + MemoryBlock data (rng.nextInt (2000) + 1); + + for (int k = data.getSize(); --k >= 0;) + data[k] = (char) rng.nextInt (255); + + original.write (data.getData(), data.getSize()); + zipper .write (data.getData(), data.getSize()); + } + } + + { + MemoryInputStream compressedInput (compressed.getData(), compressed.getDataSize(), false); + GZIPDecompressorInputStream unzipper (compressedInput); + + uncompressed.writeFromInputStream (unzipper, -1); + } + + expectEquals ((int) uncompressed.getDataSize(), + (int) original.getDataSize()); + + if (original.getDataSize() == uncompressed.getDataSize()) + expect (memcmp (uncompressed.getData(), + original.getData(), + original.getDataSize()) == 0); + } + } +}; + +static GZIPTests gzipTests; + +#endif + END_JUCE_NAMESPACE diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp index 91f2ee9299..4f2508e9f1 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp @@ -294,7 +294,7 @@ void FileBrowserComponent::setFileFilter (const FileFilter* const newFileFilter) } } -const String FileBrowserComponent::getActionVerb() const +String FileBrowserComponent::getActionVerb() const { return isSaveMode() ? TRANS("Save") : TRANS("Open"); } diff --git a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h index 389e9a0f9a..9c105ada77 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h @@ -153,7 +153,7 @@ public: E.g. if browsing in "load file" mode, this will be "Open", if in "save file" mode, it'll be "Save", etc. */ - virtual const String getActionVerb() const; + virtual String getActionVerb() const; /** Returns true if the saveMode flag was set when this component was created. */ diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp index 14190b3805..ec474f61bd 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.cpp @@ -205,7 +205,6 @@ public: return columnComponents [owner.getHeader().getIndexOfColumnId (columnId, true)]; } - private: TableListBox& owner; OwnedArray columnComponents; @@ -269,7 +268,6 @@ TableListBox::TableListBox (const String& name, TableListBoxModel* const model_) TableListBox::~TableListBox() { - header = nullptr; } void TableListBox::setModel (TableListBoxModel* const newModel) @@ -332,8 +330,8 @@ bool TableListBox::isAutoSizeMenuOptionShown() const return autoSizeOptionsShown; } -const Rectangle TableListBox::getCellPosition (const int columnId, const int rowNumber, - const bool relativeToComponentTopLeft) const +Rectangle TableListBox::getCellPosition (const int columnId, const int rowNumber, + const bool relativeToComponentTopLeft) const { Rectangle headerCell (header->getColumnPosition (header->getIndexOfColumnId (columnId, true))); @@ -479,8 +477,8 @@ void TableListBoxModel::deleteKeyPressed (int) {} void TableListBoxModel::returnKeyPressed (int) {} void TableListBoxModel::listWasScrolled() {} -const String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; } -var TableListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } +String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; } +var TableListBoxModel::getDragSourceDescription (const SparseSet&) { return var::null; } Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate) { @@ -489,5 +487,4 @@ Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component return nullptr; } - END_JUCE_NAMESPACE diff --git a/modules/juce_gui_basics/widgets/juce_TableListBox.h b/modules/juce_gui_basics/widgets/juce_TableListBox.h index 1768eab43d..59d4375010 100644 --- a/modules/juce_gui_basics/widgets/juce_TableListBox.h +++ b/modules/juce_gui_basics/widgets/juce_TableListBox.h @@ -146,7 +146,7 @@ public: /** Returns a tooltip for a particular cell in the table. */ - virtual const String getCellTooltip (int rowNumber, int columnId); + virtual String getCellTooltip (int rowNumber, int columnId); //============================================================================== /** Override this to be informed when rows are selected or deselected. @@ -275,8 +275,8 @@ public: If relativeToComponentTopLeft is false, the co-ords are relative to the top-left of the table's top-left cell. */ - const Rectangle getCellPosition (int columnId, int rowNumber, - bool relativeToComponentTopLeft) const; + Rectangle getCellPosition (int columnId, int rowNumber, + bool relativeToComponentTopLeft) const; /** Returns the component that currently represents a given cell. If the component for this cell is off-screen or if the position is out-of-range,