From 2c23391de76be0994d8367fdfba63a98e9faa63d Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Fri, 20 Oct 2023 11:02:58 +0000 Subject: [PATCH] 8318101: Additional test cases for CSSAttributeEqualityBug Reviewed-by: prr --- .../html/CSS/CSSAttributeEqualityBug.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/jdk/javax/swing/text/html/CSS/CSSAttributeEqualityBug.java b/test/jdk/javax/swing/text/html/CSS/CSSAttributeEqualityBug.java index 7968f773bd5..304f1e83542 100644 --- a/test/jdk/javax/swing/text/html/CSS/CSSAttributeEqualityBug.java +++ b/test/jdk/javax/swing/text/html/CSS/CSSAttributeEqualityBug.java @@ -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 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 { } } -