From 5e325b27590920f1abcb0a6fbe8d037e1131b9df Mon Sep 17 00:00:00 2001
From: olim <bobq4582@gmail.com>
Date: Thu, 15 Feb 2024 21:04:47 +0000
Subject: add test for isMach

create test for most parts of the isMatch check
---
 .../skyblocker/skyblock/chat/ChatRuleTest.java     | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java

diff --git a/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java
new file mode 100644
index 00000000..0c98debe
--- /dev/null
+++ b/src/test/java/de/hysky/skyblocker/skyblock/chat/ChatRuleTest.java
@@ -0,0 +1,37 @@
+package de.hysky.skyblocker.skyblock.chat;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class ChatRuleTest {
+
+    @Test
+    void isMatch() {
+        ChatRule testRule = new ChatRule();
+        //test enabled check
+        testRule.setFilter("test");
+        testRule.setEnabled(false);
+        Assertions.assertEquals(testRule.isMatch("test"),false);
+        //test simple filter works
+        testRule.setEnabled(true);
+        Assertions.assertEquals(testRule.isMatch("test"),true);
+        //test partial match works
+        Assertions.assertEquals(testRule.isMatch("test extra"),false);
+        testRule.setPartialMatch(true);
+        Assertions.assertEquals(testRule.isMatch("test extra"),true);
+        //test ignore case works
+        Assertions.assertEquals(testRule.isMatch("TEST"),true);
+        testRule.setIgnoreCase(false);
+        Assertions.assertEquals(testRule.isMatch("TEST"),false);
+
+        //test regex
+        testRule = new ChatRule();
+        testRule.setRegex(true);
+        testRule.setFilter("[0-9]+");
+        Assertions.assertEquals(testRule.isMatch("1234567"),true);
+        Assertions.assertEquals(testRule.isMatch("1234567 test"),false);
+
+    }
+}
\ No newline at end of file
-- 
cgit