From 033ea850f365e2c1e72fb9e0289777d8fe777321 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 19 Mar 2023 12:08:44 +0200 Subject: [PATCH] Formatting - Explicitly make the formatting functions `public` Client - Added unit tests for formatting functions --- source/birchwood/client/client.d | 15 +++++++++++++++ source/birchwood/protocol/formatting.d | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index 28b120a..96fd367 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -1098,6 +1098,21 @@ public class Client : Thread client.directMessage("(3) Message to myself (multi)", ["birchwood", "birchwood"]); + /** + * Test formatting of text + */ + import birchwood.protocol.formatting; + string formattedTextBold = bold("Hello in bold!"); + string formattedTextItalics = italics("Hello in italics!"); + string formattedTextUnderline = underline("Hello in underline!"); + string formattedTextMonospace = monospace("Hello in monospace!"); + string formattedTextStrikthrough = strikethrough("Hello in strikethrough!"); + client.channelMessage(formattedTextBold, "#birchwood"); + client.channelMessage(formattedTextItalics, "#birchwood"); + client.channelMessage(formattedTextUnderline, "#birchwood"); + client.channelMessage(formattedTextMonospace, "#birchwood"); + client.channelMessage(formattedTextStrikthrough, "#birchwood"); + /** diff --git a/source/birchwood/protocol/formatting.d b/source/birchwood/protocol/formatting.d index a4c415a..d1a3f27 100644 --- a/source/birchwood/protocol/formatting.d +++ b/source/birchwood/protocol/formatting.d @@ -123,7 +123,7 @@ string reset_fg_bg() * Returns: the boldened text */ pragma(inline) -string bold(string text) +public string bold(string text) { return bold_code~text~bold_code; } @@ -137,7 +137,7 @@ string bold(string text) * Returns: the italicized text */ pragma(inline) -string italics(string text) +public string italics(string text) { return italic_code~text~italic_code; } @@ -151,7 +151,7 @@ string italics(string text) * Returns: the underlined text */ pragma(inline) -string underline(string text) +public string underline(string text) { return underline_code~text~underline_code; } @@ -165,7 +165,7 @@ string underline(string text) * Returns: the strikethroughed text */ pragma(inline) -string strikethrough(string text) +public string strikethrough(string text) { return strikethrough_code~text~strikethrough_code; } @@ -179,7 +179,7 @@ string strikethrough(string text) * Returns: the monospaced text */ pragma(inline) -string monospace(string text) +public string monospace(string text) { return monospace_code~text~monospace_code; } \ No newline at end of file