aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/notnite/gloppers/GlobUtilTest.java
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-11-10 23:36:59 +0100
committerLinnea Gräf <nea@nea.moe>2024-11-11 10:04:15 +0100
commit65cc87b1383f37b4b423d4beb42dfe573c1ba3ea (patch)
tree4eaee5b598435f592ea861908f3350126747bf4c /src/test/java/com/notnite/gloppers/GlobUtilTest.java
parent9f6647da939f25824fcadcf26c3968be0ef6e3be (diff)
downloadgloppers-65cc87b1383f37b4b423d4beb42dfe573c1ba3ea.tar.gz
gloppers-65cc87b1383f37b4b423d4beb42dfe573c1ba3ea.tar.bz2
gloppers-65cc87b1383f37b4b423d4beb42dfe573c1ba3ea.zip
Improve performance of the glob matching
Diffstat (limited to 'src/test/java/com/notnite/gloppers/GlobUtilTest.java')
-rw-r--r--src/test/java/com/notnite/gloppers/GlobUtilTest.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/java/com/notnite/gloppers/GlobUtilTest.java b/src/test/java/com/notnite/gloppers/GlobUtilTest.java
new file mode 100644
index 0000000..064ced1
--- /dev/null
+++ b/src/test/java/com/notnite/gloppers/GlobUtilTest.java
@@ -0,0 +1,34 @@
+package com.notnite.gloppers;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class GlobUtilTest {
+ @Test
+ public void testGlobBeginning() {
+ assertTrue(GlobUtil.matchGlob("test_id", "*_id"));
+ assertTrue(GlobUtil.matchGlob("test__id", "*_id"));
+ assertFalse(GlobUtil.matchGlob("testid", "*_id"));
+ }
+
+ @Test
+ public void testRepeatedWildcards() {
+ assertTrue(GlobUtil.matchGlob("test_id", "*_*"));
+ assertTrue(GlobUtil.matchGlob("test_id", "**_*"));
+ assertTrue(GlobUtil.matchGlob("test_id", "*?_*"));
+ assertFalse(GlobUtil.matchGlob("testid", "*?_*"));
+ }
+
+ @Test
+ public void testGlobEnd() {
+ assertTrue(GlobUtil.matchGlob("test_id", "test_*"));
+ assertTrue(GlobUtil.matchGlob("test_id", "test_i?"));
+ assertFalse(GlobUtil.matchGlob("test_id", "test_?"));
+ }
+
+ @Test
+ public void testSinglePlaceholder() {
+ assertTrue(GlobUtil.matchGlob("test_id", "tes?_i?"));
+ }
+}