Skip to content
Permalink
Browse files
8264162: PickResult.toString() is missing the closing square bracket
Reviewed-by: jvos, nlisker
  • Loading branch information
kevinrushforth committed Mar 31, 2021
1 parent d80b8ad commit f3e27a08716641156668c52508ec1ddf362fcc1d
@@ -195,14 +195,15 @@ public String toString() {
.append(", point = ").append(getIntersectedPoint())
.append(", distance = ").append(getIntersectedDistance());
if (getIntersectedFace() != FACE_UNDEFINED) {
sb.append(", face = ").append(getIntersectedFace());
sb.append(", face = ").append(getIntersectedFace());
}
if (getIntersectedNormal() != null) {
sb.append(", normal = ").append(getIntersectedNormal());
sb.append(", normal = ").append(getIntersectedNormal());
}
if (getIntersectedTexCoord() != null) {
sb.append(", texCoord = ").append(getIntersectedTexCoord());
sb.append(", texCoord = ").append(getIntersectedTexCoord());
}
sb.append("]");
return sb.toString();
}
}
@@ -111,6 +111,44 @@
assertFalse(e.isStillSincePress());
}

@Test public void testToStringMatchingBrackets() {
Rectangle node = new Rectangle();
node.setTranslateX(3);
node.setTranslateY(2);
node.setTranslateZ(50);

PickResult pickRes = new PickResult(node, new Point3D(15, 25, 100), 33);

MouseEvent e = new MouseEvent(MouseEvent.MOUSE_PRESSED,
10, 20, 30, 40, MouseButton.PRIMARY, 1,
false, false, false, false,
true, false, false,
false, false, false, pickRes);

assertSame(pickRes, e.getPickResult());

// Check the String returned by MouseEvent::toString method to ensure
// that all of the square brackets are matching.
// Note that this will fail if the toString method of any of the
// components that make up the MouseEvent returns a String with
// mismatched brackets, including the source and target
// objects, the PickResult, the picked Node, or the picked Point3D.
String str = e.toString();
int bracketCount = 0;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i)) {
case '[':
++bracketCount;
break;
case ']':
--bracketCount;
assertTrue("Too many closing brackets: " + str, bracketCount >= 0);
break;
}
}
assertEquals("Too few closing brackets: " + str, 0, bracketCount);
}

@Test public void testShortConstructorWithoutPickResult() {
MouseDragEvent e = new MouseDragEvent(MouseDragEvent.MOUSE_DRAG_OVER,
10, 20, 30, 40, MouseButton.MIDDLE, 3,

1 comment on commit f3e27a0

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on f3e27a0 Mar 31, 2021

Please sign in to comment.