presentation
Andreas Butti 7 years ago
commit db16fe8189
  1. 48
      src/util/PlaceholderString.cpp
  2. 9
      test/util/I18nTest.cpp

@ -142,51 +142,45 @@ void PlaceholderString::process()
{
char c = text.at(i);
if (closeBacket && c == '}')
{
if (c == '{') {
closeBacket = false;
processed += '}';
continue;
}
if (c == '{' && openBracket && formatString.length() == 0)
{
openBracket = false;
processed += '{';
continue;
}
if (c == '}' && openBracket)
{
closeBacket = true;
processed += formatPart(formatString);
openBracket = false;
formatString = "";
if (openBracket)
{
openBracket = false;
processed += '{';
continue;
}
openBracket = true;
continue;
}
if (c == '}')
{
if (closeBacket)
{
processed += '}';
closeBacket = false;
continue;
}
closeBacket = true;
if (openBracket)
{
processed += formatPart(formatString);
openBracket = false;
formatString = "";
}
continue;
}
if (openBracket)
{
formatString += c;
continue;
}
if (c == '{')
{
openBracket = true;
continue;
}
closeBacket = false;
processed += c;
}
}

@ -28,6 +28,7 @@ class I18nTest : public CppUnit::TestFixture
CPPUNIT_TEST(testMissing);
CPPUNIT_TEST(testOrder);
CPPUNIT_TEST(testLatexString);
CPPUNIT_TEST(test3);
CPPUNIT_TEST_SUITE_END();
@ -80,6 +81,14 @@ public:
string command = FS(FORMAT_STR("{1} -m 0 \"\\png\\usepackage{{color}}\\color{{{2}}}\\dpi{{{3}}}\\normalsize {4}\" -o {5}") % "abc" % "red" % 45 % "asdf" % "asdf.png");
CPPUNIT_ASSERT_EQUAL(std::string("abc -m 0 \"\\png\\usepackage{color}\\color{red}\\dpi{45}\\normalsize asdf\" -o asdf.png"), command);
}
void test3()
{
string msg = FS(FORMAT_STR(" of {1}{2}") % 5 % 6);
CPPUNIT_ASSERT_EQUAL(std::string(" of 56"), msg);
}
};
// Registers the fixture into the 'registry'

Loading…
Cancel
Save