mirror of
https://github.com/dlang/phobos.git
synced 2025-05-05 01:20:40 +03:00
Added CTFE-ability tests to some stuff in std.conv and std.string.
These tests are for the functionality that std.metastrings provides, and we need to ensure that the normal functions which are replacing those in std.metastrings continue to work in CTFE.
This commit is contained in:
parent
20e6064ea8
commit
9bd4044536
2 changed files with 17 additions and 0 deletions
13
std/conv.d
13
std/conv.d
|
@ -974,6 +974,11 @@ unittest
|
|||
assert(wtext(int.max) == "2147483647"w);
|
||||
assert(wtext(int.min) == "-2147483648"w);
|
||||
assert(to!string(0L) == "0");
|
||||
|
||||
//Test CTFE-ability.
|
||||
static assert(to!string(1uL << 62) == "4611686018427387904");
|
||||
static assert(to!string(0x100000000) == "4294967296");
|
||||
static assert(to!string(-138L) == "-138");
|
||||
}
|
||||
|
||||
unittest
|
||||
|
@ -2010,6 +2015,14 @@ unittest
|
|||
}
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
//Some CTFE-ability checks.
|
||||
static assert((){string s = "1234abc"; return parse!int(s) == 1234 && s == "abc";}());
|
||||
static assert((){string s = "-1234abc"; return parse!int(s) == -1234 && s == "abc";}());
|
||||
static assert((){string s = "1234abc"; return parse!uint(s) == 1234 && s == "abc";}());
|
||||
}
|
||||
|
||||
/// ditto
|
||||
Target parse(Target, Source)(ref Source s, uint radix)
|
||||
if (isSomeChar!(ElementType!Source) &&
|
||||
|
|
|
@ -2554,6 +2554,10 @@ unittest
|
|||
|
||||
assertThrown!FormatException(format("foo %s"));
|
||||
assertThrown!FormatException(format("foo %s", 123, 456));
|
||||
|
||||
//Test CTFE-ability of format.
|
||||
static assert(format("hel%slo%s%s%s", "world", -138, 'c', true) ==
|
||||
"helworldlo-138ctrue", "[" ~ s ~ "]");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue