This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 6843a6e3395 Add more test cases on QuoteCharacterTest (#38357)
6843a6e3395 is described below

commit 6843a6e33953e464d92f847e4b9b90d794044883
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Mar 6 10:16:57 2026 +0800

    Add more test cases on QuoteCharacterTest (#38357)
    
    * Add more test cases on QuoteCharacterTest
    
    * Add more test cases on QuoteCharacterTest
    
    * Add more test cases on QuoteCharacterTest
---
 .../database/enums/QuoteCharacterTest.java         | 92 +++++++++++++++-------
 1 file changed, 62 insertions(+), 30 deletions(-)

diff --git 
a/database/connector/core/src/test/java/org/apache/shardingsphere/database/connector/core/metadata/database/enums/QuoteCharacterTest.java
 
b/database/connector/core/src/test/java/org/apache/shardingsphere/database/connector/core/metadata/database/enums/QuoteCharacterTest.java
index 04bb33ed250..3e8210450a0 100644
--- 
a/database/connector/core/src/test/java/org/apache/shardingsphere/database/connector/core/metadata/database/enums/QuoteCharacterTest.java
+++ 
b/database/connector/core/src/test/java/org/apache/shardingsphere/database/connector/core/metadata/database/enums/QuoteCharacterTest.java
@@ -18,55 +18,87 @@
 package 
org.apache.shardingsphere.database.connector.core.metadata.database.enums;
 
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
 
-import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.hamcrest.Matchers.is;
 
 class QuoteCharacterTest {
     
-    @Test
-    void assertGetQuoteCharacter() {
-        assertThat(QuoteCharacter.getQuoteCharacter(null), 
is(QuoteCharacter.NONE));
-        assertThat(QuoteCharacter.getQuoteCharacter(""), 
is(QuoteCharacter.NONE));
-        assertThat(QuoteCharacter.getQuoteCharacter("test"), 
is(QuoteCharacter.NONE));
-        assertThat(QuoteCharacter.getQuoteCharacter("`test`"), 
is(QuoteCharacter.BACK_QUOTE));
-        assertThat(QuoteCharacter.getQuoteCharacter("'test'"), 
is(QuoteCharacter.SINGLE_QUOTE));
-        assertThat(QuoteCharacter.getQuoteCharacter("\"test\""), 
is(QuoteCharacter.QUOTE));
-        assertThat(QuoteCharacter.getQuoteCharacter("[test]"), 
is(QuoteCharacter.BRACKETS));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("getQuoteCharacterArguments")
+    void assertGetQuoteCharacter(final String name, final String value, final 
QuoteCharacter expectedQuoteCharacter) {
+        assertThat(QuoteCharacter.getQuoteCharacter(value), 
is(expectedQuoteCharacter));
     }
     
     @Test
-    void assertWarp() {
+    void assertWrap() {
         assertThat(QuoteCharacter.BACK_QUOTE.wrap("test"), is("`test`"));
     }
     
-    @Test
-    void assertUnwrap() {
-        assertThat(QuoteCharacter.BACK_QUOTE.unwrap("`test`"), is("test"));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("unwrapArguments")
+    void assertUnwrap(final String name, final QuoteCharacter quoteCharacter, 
final String value, final String expectedValue) {
+        assertThat(quoteCharacter.unwrap(value), is(expectedValue));
     }
     
-    @Test
-    void assertIsWrapped() {
-        assertTrue(QuoteCharacter.SINGLE_QUOTE.isWrapped("'test'"));
-        assertFalse(QuoteCharacter.SINGLE_QUOTE.isWrapped("'test\""));
-        assertTrue(QuoteCharacter.NONE.isWrapped("test"));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("isWrappedArguments")
+    void assertIsWrapped(final String name, final QuoteCharacter 
quoteCharacter, final String value, final boolean expectedWrapped) {
+        assertThat(quoteCharacter.isWrapped(value), is(expectedWrapped));
     }
     
-    @Test
-    void assertUnwrapText() {
-        assertThat(QuoteCharacter.unwrapText("test"), is("test"));
-        assertThat(QuoteCharacter.unwrapText("`test`"), is("test"));
-        assertThat(QuoteCharacter.unwrapText("'test'"), is("test"));
-        assertThat(QuoteCharacter.unwrapText("\"test\""), is("test"));
-        assertThat(QuoteCharacter.unwrapText("[test]"), is("test"));
-        assertThat(QuoteCharacter.unwrapText("(test)"), is("test"));
-        assertThat(QuoteCharacter.unwrapText("{test}"), is("{test}"));
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("unwrapTextArguments")
+    void assertUnwrapText(final String name, final String text, final String 
expectedText) {
+        assertThat(QuoteCharacter.unwrapText(text), is(expectedText));
     }
     
     @Test
     void assertUnwrapAndTrimText() {
         assertThat(QuoteCharacter.unwrapAndTrimText("` test `"), is("test"));
     }
+    
+    private static Stream<Arguments> getQuoteCharacterArguments() {
+        return Stream.of(
+                Arguments.of("null value", null, QuoteCharacter.NONE),
+                Arguments.of("empty value", "", QuoteCharacter.NONE),
+                Arguments.of("plain value", "test", QuoteCharacter.NONE),
+                Arguments.of("back quote value", "`test`", 
QuoteCharacter.BACK_QUOTE),
+                Arguments.of("single quote value", "'test'", 
QuoteCharacter.SINGLE_QUOTE),
+                Arguments.of("double quote value", "\"test\"", 
QuoteCharacter.QUOTE),
+                Arguments.of("brackets value", "[test]", 
QuoteCharacter.BRACKETS),
+                Arguments.of("parentheses value", "(test)", 
QuoteCharacter.PARENTHESES));
+    }
+    
+    private static Stream<Arguments> unwrapArguments() {
+        return Stream.of(
+                Arguments.of("wrapped by back quote", 
QuoteCharacter.BACK_QUOTE, "`test`", "test"),
+                Arguments.of("start delimiter mismatch", 
QuoteCharacter.BACK_QUOTE, "test", "test"),
+                Arguments.of("end delimiter mismatch", 
QuoteCharacter.BACK_QUOTE, "`test'", "`test'"));
+    }
+    
+    private static Stream<Arguments> isWrappedArguments() {
+        return Stream.of(
+                Arguments.of("start delimiter mismatch", 
QuoteCharacter.SINGLE_QUOTE, "test'", false),
+                Arguments.of("end delimiter mismatch", 
QuoteCharacter.SINGLE_QUOTE, "'test\"", false),
+                Arguments.of("fully wrapped by single quote", 
QuoteCharacter.SINGLE_QUOTE, "'test'", true),
+                Arguments.of("none quote character", QuoteCharacter.NONE, 
"test", true));
+    }
+    
+    private static Stream<Arguments> unwrapTextArguments() {
+        return Stream.of(
+                Arguments.of("plain text", "test", "test"),
+                Arguments.of("back quote text", "`test`", "test"),
+                Arguments.of("single quote text", "'test'", "test"),
+                Arguments.of("double quote text", "\"test\"", "test"),
+                Arguments.of("brackets text", "[test]", "test"),
+                Arguments.of("parentheses text", "(test)", "test"),
+                Arguments.of("unrecognized wrapper text", "{test}", "{test}"),
+                Arguments.of("unmatched back quote text", "`test'", "`test'"));
+    }
 }

Reply via email to