Skip to content

Commit

Permalink
bugfix: Require unit_threaded only in the testfunctions themselves
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
gizmomogwai committed Apr 4, 2023
1 parent 5785511 commit 5d2a7e0
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions source/colored/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ version (unittest)
import std.conv : to;
import std.process : environment;
import std.stdio : writeln, write;
import unit_threaded;
}
/// Available Colors
enum AnsiColor
Expand Down Expand Up @@ -180,11 +179,13 @@ string onRgb(string s, ubyte r, ubyte g, ubyte b)
return RGBString(s).onRgb(r, g, b).to!string;
}

/+
@system @("rgb") unittest
{
// import std.experimental.color : RGBA8, convertColor;
// import std.experimental.color.hsx : HSV;
/*
import unit_threaded;
import std.experimental.color : RGBA8, convertColor;
import std.experimental.color.hsx : HSV;
writeln("red: ", "r".rgb(255, 0, 0).onRgb(0, 255, 0));
writeln("green: ", "g".rgb(0, 255, 0).onRgb(0, 0, 255));
writeln("blue: ", "b".rgb(0, 0, 255).onRgb(255, 0, 0));
Expand All @@ -197,8 +198,8 @@ string onRgb(string s, ubyte r, ubyte g, ubyte b)
}
writeln;
}
*/
/*
int delay = environment.get("DELAY", "0").to!int;
for (int j = 0; j < 255; j += 1)
{
Expand All @@ -211,12 +212,14 @@ string onRgb(string s, ubyte r, ubyte g, ubyte b)
Thread.sleep(delay.msecs);
write("\r");
}
*/
writeln;
}
+/

@system @("styledstring") unittest
{
import unit_threaded;
foreach (immutable color; [EnumMembers!AnsiColor])
{
auto colorName = "%s".format(color);
Expand All @@ -239,6 +242,7 @@ string onRgb(string s, ubyte r, ubyte g, ubyte b)

@system @("styledstring ~") unittest
{
import unit_threaded;
("test".red ~ "blub").should == "\033[31mtest\033[0mblub";
}

Expand Down Expand Up @@ -281,6 +285,7 @@ mixin(styleMixin!Style);

@system @("api") unittest
{
import unit_threaded;
"redOnGreen".red.onGreen.writeln;
"redOnYellowBoldUnderlined".red.onYellow.bold.underlined.writeln;
"bold".bold.writeln;
Expand Down Expand Up @@ -414,6 +419,7 @@ auto tokenize(Range)(Range parts)

@system @("ansi tokenizer") unittest
{
import unit_threaded;
[38, 5, 2, 38, 2, 1, 2, 3, 36, 1, 2, 3, 4].tokenize.should == ([
[38, 5, 2], [38, 2, 1, 2, 3], [36], [1], [2], [3], [4]
]);
Expand Down Expand Up @@ -520,6 +526,7 @@ auto rightJustifyFormattedString(string s, ulong width, char fillChar = ' ')

@system @("rightJustifyFormattedString") unittest
{
import unit_threaded;
"test".red.to!string.rightJustifyFormattedString(10).should == (" \033[31mtest\033[0m");
}

Expand All @@ -530,6 +537,7 @@ auto forceStyle(string text, Style style) {

@("forceStyle") unittest
{
import unit_threaded;
auto splitt = "1es2eses3".split("es").filter!(not!(empty));
splitt.should == ["1", "2", "3"];
string s = "noformatting%snoformatting".format("red".red).forceStyle(Style.reverse);
Expand Down

0 comments on commit 5d2a7e0

Please sign in to comment.