From 0e9c042d213b9d6d5e346b6d47f66f2e02d6dac2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Fri, 17 Mar 2023 09:18:17 +0200 Subject: [PATCH 1/3] Unit tests - Cleaned up --- source/birchwood/protocol/messages.d | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index c088e70..0f405de 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -300,10 +300,13 @@ public final class Message private string[] ppPairs; - unittest + version(unittest) { import std.stdio; + } + unittest + { string testInput = "A:=1 A=2 :Hello this is text"; writeln("Input: ", testInput); @@ -323,8 +326,6 @@ public final class Message unittest { - import std.stdio; - string testInput = ":Hello this is text"; bool hasTrailer; string[] splitted = splitting(testInput, hasTrailer); From d982205b1b4c4c2d791ca29936249cbcd5c1d919 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Fri, 17 Mar 2023 09:20:54 +0200 Subject: [PATCH 2/3] Messages - Documented `getKVPairs()`, `getTrailing()` and `getPairs()` --- source/birchwood/protocol/messages.d | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index 0f405de..1e29dc1 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -279,17 +279,35 @@ public final class Message return params; } - + /** + * Retrieves the trailing text in the paramaters + * (if any) + * + * Returns: the trailing text + */ public string getTrailing() { return ppTrailing; } + /** + * Returns the parameters excluding the trailing text + * which are seperated by spaces but only those + * which are key-value pairs + * + * Returns: the key-value pair parameters + */ public string[string] getKVPairs() { return ppKVPairs; } + /** + * Returns the parameters excluding the trailing text + * which are seperated by spaces + * + * Returns: the parameters + */ public string[] getPairs() { return ppPairs; From c6953057e8dd076708b842161e3c372020b655c2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Fri, 17 Mar 2023 09:29:04 +0200 Subject: [PATCH 3/3] Client - Disable testing code for now --- source/birchwood/client/client.d | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 1e2c7da..5c79113 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -139,22 +139,25 @@ public class Client : Thread if(commandReply.getReplyType() == ReplyType.RPL_BOUNCE) { - logger.log(); - logger.log("<<<>>>"); + // TODO: Testing code was here + // logger.log(); + // logger.log("<<<>>>"); - logger.log("Take a look:\n\n"~commandReply.getParams()); + // logger.log("Take a look:\n\n"~commandReply.getParams()); - logger.log("And here is key-value pairs: ", commandReply.getKVPairs()); - logger.log("And here is array: ", commandReply.getPairs()); + // logger.log("And here is key-value pairs: ", commandReply.getKVPairs()); + // logger.log("And here is array: ", commandReply.getPairs()); - // TODO: DLog bug, this prints nothing - logger.log("And here is trailing: ", commandReply.getTrailing().length); + // // TODO: DLog bug, this prints nothing + // logger.log("And here is trailing: ", commandReply.getTrailing()); - import std.stdio; - writeln("Trailer: "~commandReply.getTrailing()); + // import std.stdio; + // writeln("Trailer: "~commandReply.getTrailing()); - logger.log("<<<>>>"); - logger.log(); + // writeln(cast(ubyte[])commandReply.getTrailing()); + + // logger.log("<<<>>>"); + // logger.log();