From 65cc87b1383f37b4b423d4beb42dfe573c1ba3ea Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 10 Nov 2024 23:36:59 +0100 Subject: Improve performance of the glob matching --- .../java/com/notnite/gloppers/GlobUtilTest.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/com/notnite/gloppers/GlobUtilTest.java (limited to 'src/test/java') 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?")); + } +} -- cgit