diff options
author | Rime <81419447+Emirlol@users.noreply.github.com> | 2024-07-13 02:21:47 +0300 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-07-15 12:38:47 +0100 |
commit | dfe5c28dd6a50fc88973e95e60bcfd418daa1e90 (patch) | |
tree | a5280c3ca108f0990cb04ac52552c30dc8926643 /src/test/java | |
parent | e308b09fd59b014e783e2ae6022f64f3962b123f (diff) | |
download | Skyblocker-dfe5c28dd6a50fc88973e95e60bcfd418daa1e90.tar.gz Skyblocker-dfe5c28dd6a50fc88973e95e60bcfd418daa1e90.tar.bz2 Skyblocker-dfe5c28dd6a50fc88973e95e60bcfd418daa1e90.zip |
Fix regex and add tests for the regex
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java index 5d555742..11331fae 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/dwarven/CrystalsLocationManagerTest.java @@ -6,7 +6,31 @@ import org.junit.jupiter.api.Test; import de.hysky.skyblocker.utils.Constants; -public class CrystalsLocationManagerTest { +class CrystalsLocationManagerTest { + boolean matches(String text) { + return CrystalsLocationsManager.TEXT_CWORDS_PATTERN.matcher(text).find(); + } + + @Test + void testRegex() { + Assertions.assertTrue(matches("x123 y12 z123")); + Assertions.assertTrue(matches("x123, y12, z123")); + Assertions.assertTrue(matches("Player: 123 12 123")); //This and the ones below fail when specified in the same format as those above, as the regex check assumes that the message is sent somewhere in a message and that it isn't the whole message + Assertions.assertTrue(matches("Player: 123 123 123")); + Assertions.assertTrue(matches("Player: 123, 12, 123")); + Assertions.assertTrue(matches("Player: 123, 123, 123")); + Assertions.assertTrue(matches("Player: 123,12,123")); + Assertions.assertTrue(matches("Player: 123,123,123")); + + Assertions.assertFalse(matches("Player: 123 1234 123")); + Assertions.assertFalse(matches("Player: 1234 12 123")); + Assertions.assertFalse(matches("Player: 123 12 1234")); + Assertions.assertFalse(matches("Player: 12 12 123")); + Assertions.assertFalse(matches("Player: 123 1 123")); + Assertions.assertFalse(matches("Player: 123 12 12")); + Assertions.assertFalse(matches("Player: 12312123")); + Assertions.assertFalse(matches("Player: 123123123")); + } @Test void testLocationInCrystals() { |