Skip to content

Commit

Permalink
Add unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xEAB committed Dec 29, 2024
1 parent 7c51a53 commit 74c14e2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions std/conv.d
Original file line number Diff line number Diff line change
Expand Up @@ -4834,6 +4834,40 @@ if (T.length > 0) { return textImpl!dstring(args); }
assert(dtext(cs, ' ', ws, " ", ds) == "今日は 여보세요 Здравствуйте"d);
}

// ensure that ranges are still printed properly
@safe unittest
{
static struct Range
{
int counter = 0;

@safe pure nothrow @nogc:
bool empty() const => (counter <= 0);
int front() const => counter;
void popFront() { --counter; }
}

auto m = Range(2);
const c = Range(3);
assert(text(m) == "[2, 1]");
assert(text(c) == "const(Range)(3)");
}

// ensure that a usage pattern seen in libraries like "unit-threaded" keeps working
@safe unittest
{
static final class Foo
{
override string toString() const @safe
{
return ":-)";
}
}

const c = new Foo();
assert(text(c) == ":-)");
}

private S textImpl(S, U...)(const(U) args)
{
static if (U.length == 0)
Expand Down

0 comments on commit 74c14e2

Please sign in to comment.