mirror of
https://github.com/deavmi/doap
synced 2024-07-04 15:50:15 +02:00
Packet (unit tests)
- Ensure the message ID is encoded properly in big endian format
This commit is contained in:
parent
edf7de3839
commit
0e450556be
|
@ -37,7 +37,7 @@ public class CoapPacket
|
||||||
// Set the request/response code
|
// Set the request/response code
|
||||||
encoded ~= code;
|
encoded ~= code;
|
||||||
|
|
||||||
// Set the message ID
|
// Set the message ID (encoded as big endian)
|
||||||
version(LittleEndian)
|
version(LittleEndian)
|
||||||
{
|
{
|
||||||
ubyte* basePtr = cast(ubyte*)∣
|
ubyte* basePtr = cast(ubyte*)∣
|
||||||
|
@ -129,6 +129,8 @@ unittest
|
||||||
|
|
||||||
packet.setCode(Code.PONG);
|
packet.setCode(Code.PONG);
|
||||||
|
|
||||||
|
packet.setMessageId(257);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,4 +164,9 @@ unittest
|
||||||
writeln(code);
|
writeln(code);
|
||||||
assert(secondByte == Code.PONG);
|
assert(secondByte == Code.PONG);
|
||||||
|
|
||||||
|
// Ensure the message ID is 257
|
||||||
|
ubyte thirdByte = encoded[2], fourthByte = encoded[3];
|
||||||
|
assert(thirdByte == 1);
|
||||||
|
assert(fourthByte == 1);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user