8318101: Additional test cases for CSSAttributeEqualityBug

Reviewed-by: prr
This commit is contained in:
Alexey Ivanov 2023-10-20 11:02:58 +00:00
parent deadb9c8d7
commit 2c23391de7

View File

@ -70,6 +70,8 @@ public class CSSAttributeEqualityBug {
"background-position: 0 0",
"background-position: 1cm 2cm",
"background-position: 1em 2em",
"border-width: medium",
};
/**
@ -86,6 +88,14 @@ public class CSSAttributeEqualityBug {
{"margin-top: 100%", "margin-top: 50%"},
};
private static final String[][] EQUALS_WITH_SPACE = {
{"font-size: 42px", "font-size: 42 px"},
{"font-size: 100%", "font-size: 100 %"},
{"width: 42px", "width: 42 px"},
{"width: 100%", "width: 100 %"},
};
public static void main(String[] args) {
final List<String> failures = new ArrayList<>();
@ -97,10 +107,14 @@ public class CSSAttributeEqualityBug {
.map(CSSAttributeEqualityBug::negativeTest)
.filter(Objects::nonNull)
.forEach(failures::add);
Arrays.stream(EQUALS_WITH_SPACE)
.map(CSSAttributeEqualityBug::positiveTest)
.filter(Objects::nonNull)
.forEach(failures::add);
if (!failures.isEmpty()) {
failures.forEach(System.err::println);
throw new RuntimeException(failures.size()
throw new RuntimeException("The test failed: " + failures.size()
+ " failure(s) detected: "
+ failures.get(0));
}
@ -115,6 +129,15 @@ public class CSSAttributeEqualityBug {
return assertEquals(a, b);
}
private static String positiveTest(String[] cssDeclaration) {
StyleSheet ss = new StyleSheet();
AttributeSet a = ss.getDeclaration(cssDeclaration[0]);
AttributeSet b = ss.getDeclaration(cssDeclaration[1]);
return assertEquals(a, b);
}
private static String negativeTest(String[] cssDeclaration) {
StyleSheet ss = new StyleSheet();
@ -145,4 +168,3 @@ public class CSSAttributeEqualityBug {
}
}