-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Transform: fix toString() method #2526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2022 jMonkeyEngine | ||
| * Copyright (c) 2009-2025 jMonkeyEngine | ||
| * All rights reserved. | ||
| * | ||
| * Redistribution and use in source and binary forms, with or without | ||
|
|
@@ -59,15 +59,31 @@ public void testTransformToString() { | |
| * Verify that the result matches the javadoc | ||
| * and can be parsed using a regular expression. | ||
| */ | ||
| // --- Regex for matching the generated string --- | ||
| // Use \\R for platform-independent newline | ||
| Pattern pattern = Pattern.compile( | ||
| "^Transform\\[ (\\S+), (\\S+), (\\S+)\\]\\n" | ||
| + "\\[ (\\S+), (\\S+), (\\S+), (\\S+)\\]\\n" | ||
| + "\\[ (\\S+) , (\\S+), (\\S+)\\]$" | ||
| "^Transform\\[(\\S+), (\\S+), (\\S+)\\]\\R" | ||
| + "\\[(\\S+), (\\S+), (\\S+), (\\S+)\\]\\R" | ||
| + "\\[(\\S+), (\\S+), (\\S+)\\]$" | ||
| ); | ||
|
|
||
| Matcher matcher = pattern.matcher(result); | ||
| boolean valid = matcher.matches(); | ||
| Assert.assertTrue(valid); | ||
|
|
||
| // if (valid) { | ||
| // System.out.println("Group 1 (Translation X): " + matcher.group(1)); | ||
| // System.out.println("Group 2 (Translation Y): " + matcher.group(2)); | ||
| // System.out.println("Group 3 (Translation Z): " + matcher.group(3)); | ||
| // System.out.println("Group 4 (Rotation X): " + matcher.group(4)); | ||
| // System.out.println("Group 5 (Rotation Y): " + matcher.group(5)); | ||
| // System.out.println("Group 6 (Rotation Z): " + matcher.group(6)); | ||
| // System.out.println("Group 7 (Rotation W): " + matcher.group(7)); | ||
| // System.out.println("Group 8 (Scale X): " + matcher.group(8)); | ||
| // System.out.println("Group 9 (Scale Y): " + matcher.group(9)); | ||
| // System.out.println("Group 10 (Scale Z): " + matcher.group(10)); | ||
| // } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to commit this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I left them on purpose. The legend of the indices of the "groups" makes the test easier to understand; otherwise, it is difficult to understand the choice of those used later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how they help with that. They seem like bits of commented out code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have replaced the bits of code with clearer comments. I hope you feel more confident now. |
||
| String txText = matcher.group(1); | ||
| float tx = Float.parseFloat(txText); | ||
| Assert.assertEquals(12f, tx, 1e-5f); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.