Skip to content

Commit

Permalink
fix test cases for narrative generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Feb 27, 2025
1 parent dd4743e commit 955d942
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ private void checkDateTimeRendering(String src, String lang, String country, Zon
DateTimeType dt = new DateTimeType(src);
String actual = new DataRenderer(rc).displayDataType(ResourceWrapper.forType(rc.getContextUtilities(), dt));

Assert.assertTrue("Actual = "+actual+", expected one of "+Utilities.toString(expected), Utilities.existsInList(Utilities.normalize(actual), expected));
Assert.assertTrue("Actual = "+actual+", expected one of "+Utilities.toString(expected), Utilities.existsInList(Utilities.normalize(actual, false), expected));
XhtmlNode node = new XhtmlNode(NodeType.Element, "p");
new DataRenderer(rc).renderDataType(new RenderingStatus(), node, ResourceWrapper.forType(rc.getContextUtilities(), dt));
actual = new XhtmlComposer(true, false).compose(node);
Assert.assertTrue(actual.startsWith("<p>"));
Assert.assertTrue(actual.endsWith("</p>"));
Assert.assertTrue("Actual = "+actual+", expected one of "+Utilities.toString(expected), Utilities.existsInList(Utilities.normalize(actual.substring(0, actual.length()-4)).substring(3), expected));
Assert.assertTrue("Actual = "+actual+", expected one of "+Utilities.toString(expected), Utilities.existsInList(Utilities.normalize(actual.substring(0, actual.length()-4), false).substring(3), expected));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,14 +718,17 @@ public static String encodeUriParam(String param) {
}

public static String normalize(String s) {
return normalize(s, true);
}
public static String normalize(String s, boolean lower) {
if (noString(s))
return null;
StringBuilder b = new StringBuilder();
boolean isWhitespace = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (!isWhitespace(c)) {
b.append(Character.toLowerCase(c));
b.append(lower ? Character.toLowerCase(c) : c);
isWhitespace = false;
} else if (!isWhitespace) {
if (c == '\r' || c == '\n') {
Expand Down

0 comments on commit 955d942

Please sign in to comment.