Browse Source

Added a unit-test, and removed constness from a couple more return types.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
dce7cd9cd1
16 changed files with 79 additions and 53 deletions
  1. +3
    -3
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp
  2. +3
    -3
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h
  3. +0
    -5
      modules/juce_core/containers/juce_AbstractFifo.cpp
  4. +0
    -5
      modules/juce_core/files/juce_File.cpp
  5. +0
    -4
      modules/juce_core/json/juce_JSON.cpp
  6. +0
    -4
      modules/juce_core/streams/juce_MemoryInputStream.cpp
  7. +8
    -7
      modules/juce_core/streams/juce_MemoryOutputStream.cpp
  8. +2
    -2
      modules/juce_core/streams/juce_MemoryOutputStream.h
  9. +0
    -4
      modules/juce_core/text/juce_String.cpp
  10. +0
    -2
      modules/juce_core/threads/juce_ChildProcess.cpp
  11. +0
    -2
      modules/juce_core/threads/juce_Thread.cpp
  12. +54
    -0
      modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp
  13. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp
  14. +1
    -1
      modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h
  15. +4
    -7
      modules/juce_gui_basics/widgets/juce_TableListBox.cpp
  16. +3
    -3
      modules/juce_gui_basics/widgets/juce_TableListBox.h

+ 3
- 3
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp View File

@@ -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;


+ 3
- 3
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.h View File

@@ -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..


+ 0
- 5
modules/juce_core/containers/juce_AbstractFifo.cpp View File

@@ -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:


+ 0
- 5
modules/juce_core/files/juce_File.cpp View File

@@ -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:


+ 0
- 4
modules/juce_core/json/juce_JSON.cpp View File

@@ -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:


+ 0
- 4
modules/juce_core/streams/juce_MemoryInputStream.cpp View File

@@ -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:


+ 8
- 7
modules/juce_core/streams/juce_MemoryOutputStream.cpp View File

@@ -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 <char*> (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 <char*> (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

+ 2
- 2
modules/juce_core/streams/juce_MemoryOutputStream.h View File

@@ -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


+ 0
- 4
modules/juce_core/text/juce_String.cpp View File

@@ -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:


+ 0
- 2
modules/juce_core/threads/juce_ChildProcess.cpp View File

@@ -63,8 +63,6 @@ String ChildProcess::readAllProcessOutput()
//==============================================================================
#if JUCE_UNIT_TESTS
#include "../unit_tests/juce_UnitTest.h"
class ChildProcessTests : public UnitTest
{
public:


+ 0
- 2
modules/juce_core/threads/juce_Thread.cpp View File

@@ -333,8 +333,6 @@ void SpinLock::enter() const noexcept
//==============================================================================
#if JUCE_UNIT_TESTS
#include "../unit_tests/juce_UnitTest.h"
class AtomicTests : public UnitTest
{
public:


+ 54
- 0
modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp View File

@@ -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

+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.cpp View File

@@ -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");
}


+ 1
- 1
modules/juce_gui_basics/filebrowser/juce_FileBrowserComponent.h View File

@@ -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.
*/


+ 4
- 7
modules/juce_gui_basics/widgets/juce_TableListBox.cpp View File

@@ -205,7 +205,6 @@ public:
return columnComponents [owner.getHeader().getIndexOfColumnId (columnId, true)];
}
private:
TableListBox& owner;
OwnedArray<Component> 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<int> TableListBox::getCellPosition (const int columnId, const int rowNumber,
const bool relativeToComponentTopLeft) const
Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowNumber,
const bool relativeToComponentTopLeft) const
{
Rectangle<int> 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<int>&) { return var::null; }
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { 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

+ 3
- 3
modules/juce_gui_basics/widgets/juce_TableListBox.h View File

@@ -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<int> getCellPosition (int columnId, int rowNumber,
bool relativeToComponentTopLeft) const;
Rectangle<int> 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,


Loading…
Cancel
Save