On Friday, February 20, 2015 at 12:57:44 PM UTC+1, Ted Mielczarek wrote: > On Thu, Feb 19, 2015, at 06:32 AM, a...@mozilla.com wrote: > > On Tuesday, February 17, 2015 at 6:33:42 PM UTC+1, Ted Mielczarek wrote: > > > On Tue, Feb 17, 2015, at 10:27 AM, Axel Hecht wrote: > > > > Hi, > > > > > > > > I'd like to write tests to validate my assumptions around what's an > > > > error > > > > and what's a warning for localized values going into > > > > nsTextFormatter::smprintf. > > > > > > > > Basically, the tests would start with a reference string, and then a > > > > more > > > > or less random modification of that string, and a check if the segments > > > > are in, or if it crashes [1]. > > > > > > > > So I'll need a .cpp core, and a wrapper that feeds it data and checks > > > > the > > > > output. > > > > > > > > Any suggestions on how to do that "right"? > > > > > > When you say "crashes" do you mean an actual program crash? If so, > > > shouldn't we just be fixing these in nsTextFormatter? If you don't need > > > to monitor actual crashes then a Gtest should work just fine here. > > > > > > -Ted > > > > I'm talking actual crashes, and I don't know how we would fix the text > > formatter. I'm glancing at > > http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTextFormatter.cpp#778, > > and I had no idea how to fix the C++ API there. > > > > bug 1133554#c2 is a bug where we got it wrong in en-US, too. Doesn't > > crash, but produces undesirable results. > > > > Note, folks using the stringbundle.formatStringFromName just use a > > wstring array. The only code paths affected are those that get the > > string, and explicitly call into nsTextFormatter from c++. > > Can you provide an example of a call that crashes? I still feel like the > right outcome here is to make the code not crash. > > -Ted
I just tweaked the test: diff --git a/xpcom/tests/TestTextFormatter.cpp b/xpcom/tests/TestTextFormatter.cpp --- a/xpcom/tests/TestTextFormatter.cpp +++ b/xpcom/tests/TestTextFormatter.cpp @@ -11,7 +11,7 @@ { int test_ok = true; - nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$d %2$d %2$d %3$s")); + nsAutoString fmt(NS_LITERAL_STRING("%3$s %4$S %1$f %2$d %2$d %3$s")); char utf8[] = "Hello"; char16_t ucs2[]={'W', 'o', 'r', 'l', 'd', 0x4e00, 0xAc00, 0xFF45, 0x0103, 0x00}; int d=3; And then you get ../../dist/bin/TestTextFormatter Segmentation fault: 11 _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform