forked from HowardHinnant/date
Tweak white space parsing rules (again):
* White space matches zero or more white space characters. * %n matches one white space character. * %t matches zero or one white space characters.
This commit is contained in:
@@ -740,6 +740,81 @@ test_leading_ws()
|
||||
assert(d2 == may/4/2017);
|
||||
}
|
||||
|
||||
void
|
||||
test_space()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse(" %D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_n()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%n%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_t()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace date;
|
||||
{
|
||||
istringstream in{"05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(d1 == may/4/2017);
|
||||
}
|
||||
{
|
||||
istringstream in{" 05/04/17"};
|
||||
year_month_day d1;
|
||||
in >> parse("%t%D", d1);
|
||||
assert(in.fail());
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -769,4 +844,7 @@ main()
|
||||
test_Z();
|
||||
test_trailing_Z();
|
||||
test_leading_ws();
|
||||
test_space();
|
||||
test_n();
|
||||
test_t();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user