mirror of
https://github.com/deavmi/doap
synced 2024-07-04 15:50:15 +02:00
Packet (unit tests)
- Added a unit test which tests the encoding - So far it just checks that the version is encoded correctly
This commit is contained in:
parent
3a3febc61e
commit
8e8d1d2ba1
|
@ -34,7 +34,37 @@ public class CoapPacket
|
|||
// Set the request/response code
|
||||
encoded ~= code;
|
||||
|
||||
// Set the message ID
|
||||
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
// public ubyte getVersion()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Encoding tests
|
||||
*
|
||||
* These set high level parameters and then
|
||||
* we call `getBytes()` and analyse the components
|
||||
* of the encoded wire format by hand to ensure
|
||||
* they are set in place correctly
|
||||
*/
|
||||
unittest
|
||||
{
|
||||
CoapPacket packet = new CoapPacket();
|
||||
ubyte[] encoded = packet.getBytes();
|
||||
|
||||
ubyte firstByte = encoded[0];
|
||||
|
||||
// Ensure the version is set to 1
|
||||
ubyte versionField = cast(ubyte)(firstByte & 192) >> 6;
|
||||
assert(versionField == 1);
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user