mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-31 06:35:03 +01:00
PatternFormatter fix, added test
This commit is contained in:
parent
fafe691a04
commit
ec71e76f0a
@ -256,13 +256,18 @@ void PatternFormatter::parsePriorityNames()
|
||||
{
|
||||
_priorities[i] = priorities[i];
|
||||
}
|
||||
StringTokenizer st(_priorityNames, ",;", StringTokenizer::TOK_TRIM);
|
||||
if (st.count() == 8)
|
||||
if (!_priorityNames.empty())
|
||||
{
|
||||
for (int i = 1; i <= 8; i++)
|
||||
_priorities[i] = st[i - 1];
|
||||
StringTokenizer st(_priorityNames, ",;", StringTokenizer::TOK_TRIM);
|
||||
if (st.count() == 8)
|
||||
{
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
_priorities[i] = st[i - 1];
|
||||
}
|
||||
}
|
||||
else throw Poco::SyntaxException("priorityNames property must specify a comma-separated list of 8 property names");
|
||||
}
|
||||
else throw Poco::SyntaxException("priorityNames property must specify a comma-separated list of 8 property names");
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,6 +93,21 @@ void PatternFormatterTest::testPatternFormatter()
|
||||
fmt.setProperty("pattern", "start %v[8] end");
|
||||
fmt.format(msg, result);
|
||||
assert (result == "start stSource end");
|
||||
|
||||
result.clear();
|
||||
fmt.setProperty("pattern", "%p");
|
||||
fmt.setProperty("priorityNames", "FAT, CRI, ERR, WRN, NTC, INF, DBG, TRC");
|
||||
fmt.format(msg, result);
|
||||
assert (result == "ERR");
|
||||
|
||||
try
|
||||
{
|
||||
fmt.setProperty("priorityNames", "FAT, CRI,");
|
||||
fail("invalid value, must throw");
|
||||
}
|
||||
catch (Poco::SyntaxException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user