Skip to content

Commit

Permalink
582465: A few MAT tests fail with german language / region
Browse files Browse the repository at this point in the history
Fix number formatting tests for common locales.
Needs a more general solution, but good for now.

Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=582465
Change-Id: I3eb50980d763dd46bf9241701fc6f19471f6ff9f
  • Loading branch information
ajohnson1 committed Sep 25, 2023
1 parent ac097e7 commit b803e92
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.hamcrest.number.OrderingComparison.greaterThan;
import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo;
import static org.hamcrest.text.MatchesPattern.matchesPattern;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -750,9 +751,28 @@ void checkFormat(Format f, Column c, int colIdx) throws ParseException
* approximate values outside limit range can't be
* converted to a plain number which can be printed
* without conversion.
* Note: Unicode Character 'ALMOST EQUAL TO' (U+2248)
*/
if (v < limit && v >= -limit || !s.contains("\u2248"))
assertTrue(colIdx+":"+c.getLabel()+" "+f.toString() +" " + vc + "\n" + v + "\n" + d2 + "\n" + s + "\n" + s2, s2.matches("[+-]?[0-9,]+(\\.[0-9]{1,20})?(\\s?%)?"));
{
/*
* Allow:
* plus
* minus US,GB,IN,DE,FR
* minus sign \u2212 NO
* Allow:
* comma US,GB,IN
* dot DE,FR
* non-breaking space NO
* for grouping separator.
* Allow
* dot US,GB,IN
* comma DE,FR,NO
* for decimal separator.
* Might break for obscure locales.
*/
assertThat(colIdx+":"+c.getLabel()+" "+f.toString() +" " + vc + "\n" + v + "\n" + d2 + "\n" + s + "\n" + s2, s2, matchesPattern("[+-\u2212]?[0-9,.\u00A0]+([.,][0-9]{1,20})?(\\s?%)?"));
}
}
}
}
Expand Down

0 comments on commit b803e92

Please sign in to comment.