- Added unit tests

- Updated `.gitignore`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-25 22:32:40 +02:00
parent bef4f852bf
commit 2eb45381d1
2 changed files with 17 additions and 0 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@ docs/
# Code coverage
*.lst
dub.selections.json
bformat-test-library

View File

@ -88,4 +88,20 @@ public byte[] encodeBformat(byte[] message)
messageBuffer ~= cast(byte[])message;
return messageBuffer;
}
version(unittest)
{
import std.string : cmp;
}
unittest
{
string message = "This is my message";
byte[] bformatEncoded = encodeBformat(cast(byte[])message);
byte[] decodedMessageBytes = decodeMessage(bformatEncoded);
string decodedMessage = cast(string)decodedMessageBytes;
assert(cmp(message, decodedMessage) == 0);
}