-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sean Kao <[email protected]>
- Loading branch information
1 parent
8ed8255
commit 07250e7
Showing
3 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
ppl-spark-integration/src/test/java/org/opensearch/sql/common/utils/StringUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.opensearch.sql.common.utils; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.opensearch.sql.common.utils.StringUtils.unquoteIdentifier; | ||
import static org.opensearch.sql.common.utils.StringUtils.unquoteText; | ||
|
||
import org.junit.Test; | ||
|
||
public class StringUtilsTest { | ||
@Test | ||
public void unquoteIdentifierTest() { | ||
assertEquals("test", unquoteIdentifier("test")); | ||
assertEquals("test", unquoteIdentifier("`test`")); | ||
|
||
assertEquals("\"test\"", unquoteIdentifier("\"test\"")); | ||
assertEquals("\'test\'", unquoteIdentifier("\'test\'")); | ||
} | ||
|
||
@Test | ||
public void unquoteTextTest() { | ||
assertEquals("test", unquoteText("test")); | ||
assertEquals("test", unquoteText("'test'")); | ||
|
||
assertEquals("test'", unquoteText("'test'''")); | ||
assertEquals("test\"", unquoteText("\"test\"\"\"")); | ||
|
||
assertEquals("te``st", unquoteText("'te``st'")); | ||
assertEquals("te``st", unquoteText("\"te``st\"")); | ||
|
||
assertEquals("te'st", unquoteText("'te''st'")); | ||
assertEquals("te''st", unquoteText("\"te''st\"")); | ||
|
||
assertEquals("te\"\"st", unquoteText("'te\"\"st'")); | ||
assertEquals("te\"st", unquoteText("\"te\"\"st\"")); | ||
|
||
assertEquals("''", unquoteText("''''''")); | ||
assertEquals("\"\"", unquoteText("\"\"\"\"\"\"")); | ||
|
||
assertEquals("test'", unquoteText("'test''")); | ||
|
||
assertEquals("", unquoteText("")); | ||
assertEquals("'", unquoteText("'")); | ||
assertEquals("\"", unquoteText("\"")); | ||
|
||
assertEquals("hello'", unquoteText("'hello''")); | ||
assertEquals("don't", unquoteText("'don't'")); | ||
assertEquals("don\"t", unquoteText("\"don\"t\"")); | ||
|
||
assertEquals("hel\\lo'", unquoteText("'hel\\lo''")); | ||
assertEquals("hel'lo", unquoteText("'hel'lo'")); | ||
assertEquals("hel\"lo", unquoteText("\"hel\"lo\"")); | ||
assertEquals("hel\\'\\lo", unquoteText("'hel\\\\''\\\\lo'")); | ||
} | ||
} |