-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3860 from emmebi/develop
Fixes #3259
- Loading branch information
Showing
5 changed files
with
140 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/resources/net/rptools/maptool/client/functions/linkDataCases.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
caseName,macro,link,data | ||
no slashes in macro name,macro://jukebox_playAllClient@lib:bizland5e/all/Impersonated?281_Escape_from_Shadow.mp3,macro://jukebox_playAllClient@lib:bizland5e/all/Impersonated?,281_Escape_from_Shadow.mp3 | ||
slashes in macro name,macro://jukebox/playAllClient@lib:bizland5e/all/Impersonated?281_Escape_from_Shadow.mp3,macro://jukebox/playAllClient@lib:bizland5e/all/Impersonated?,281_Escape_from_Shadow.mp3 | ||
spaces before the protocol, macro://macroName@lib:token/all/Impersonated?val,macro://macroName@lib:token/all/Impersonated?,val | ||
minimal match,:////?,:////?,"" |
5 changes: 5 additions & 0 deletions
5
src/main/resources/net/rptools/maptool/client/functions/macroURLCases.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
caseName,macroLink,protocol,macroName,who,targets,val | ||
no slashes in macro name,macro://jukebox_playAllClient@lib:bizland5e/all/Impersonated?281_Escape_from_Shadow.mp3,macro,jukebox_playAllClient@lib:bizland5e,all,Impersonated,281_Escape_from_Shadow.mp3 | ||
slashes in macro name,macro://jukebox/playAllClient@lib:bizland5e/all/Impersonated?281_Escape_from_Shadow.mp3,macro,jukebox/playAllClient@lib:bizland5e,all,Impersonated,281_Escape_from_Shadow.mp3 | ||
spaces before the protocol, macro://macroName@lib:token/all/Impersonated?val,macro,macroName@lib:token,all,Impersonated,val | ||
minimal match,:////,"","","","", |
112 changes: 112 additions & 0 deletions
112
src/test/java/net/rptools/maptool/client/functions/MacroLinkFunctionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* This software Copyright by the RPTools.net development team, and | ||
* licensed under the Affero GPL Version 3 or, at your option, any later | ||
* version. | ||
* | ||
* MapTool Source Code is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License * along with this source Code. If not, please visit | ||
* <http://www.gnu.org/licenses/> and specifically the Affero license | ||
* text at <http://www.gnu.org/licenses/agpl.html>. | ||
*/ | ||
package net.rptools.maptool.client.functions; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvFileSource; | ||
|
||
class MacroLinkFunctionTest { | ||
|
||
@ParameterizedTest(name = "{index} - {0} is properly parsed") | ||
@CsvFileSource( | ||
resources = "/net/rptools/maptool/client/functions/macroURLCases.csv", | ||
numLinesToSkip = 1) | ||
void testMacroLinkPattern( | ||
String caseName, | ||
String macroLink, | ||
String protocol, | ||
String macroName, | ||
String who, | ||
String target, | ||
String val) { | ||
Pattern macroLinkPattern = MacroLinkFunction.MACROLINK_PATTERN; | ||
|
||
Matcher matcher = macroLinkPattern.matcher(macroLink); | ||
|
||
assertTrue(matcher.matches()); | ||
assertEquals(protocol, matcher.group(1)); | ||
assertEquals(macroName, matcher.group(2)); | ||
assertEquals(who, matcher.group(3)); | ||
assertEquals(target, matcher.group(4)); | ||
assertEquals(val, matcher.group(5)); | ||
} | ||
|
||
@ParameterizedTest(name = "{index} - {0} is properly parsed") | ||
@CsvFileSource( | ||
resources = "/net/rptools/maptool/client/functions/macroURLCases.csv", | ||
numLinesToSkip = 1) | ||
void testAutoExecPattern( | ||
String caseName, | ||
String macroLink, | ||
String protocol, | ||
String macroName, | ||
String who, | ||
String target, | ||
String val) { | ||
Pattern autoexecPattern = MacroLinkFunction.AUTOEXEC_PATTERN; | ||
|
||
Matcher matcher = autoexecPattern.matcher(macroLink); | ||
|
||
assertTrue(matcher.matches()); | ||
assertEquals(protocol, matcher.group(1)); | ||
assertEquals(macroName, matcher.group(2)); | ||
assertEquals(who, matcher.group(3)); | ||
assertEquals(target, matcher.group(4)); | ||
assertEquals(val, matcher.group(5)); | ||
} | ||
|
||
@ParameterizedTest(name = "{index} - {0} is properly parsed") | ||
@CsvFileSource( | ||
resources = "/net/rptools/maptool/client/functions/macroURLCases.csv", | ||
numLinesToSkip = 1) | ||
void testTooltipPattern( | ||
String caseName, | ||
String macroLink, | ||
String protocol, | ||
String macroName, | ||
String who, | ||
String target, | ||
String val) { | ||
Pattern tooltipPattern = MacroLinkFunction.TOOLTIP_PATTERN; | ||
|
||
Matcher matcher = tooltipPattern.matcher(macroLink); | ||
|
||
assertTrue(matcher.matches()); | ||
assertEquals(protocol, matcher.group(1)); | ||
assertEquals(macroName, matcher.group(2)); | ||
assertEquals(who, matcher.group(3)); | ||
assertEquals(target, matcher.group(4)); | ||
assertEquals(val, matcher.group(5)); | ||
} | ||
|
||
@ParameterizedTest(name = "{index} - {0} is properly parsed") | ||
@CsvFileSource( | ||
resources = "/net/rptools/maptool/client/functions/linkDataCases.csv", | ||
numLinesToSkip = 1) | ||
void testLinkDataPattern(String caseName, String macro, String macroLink, String macroData) { | ||
Pattern linkDataPattern = MacroLinkFunction.LINK_DATA_PATTERN; | ||
|
||
Matcher matcher = linkDataPattern.matcher(macro); | ||
|
||
assertTrue(matcher.matches()); | ||
assertEquals(macroLink, matcher.group(1)); | ||
assertEquals(macroData, matcher.group(2)); | ||
} | ||
} |