mirror of https://github.com/deavmi/doap
Compare commits
6 Commits
b01649337e
...
a986a36c1d
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | a986a36c1d | |
Tristan B. Velloza Kildaire | 61e8d51207 | |
Tristan B. Velloza Kildaire | 963b53fcc8 | |
Tristan B. Velloza Kildaire | 13b5e0a496 | |
Tristan B. Velloza Kildaire | 244f79f223 | |
Tristan B. Velloza Kildaire | 2017f6fd9a |
|
@ -26,6 +26,7 @@ jobs:
|
|||
- name: Install Doveralls (code coverage tool)
|
||||
run: |
|
||||
dub fetch doveralls
|
||||
sudo apt update
|
||||
sudo apt install libcurl4-openssl-dev
|
||||
|
||||
- name: 'Build & Test'
|
||||
|
|
|
@ -39,20 +39,8 @@ public struct CoapOption
|
|||
{
|
||||
return this.id-right.id;
|
||||
}
|
||||
|
||||
// public bool opEquals(CoapOption right)
|
||||
// {
|
||||
// return (this.id == right.id)
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private int optionSort(CoapOption left, CoapOption right)
|
||||
{
|
||||
return left.id-right.id;
|
||||
}
|
||||
|
||||
|
||||
// TODO: remove this
|
||||
import std.stdio : writeln;
|
||||
|
||||
|
@ -300,7 +288,7 @@ public class CoapPacket
|
|||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes the currently set options
|
||||
* and orders them and returns an ordered
|
||||
|
@ -495,9 +483,20 @@ public class CoapPacket
|
|||
this.mid = mid;
|
||||
}
|
||||
|
||||
public void setOptions()
|
||||
/**
|
||||
* Adds the provided options
|
||||
*
|
||||
* Params:
|
||||
* options = the options to
|
||||
* add
|
||||
*/
|
||||
public void setOptions(CoapOption[] options)
|
||||
{
|
||||
// FIXME: Implement me
|
||||
// Add each option (duplication done in callee)
|
||||
foreach(CoapOption option; options)
|
||||
{
|
||||
addOption(option);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1033,18 +1032,26 @@ unittest
|
|||
CoapOption(65005, [1])
|
||||
];
|
||||
|
||||
// Create a new packet
|
||||
CoapPacket pack = new CoapPacket();
|
||||
foreach(CoapOption option; expectedOptions)
|
||||
|
||||
// Create a copy of the options to add, reverse them in place
|
||||
// ... (this is to test that the encoder orders them correctly)
|
||||
import std.algorithm : reverse;
|
||||
foreach(CoapOption option; reverse(expectedOptions.dup))
|
||||
{
|
||||
pack.addOption(option);
|
||||
}
|
||||
|
||||
|
||||
// Encode
|
||||
ubyte[] encodedPacket = pack.getBytes();
|
||||
|
||||
// Now try decode the packet to we can see if it decodes
|
||||
// ... the options correctly
|
||||
CoapPacket actualPacket = CoapPacket.fromBytes(encodedPacket);
|
||||
|
||||
// Grab the options
|
||||
CoapOption[] actualOptions = actualPacket.getOptions();
|
||||
|
||||
// We should have the same number of operations
|
||||
|
|
Loading…
Reference in New Issue