diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-10 23:36:59 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-11 10:04:15 +0100 |
commit | 65cc87b1383f37b4b423d4beb42dfe573c1ba3ea (patch) | |
tree | 4eaee5b598435f592ea861908f3350126747bf4c /src/test/java/com/notnite/gloppers/GlobUtilTest.java | |
parent | 9f6647da939f25824fcadcf26c3968be0ef6e3be (diff) | |
download | gloppers-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.java | 34 |
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?")); + } +} |