add compiletime test

This commit is contained in:
Daylin Morgan 2025-01-27 12:18:45 -06:00
parent 7f37590184
commit 8340e76424
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -6,6 +6,7 @@ bbMode = On
template bbCheck(input: string, output: string): untyped = template bbCheck(input: string, output: string): untyped =
check escape($bb(input)) == escape(output) check escape($bb(input)) == escape(output)
suite "basic": suite "basic":
test "simple": test "simple":
bbCheck "[red][/red]", "" bbCheck "[red][/red]", ""
@ -16,6 +17,10 @@ suite "basic":
bbCheck "[red]5[/]", "\e[38;5;1m5\e[0m" bbCheck "[red]5[/]", "\e[38;5;1m5\e[0m"
bbCheck "[bold][red]5","\e[1;38;5;1m5\e[0m" bbCheck "[bold][red]5","\e[1;38;5;1m5\e[0m"
test "compile time":
const s = bb"[red]red text"
check s == bb"[red]red text"
test "closing": test "closing":
bbCheck "[bold]Bold[red] Bold Red[/red] Bold Only", bbCheck "[bold]Bold[red] Bold Red[/red] Bold Only",
"\e[1mBold\e[0m\e[1;38;5;1m Bold Red\e[0m\e[1m Bold Only\e[0m" "\e[1mBold\e[0m\e[1;38;5;1m Bold Red\e[0m\e[1m Bold Only\e[0m"
@ -102,3 +107,4 @@ suite "strutils":
check bb"[red]red[/]yellow" == y check bb"[red]red[/]yellow" == y