41 return addressPattern;
47 return arguments.size();
52 return arguments.isEmpty();
57 return arguments.getReference (i);
62 return arguments.getReference (i);
67 return arguments.begin();
72 return arguments.begin();
77 return arguments.end();
82 return arguments.end();
110 void runTest()
override
112 beginTest (
"Basic usage");
114 OSCMessage msg (
"/test/param0");
115 expectEquals (msg.size(), 0);
116 expect (msg.getAddressPattern().toString() ==
"/test/param0");
123 const OSCColour
testColour = { 10, 20, 150, 200 };
136 expectEquals (msg[0].getType(), OSCTypes::int32);
137 expectEquals (msg[1].getType(), OSCTypes::float32);
138 expectEquals (msg[2].getType(), OSCTypes::string);
139 expectEquals (msg[3].getType(), OSCTypes::blob);
140 expectEquals (msg[4].getType(), OSCTypes::colour);
142 expect (msg[0].isInt32());
143 expect (msg[1].isFloat32());
144 expect (msg[2].isString());
145 expect (msg[3].isBlob());
146 expect (msg[4].isColour());
148 expectEquals (msg[0].getInt32(),
testInt);
149 expectEquals (msg[1].getFloat32(),
testFloat);
150 expectEquals (msg[2].getString(),
testString);
151 expect (msg[3].getBlob() ==
testBlob);
152 expect (msg[4].getColour().toInt32() ==
testColour.toInt32());
156 auto arg = msg.begin();
157 expect (
arg->isInt32());
160 expect (
arg->isFloat32());
163 expect (
arg->isString());
166 expect (
arg->isBlob());
169 expect (
arg->isColour());
172 expect (
arg == msg.end());
176 beginTest (
"Initialisation with argument list (C++11 only)");
183 OSCMessage msg (
"/test",
testInt);
184 expect (msg.getAddressPattern().toString() == String (
"/test"));
185 expectEquals (msg.size(), 1);
186 expect (msg[0].isInt32());
187 expectEquals (msg[0].getInt32(),
testInt);
191 expect (msg.getAddressPattern().toString() == String (
"/test"));
192 expectEquals (msg.size(), 1);
193 expect (msg[0].isFloat32());
194 expectEquals (msg[0].getFloat32(),
testFloat);
198 expect (msg.getAddressPattern().toString() == String (
"/test"));
199 expectEquals (msg.size(), 1);
200 expect (msg[0].isString());
201 expectEquals (msg[0].getString(),
testString);
205 expect (msg.getAddressPattern().toString() == String (
"/test"));
206 expectEquals (msg.size(), 5);
207 expect (msg[0].isInt32());
208 expect (msg[1].isFloat32());
209 expect (msg[2].isString());
210 expect (msg[3].isFloat32());
211 expect (msg[4].isInt32());
213 expectEquals (msg[0].getInt32(),
testInt);
214 expectEquals (msg[1].getFloat32(),
testFloat);
215 expectEquals (msg[2].getString(),
testString);
216 expectEquals (msg[3].getFloat32(),
testFloat);
217 expectEquals (msg[4].getInt32(),
testInt);
A class to hold a resizable block of raw data.
void addInt32(int32 value)
Creates a new OSCArgument of type int32 with the given value, and adds it to the OSCMessage object.
OSCArgument & operator[](int i) noexcept
Returns a reference to the OSCArgument at index i in the OSCMessage object.
void addString(const String &value)
Creates a new OSCArgument of type string with the given value, and adds it to the OSCMessage object.
void addFloat32(float value)
Creates a new OSCArgument of type float32 with the given value, and adds it to the OSCMessage object.
void setAddressPattern(const OSCAddressPattern &ap) noexcept
Sets the address pattern of the OSCMessage.
OSCMessage(const OSCAddressPattern &ap) noexcept
Constructs an OSCMessage object with the given address pattern and no arguments.
OSCAddressPattern getAddressPattern() const noexcept
Returns the address pattern of the OSCMessage.
OSCArgument * end() noexcept
Returns a pointer to the last OSCArgument in the OSCMessage object.
void clear()
Removes all arguments from the OSCMessage.
bool isEmpty() const noexcept
Returns true if the OSCMessage contains no OSCArgument objects; false otherwise.
void addBlob(MemoryBlock blob)
Creates a new OSCArgument of type blob with binary data content copied from the given MemoryBlock.
OSCArgument * begin() noexcept
Returns a pointer to the first OSCArgument in the OSCMessage object.
void addArgument(OSCArgument argument)
Adds the OSCArgument argument to the OSCMessage object.
int size() const noexcept
Returns the number of OSCArgument objects that belong to this OSCMessage.
void addColour(OSCColour colour)
Creates a new OSCArgument of type colour with the given value, and adds it to the OSCMessage object.
This is a base class for classes that perform a unit test.
signed int int32
A platform-independent 32-bit signed integer type.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
Holds a 32-bit RGBA colour for passing to and from an OSCArgument.