Use C++14 string literal
This commit is contained in:
parent
06af1c4a73
commit
c4d73b0d7d
|
@ -251,7 +251,7 @@ void ArgumentReader::read(ArgumentVector &args)
|
||||||
++index, ++argv, argDenotation = nullptr;
|
++index, ++argv, argDenotation = nullptr;
|
||||||
break;
|
break;
|
||||||
case UnknownArgumentBehavior::Fail:
|
case UnknownArgumentBehavior::Fail:
|
||||||
throw Failure("The specified argument \"" % string(*argv) + "\" is unknown and will be ignored.");
|
throw Failure("The specified argument \""s % *argv + "\" is unknown and will be ignored."s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // if(!matchingArg)
|
} // if(!matchingArg)
|
||||||
|
@ -1123,10 +1123,10 @@ void ArgumentParser::checkConstraints(const ArgumentVector &args)
|
||||||
for(const Argument *arg : args) {
|
for(const Argument *arg : args) {
|
||||||
const auto occurrences = arg->occurrences();
|
const auto occurrences = arg->occurrences();
|
||||||
if(arg->isParentPresent() && occurrences > arg->maxOccurrences()) {
|
if(arg->isParentPresent() && occurrences > arg->maxOccurrences()) {
|
||||||
throw Failure("The argument \"" % string(arg->name()) % "\" mustn't be specified more than " % arg->maxOccurrences() + (arg->maxOccurrences() == 1 ? " time." : " times."));
|
throw Failure("The argument \""s % arg->name() % "\" mustn't be specified more than "s % arg->maxOccurrences() + (arg->maxOccurrences() == 1 ? " time."s : " times."s));
|
||||||
}
|
}
|
||||||
if(arg->isParentPresent() && occurrences < arg->minOccurrences()) {
|
if(arg->isParentPresent() && occurrences < arg->minOccurrences()) {
|
||||||
throw Failure("The argument \"" % string(arg->name()) % "\" must be specified at least " % arg->minOccurrences() + (arg->minOccurrences() == 1 ? " time." : " times."));
|
throw Failure("The argument \""s % arg->name() % "\" must be specified at least "s % arg->minOccurrences() + (arg->minOccurrences() == 1 ? " time."s : " times."s));
|
||||||
}
|
}
|
||||||
Argument *conflictingArgument = nullptr;
|
Argument *conflictingArgument = nullptr;
|
||||||
if(arg->isMainArgument()) {
|
if(arg->isMainArgument()) {
|
||||||
|
@ -1137,7 +1137,7 @@ void ArgumentParser::checkConstraints(const ArgumentVector &args)
|
||||||
conflictingArgument = arg->conflictsWithArgument();
|
conflictingArgument = arg->conflictsWithArgument();
|
||||||
}
|
}
|
||||||
if(conflictingArgument) {
|
if(conflictingArgument) {
|
||||||
throw Failure("The argument \"" % string(conflictingArgument->name()) % "\" can not be combined with \"" + arg->name() + "\".");
|
throw Failure("The argument \""s % conflictingArgument->name() % "\" can not be combined with \""s + arg->name() + "\"."s);
|
||||||
}
|
}
|
||||||
for(size_t i = 0; i != occurrences; ++i) {
|
for(size_t i = 0; i != occurrences; ++i) {
|
||||||
if(!arg->allRequiredValuesPresent(i)) {
|
if(!arg->allRequiredValuesPresent(i)) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ DateTime DateTime::fromString(const char *str)
|
||||||
} else if(c == '\0') {
|
} else if(c == '\0') {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
throw ConversionException(string("unexpected ") + c);
|
throw ConversionException("unexpected "s + c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return DateTime::fromDateAndTime(values[0], values[1], *dayIndex, values[3], values[4], *secondsIndex, miliSeconds);
|
return DateTime::fromDateAndTime(values[0], values[1], *dayIndex, values[3], values[4], *secondsIndex, miliSeconds);
|
||||||
|
@ -169,7 +169,7 @@ std::pair<DateTime, TimeSpan> DateTime::fromIsoString(const char *str)
|
||||||
} else if(c == '\0') {
|
} else if(c == '\0') {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
throw ConversionException(string("unexpected \"") % c + '\"');
|
throw ConversionException("unexpected \""s % c + '\"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deltaNegative && (*deltaHourIndex = -*deltaHourIndex);
|
deltaNegative && (*deltaHourIndex = -*deltaHourIndex);
|
||||||
|
|
|
@ -185,11 +185,12 @@ void ArgumentParserTests::testParsing()
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
cerr.rdbuf(regularCerrBuffer);
|
cerr.rdbuf(regularCerrBuffer);
|
||||||
CPPUNIT_ASSERT(!strcmp(buffer.str().data(), "The specified argument \"album\" is unknown and will be ignored.\n"
|
CPPUNIT_ASSERT_EQUAL("The specified argument \"album\" is unknown and will be ignored.\n"s
|
||||||
"The specified argument \"title\" is unknown and will be ignored.\n"
|
"The specified argument \"title\" is unknown and will be ignored.\n"s
|
||||||
"The specified argument \"diskpos\" is unknown and will be ignored.\n"
|
"The specified argument \"diskpos\" is unknown and will be ignored.\n"s
|
||||||
"The specified argument \"--files\" is unknown and will be ignored.\n"
|
"The specified argument \"--files\" is unknown and will be ignored.\n"s
|
||||||
"The specified argument \"somefile\" is unknown and will be ignored.\n"));
|
"The specified argument \"somefile\" is unknown and will be ignored.\n"s,
|
||||||
|
buffer.str());
|
||||||
// none of the arguments should be present now
|
// none of the arguments should be present now
|
||||||
CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
|
CPPUNIT_ASSERT(!qtConfigArgs.qtWidgetsGuiArg().isPresent());
|
||||||
CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
|
CPPUNIT_ASSERT(!displayFileInfoArg.isPresent());
|
||||||
|
@ -422,7 +423,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.read();
|
reader.read();
|
||||||
parser.printBashCompletion(1, argv1, 0, reader);
|
parser.printBashCompletion(1, argv1, 0, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=()\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=()\n"s, buffer.str());
|
||||||
|
|
||||||
// correct operation arg flags
|
// correct operation arg flags
|
||||||
buffer.str(string());
|
buffer.str(string());
|
||||||
|
@ -431,7 +432,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv1, argv1 + 1).read();
|
reader.reset(argv1, argv1 + 1).read();
|
||||||
parser.printBashCompletion(1, argv1, 0, reader);
|
parser.printBashCompletion(1, argv1, 0, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('set' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('set' )\n"s, buffer.str());
|
||||||
|
|
||||||
// argument at current cursor position already specified -> the completion should just return the argument
|
// argument at current cursor position already specified -> the completion should just return the argument
|
||||||
const char *const argv2[] = {"set"};
|
const char *const argv2[] = {"set"};
|
||||||
|
@ -441,7 +442,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv2, argv2 + 1).read();
|
reader.reset(argv2, argv2 + 1).read();
|
||||||
parser.printBashCompletion(1, argv2, 0, reader);
|
parser.printBashCompletion(1, argv2, 0, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('set' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('set' )\n"s, buffer.str());
|
||||||
|
|
||||||
// advance the cursor position -> the completion should propose the next argument
|
// advance the cursor position -> the completion should propose the next argument
|
||||||
buffer.str(string());
|
buffer.str(string());
|
||||||
|
@ -450,7 +451,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv2, argv2 + 1).read();
|
reader.reset(argv2, argv2 + 1).read();
|
||||||
parser.printBashCompletion(1, argv2, 1, reader);
|
parser.printBashCompletion(1, argv2, 1, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('--files' '--values' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('--files' '--values' )\n"s, buffer.str());
|
||||||
|
|
||||||
// specifying no args should propose all main arguments
|
// specifying no args should propose all main arguments
|
||||||
buffer.str(string());
|
buffer.str(string());
|
||||||
|
@ -459,7 +460,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(nullptr, nullptr).read();
|
reader.reset(nullptr, nullptr).read();
|
||||||
parser.printBashCompletion(0, nullptr, 0, reader);
|
parser.printBashCompletion(0, nullptr, 0, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('display-file-info' 'get' 'set' '--help' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('display-file-info' 'get' 'set' '--help' )\n"s, buffer.str());
|
||||||
|
|
||||||
// pre-defined values
|
// pre-defined values
|
||||||
const char *const argv3[] = {"get", "--fields"};
|
const char *const argv3[] = {"get", "--fields"};
|
||||||
|
@ -469,7 +470,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv3, argv3 + 2).read();
|
reader.reset(argv3, argv3 + 2).read();
|
||||||
parser.printBashCompletion(2, argv3, 2, reader);
|
parser.printBashCompletion(2, argv3, 2, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('title' 'album' 'artist' 'trackpos' '--files' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('title' 'album' 'artist' 'trackpos' '--files' )\n"s, buffer.str());
|
||||||
|
|
||||||
// pre-defined values with equation sign, one letter already present
|
// pre-defined values with equation sign, one letter already present
|
||||||
const char *const argv4[] = {"set", "--values", "a"};
|
const char *const argv4[] = {"set", "--values", "a"};
|
||||||
|
@ -479,7 +480,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv4, argv4 + 3).read();
|
reader.reset(argv4, argv4 + 3).read();
|
||||||
parser.printBashCompletion(3, argv4, 2, reader);
|
parser.printBashCompletion(3, argv4, 2, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('album=' 'artist=' ); compopt -o nospace\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('album=' 'artist=' ); compopt -o nospace\n"s, buffer.str());
|
||||||
|
|
||||||
// file names
|
// file names
|
||||||
string iniFilePath = TestUtilities::testFilePath("test.ini");
|
string iniFilePath = TestUtilities::testFilePath("test.ini");
|
||||||
|
@ -510,7 +511,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv6, argv6 + 2).read();
|
reader.reset(argv6, argv6 + 2).read();
|
||||||
parser.printBashCompletion(2, argv6, 1, reader);
|
parser.printBashCompletion(2, argv6, 1, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('--files' '--values' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('--files' '--values' )\n"s, buffer.str());
|
||||||
|
|
||||||
// nested sub arguments
|
// nested sub arguments
|
||||||
const char *const argv7[] = {"-i", "--sub", "--"};
|
const char *const argv7[] = {"-i", "--sub", "--"};
|
||||||
|
@ -520,7 +521,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv7, argv7 + 3).read();
|
reader.reset(argv7, argv7 + 3).read();
|
||||||
parser.printBashCompletion(3, argv7, 2, reader);
|
parser.printBashCompletion(3, argv7, 2, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('--files' '--nested-sub' '--verbose' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('--files' '--nested-sub' '--verbose' )\n"s, buffer.str());
|
||||||
|
|
||||||
// started pre-defined values with equation sign, one letter already present, last value matches
|
// started pre-defined values with equation sign, one letter already present, last value matches
|
||||||
const char *const argv8[] = {"set", "--values", "t"};
|
const char *const argv8[] = {"set", "--values", "t"};
|
||||||
|
@ -530,7 +531,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv8, argv8 + 3).read();
|
reader.reset(argv8, argv8 + 3).read();
|
||||||
parser.printBashCompletion(3, argv8, 2, reader);
|
parser.printBashCompletion(3, argv8, 2, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('title=' 'trackpos=' ); compopt -o nospace\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('title=' 'trackpos=' ); compopt -o nospace\n"s, buffer.str());
|
||||||
|
|
||||||
// combined abbreviations
|
// combined abbreviations
|
||||||
const char *const argv9[] = {"-gf"};
|
const char *const argv9[] = {"-gf"};
|
||||||
|
@ -540,7 +541,7 @@ void ArgumentParserTests::testBashCompletion()
|
||||||
reader.reset(argv9, argv9 + 1).read();
|
reader.reset(argv9, argv9 + 1).read();
|
||||||
parser.printBashCompletion(1, argv9, 0, reader);
|
parser.printBashCompletion(1, argv9, 0, reader);
|
||||||
cout.rdbuf(regularCoutBuffer);
|
cout.rdbuf(regularCoutBuffer);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("COMPREPLY=('-gf' )\n"), buffer.str());
|
CPPUNIT_ASSERT_EQUAL("COMPREPLY=('-gf' )\n"s, buffer.str());
|
||||||
|
|
||||||
buffer.str(string());
|
buffer.str(string());
|
||||||
cout.rdbuf(buffer.rdbuf());
|
cout.rdbuf(buffer.rdbuf());
|
||||||
|
|
|
@ -53,11 +53,11 @@ void ChronoTests::testDateTime()
|
||||||
CPPUNIT_ASSERT(test1.dayOfWeek() == DayOfWeek::Wednesday);
|
CPPUNIT_ASSERT(test1.dayOfWeek() == DayOfWeek::Wednesday);
|
||||||
CPPUNIT_ASSERT_EQUAL((31 + 29), test1.dayOfYear());
|
CPPUNIT_ASSERT_EQUAL((31 + 29), test1.dayOfYear());
|
||||||
CPPUNIT_ASSERT(test1.isLeapYear());
|
CPPUNIT_ASSERT(test1.isLeapYear());
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Wed 2012-02-29 15:34:20.033"), test1.toString(DateTimeOutputFormat::DateTimeAndShortWeekday));
|
CPPUNIT_ASSERT_EQUAL("Wed 2012-02-29 15:34:20.033"s, test1.toString(DateTimeOutputFormat::DateTimeAndShortWeekday));
|
||||||
|
|
||||||
// test fromTimeStamp()
|
// test fromTimeStamp()
|
||||||
const auto test2 = DateTime::fromTimeStampGmt(1453840331);
|
const auto test2 = DateTime::fromTimeStampGmt(1453840331);
|
||||||
CPPUNIT_ASSERT(test2.toString(DateTimeOutputFormat::DateTimeAndShortWeekday) == "Tue 2016-01-26 20:32:11");
|
CPPUNIT_ASSERT_EQUAL("Tue 2016-01-26 20:32:11"s, test2.toString(DateTimeOutputFormat::DateTimeAndShortWeekday));
|
||||||
|
|
||||||
// test whether ConversionException() is thrown when invalid values are specified
|
// test whether ConversionException() is thrown when invalid values are specified
|
||||||
CPPUNIT_ASSERT_THROW(DateTime::fromDateAndTime(2013, 2, 29, 15, 34, 20, 33), ConversionException);
|
CPPUNIT_ASSERT_THROW(DateTime::fromDateAndTime(2013, 2, 29, 15, 34, 20, 33), ConversionException);
|
||||||
|
@ -67,10 +67,10 @@ void ChronoTests::testDateTime()
|
||||||
|
|
||||||
// test fromString()/toString()
|
// test fromString()/toString()
|
||||||
CPPUNIT_ASSERT_EQUAL(test1, DateTime::fromString("2012-02-29 15:34:20.033"));
|
CPPUNIT_ASSERT_EQUAL(test1, DateTime::fromString("2012-02-29 15:34:20.033"));
|
||||||
CPPUNIT_ASSERT_EQUAL(string("2012-02-29 15:34:20.033"), test1.toString(DateTimeOutputFormat::DateAndTime, false));
|
CPPUNIT_ASSERT_EQUAL("2012-02-29 15:34:20.033"s, test1.toString(DateTimeOutputFormat::DateAndTime, false));
|
||||||
CPPUNIT_ASSERT_THROW(TimeSpan::fromString("2012-02-29 15:34:34:20.033"), ConversionException);
|
CPPUNIT_ASSERT_THROW(TimeSpan::fromString("2012-02-29 15:34:34:20.033"), ConversionException);
|
||||||
const auto test3 = DateTime::fromIsoString("2016-08-29T21:32:31.125+02:00");
|
const auto test3 = DateTime::fromIsoString("2016-08-29T21:32:31.125+02:00");
|
||||||
CPPUNIT_ASSERT_EQUAL(string("2016-08-29T21:32:31.125+02:00"), test3.first.toIsoString(test3.second));
|
CPPUNIT_ASSERT_EQUAL("2016-08-29T21:32:31.125+02:00"s, test3.first.toIsoString(test3.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -89,7 +89,7 @@ void ChronoTests::testTimeSpan()
|
||||||
CPPUNIT_ASSERT(test1.totalDays() > 3.0 && test1.totalDays() < 4.0);
|
CPPUNIT_ASSERT(test1.totalDays() > 3.0 && test1.totalDays() < 4.0);
|
||||||
CPPUNIT_ASSERT(test1.totalHours() > (2 * 24 + 34) && test1.totalHours() < (2 * 24 + 35));
|
CPPUNIT_ASSERT(test1.totalHours() > (2 * 24 + 34) && test1.totalHours() < (2 * 24 + 35));
|
||||||
CPPUNIT_ASSERT(test1.totalMinutes() > (2 * 24 * 60 + 34 * 60 + 53) && test1.totalHours() < (2 * 24 * 60 + 34 * 60 + 54));
|
CPPUNIT_ASSERT(test1.totalMinutes() > (2 * 24 * 60 + 34 * 60 + 53) && test1.totalHours() < (2 * 24 * 60 + 34 * 60 + 54));
|
||||||
CPPUNIT_ASSERT(test1.toString(TimeSpanOutputFormat::WithMeasures, false) == "3 d 10 h 53 min 2 s 500 ms");
|
CPPUNIT_ASSERT_EQUAL("3 d 10 h 53 min 2 s 500 ms"s, test1.toString(TimeSpanOutputFormat::WithMeasures, false));
|
||||||
|
|
||||||
// test whether ConversionException() is thrown when invalid values are specified
|
// test whether ConversionException() is thrown when invalid values are specified
|
||||||
CPPUNIT_ASSERT_THROW(TimeSpan::fromString("2:34a:53:32.5"), ConversionException);
|
CPPUNIT_ASSERT_THROW(TimeSpan::fromString("2:34a:53:32.5"), ConversionException);
|
||||||
|
|
|
@ -263,19 +263,19 @@ void ConversionTests::testStringConversions()
|
||||||
CPPUNIT_ASSERT(interpretIntegerAsString<uint32>(0x54455354) == "TEST");
|
CPPUNIT_ASSERT(interpretIntegerAsString<uint32>(0x54455354) == "TEST");
|
||||||
|
|
||||||
// splitString() / joinStrings()
|
// splitString() / joinStrings()
|
||||||
auto splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s", ",", EmptyPartsTreat::Keep), " ", false, "(", ")");
|
string splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s"s, ","s, EmptyPartsTreat::Keep), " "s, false, "("s, ")"s);
|
||||||
CPPUNIT_ASSERT(splitJoinTest == "() (a) () (ab) (ABC) (s)");
|
CPPUNIT_ASSERT_EQUAL("() (a) () (ab) (ABC) (s)"s, splitJoinTest);
|
||||||
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s", ",", EmptyPartsTreat::Keep), " ", true, "(", ")");
|
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s"s, ","s, EmptyPartsTreat::Keep), " "s, true, "("s, ")"s);
|
||||||
CPPUNIT_ASSERT(splitJoinTest == "(a) (ab) (ABC) (s)");
|
CPPUNIT_ASSERT_EQUAL("(a) (ab) (ABC) (s)"s, splitJoinTest);
|
||||||
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s", ",", EmptyPartsTreat::Omit), " ", false, "(", ")");
|
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s"s, ","s, EmptyPartsTreat::Omit), " "s, false, "("s, ")"s);
|
||||||
CPPUNIT_ASSERT(splitJoinTest == "(a) (ab) (ABC) (s)");
|
CPPUNIT_ASSERT_EQUAL("(a) (ab) (ABC) (s)"s, splitJoinTest);
|
||||||
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s", ",", EmptyPartsTreat::Merge), " ", false, "(", ")");
|
splitJoinTest = joinStrings(splitString<vector<string> >(",a,,ab,ABC,s"s, ","s, EmptyPartsTreat::Merge), " "s, false, "("s, ")"s);
|
||||||
CPPUNIT_ASSERT(splitJoinTest == "(a,ab) (ABC) (s)");
|
CPPUNIT_ASSERT_EQUAL("(a,ab) (ABC) (s)"s, splitJoinTest);
|
||||||
|
|
||||||
// findAndReplace()
|
// findAndReplace()
|
||||||
string findReplaceTest("findAndReplace()");
|
string findReplaceTest("findAndReplace()");
|
||||||
findAndReplace<string>(findReplaceTest, "And", "Or");
|
findAndReplace<string>(findReplaceTest, "And", "Or");
|
||||||
CPPUNIT_ASSERT(findReplaceTest == "findOrReplace()");
|
CPPUNIT_ASSERT_EQUAL("findOrReplace()"s, findReplaceTest);
|
||||||
|
|
||||||
// startsWith()
|
// startsWith()
|
||||||
CPPUNIT_ASSERT(!startsWith<string>(findReplaceTest, "findAnd"));
|
CPPUNIT_ASSERT(!startsWith<string>(findReplaceTest, "findAnd"));
|
||||||
|
@ -312,8 +312,8 @@ void ConversionTests::testStringBuilder()
|
||||||
CPPUNIT_ASSERT_EQUAL(string("foobarfoo2bar2"), tupleToString(string("foo") % "bar" % string("foo2") % "bar2"));
|
CPPUNIT_ASSERT_EQUAL(string("foobarfoo2bar2"), tupleToString(string("foo") % "bar" % string("foo2") % "bar2"));
|
||||||
|
|
||||||
// construction of string-tuple and final conversion to string works
|
// construction of string-tuple and final conversion to string works
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("result can be passed to any function taking a std::string", string("123456789"), functionTakingString("12" % string("34") % '5' % 67 + "89"));
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("result can be passed to any function taking a std::string"s, "123456789"s, functionTakingString("12" % string("34") % '5' % 67 + "89"));
|
||||||
constexpr double velocityExample = 27.0;
|
constexpr double velocityExample = 27.0;
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("real-word example", string("velocity: 27 km/h (7.5 m/s)"), functionTakingString("velocity: " % numberToString(velocityExample) % " km/h (" % numberToString(velocityExample / 3.6) + " m/s)"));
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("real-word example"s, "velocity: 27 km/h (7.5 m/s)"s, functionTakingString("velocity: " % numberToString(velocityExample) % " km/h (" % numberToString(velocityExample / 3.6) + " m/s)"));
|
||||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("regular + operator still works (no problems with ambiguity)", string("regular + still works"), string("regular") + " + still works");
|
CPPUNIT_ASSERT_EQUAL_MESSAGE("regular + operator still works (no problems with ambiguity)"s, "regular + still works"s, "regular"s + " + still works");
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,8 +229,8 @@ void IoTests::testBitReader()
|
||||||
*/
|
*/
|
||||||
void IoTests::testPathUtilities()
|
void IoTests::testPathUtilities()
|
||||||
{
|
{
|
||||||
CPPUNIT_ASSERT(fileName("/usr/lib/libc++utilities.so") == "libc++utilities.so");
|
CPPUNIT_ASSERT_EQUAL("libc++utilities.so"s, fileName("/usr/lib/libc++utilities.so"));
|
||||||
CPPUNIT_ASSERT(directory("/usr/lib/libc++utilities.so") == "/usr/lib/");
|
CPPUNIT_ASSERT_EQUAL("/usr/lib/"s, directory("/usr/lib/libc++utilities.so"));
|
||||||
CPPUNIT_ASSERT(directory("libc++utilities.so").empty());
|
CPPUNIT_ASSERT(directory("libc++utilities.so").empty());
|
||||||
string invalidPath("lib/c++uti*lities.so?");
|
string invalidPath("lib/c++uti*lities.so?");
|
||||||
removeInvalidChars(invalidPath);
|
removeInvalidChars(invalidPath);
|
||||||
|
|
Loading…
Reference in New Issue