Search in sources :

Example 1 with Regex

use of io.airlift.joni.Regex in project presto by prestodb.

the class TestLikeFunctions method testSelfEscaping.

@Test
public void testSelfEscaping() throws Exception {
    Regex regex = likePattern(utf8Slice("\\\\abc\\%"), utf8Slice("\\"));
    assertTrue(like(utf8Slice("\\abc%"), regex));
}
Also used : Regex(io.airlift.joni.Regex) Test(org.testng.annotations.Test)

Example 2 with Regex

use of io.airlift.joni.Regex in project presto by prestodb.

the class TestLikeFunctions method testLikeNewlineInMatch.

@Test
public void testLikeNewlineInMatch() {
    Regex regex = likePattern(utf8Slice("f%b%"));
    assertTrue(like(utf8Slice("foo\nbar"), regex));
}
Also used : Regex(io.airlift.joni.Regex) Test(org.testng.annotations.Test)

Example 3 with Regex

use of io.airlift.joni.Regex in project presto by prestodb.

the class TestLikeFunctions method testLikeNewlineBeforeMatch.

@Test
public void testLikeNewlineBeforeMatch() {
    Regex regex = likePattern(utf8Slice("%b%"));
    assertTrue(like(utf8Slice("foo\nbar"), regex));
}
Also used : Regex(io.airlift.joni.Regex) Test(org.testng.annotations.Test)

Example 4 with Regex

use of io.airlift.joni.Regex in project presto by prestodb.

the class TestLikeFunctions method testLikeInvalidUtf8Value.

@SuppressWarnings("NumericCastThatLosesPrecision")
@Test(timeOut = 1000)
public void testLikeInvalidUtf8Value() {
    Slice value = Slices.wrappedBuffer(new byte[] { 'a', 'b', 'c', (byte) 0xFF, 'x', 'y' });
    Regex regex = likePattern(utf8Slice("%b%"), utf8Slice("\\"));
    assertTrue(like(value, regex));
}
Also used : Regex(io.airlift.joni.Regex) Slice(io.airlift.slice.Slice) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) Test(org.testng.annotations.Test)

Example 5 with Regex

use of io.airlift.joni.Regex in project presto by prestodb.

the class TestLikeFunctions method testLikeUtf8Pattern.

@Test(timeOut = 1000)
public void testLikeUtf8Pattern() {
    Regex regex = likePattern(utf8Slice("%名誉%"), utf8Slice("\\"));
    assertFalse(like(utf8Slice("foo"), regex));
}
Also used : Regex(io.airlift.joni.Regex) Test(org.testng.annotations.Test)

Aggregations

Regex (io.airlift.joni.Regex)11 Test (org.testng.annotations.Test)11 Slice (io.airlift.slice.Slice)1 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)1