use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.
the class TextQLParserTest method testRegexLiteralToString.
/**
* Test the regexLiteralToString method of the parser.
* It should parse a REGEX_LITERAL from the input and return it as a string.
* @throws ParseException if an unexpected ParseException is thrown
*/
@Test
public void testRegexLiteralToString() throws ParseException {
Assert.assertEquals((new TextQLParser(string2InputStream(" // "))).regexLiteralToString(), "");
Assert.assertEquals((new TextQLParser(string2InputStream(" /abc/ "))).regexLiteralToString(), "abc");
Assert.assertEquals((new TextQLParser(string2InputStream(" /d\\/e/ "))).regexLiteralToString(), "d/e");
Assert.assertEquals((new TextQLParser(string2InputStream(" /d\\/e\\/f/ "))).regexLiteralToString(), "d/e/f");
Assert.assertEquals((new TextQLParser(string2InputStream(" /FROM/ "))).regexLiteralToString(), "FROM");
Assert.assertEquals((new TextQLParser(string2InputStream(" /\"/ "))).regexLiteralToString(), "\"");
Assert.assertEquals((new TextQLParser(string2InputStream(" /\\/ "))).regexLiteralToString(), "\\");
assertException(() -> (new TextQLParser(string2InputStream(" /21 "))).regexLiteralToString(), TokenMgrError.class);
assertException(() -> (new TextQLParser(string2InputStream(" 2/1/ "))).regexLiteralToString(), ParseException.class);
assertException(() -> (new TextQLParser(string2InputStream(" \"4/ "))).regexLiteralToString(), TokenMgrError.class);
assertException(() -> (new TextQLParser(string2InputStream(" FROM// "))).regexLiteralToString(), ParseException.class);
}
use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.
the class TextQLParserTest method testStringLiteralToString.
/**
* Test the stringLiteralToString method of the parser.
* It should parse a STRING_LITERAL from the input and return it as a string.
* @throws ParseException if an unexpected ParseException is thrown
*/
@Test
public void testStringLiteralToString() throws ParseException {
Assert.assertEquals((new TextQLParser(string2InputStream(" \"\" "))).stringLiteralToString(), "");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"abc\" "))).stringLiteralToString(), "abc");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"de f\" "))).stringLiteralToString(), "de f");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"d\\\"e\" "))).stringLiteralToString(), "d\"e");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"d\\\"e\\\"f\" "))).stringLiteralToString(), "d\"e\"f");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"\\\"\" "))).stringLiteralToString(), "\"");
Assert.assertEquals((new TextQLParser(string2InputStream(" \"\\\" "))).stringLiteralToString(), "\\");
assertException(() -> (new TextQLParser(string2InputStream(" \"21 "))).stringLiteralToString(), TokenMgrError.class);
assertException(() -> (new TextQLParser(string2InputStream(" 'aa' "))).stringLiteralToString(), TokenMgrError.class);
assertException(() -> (new TextQLParser(string2InputStream(" 2\"1\" "))).stringLiteralToString(), ParseException.class);
assertException(() -> (new TextQLParser(string2InputStream(" 21 "))).stringLiteralToString(), ParseException.class);
assertException(() -> (new TextQLParser(string2InputStream(" SELECTa "))).stringLiteralToString(), ParseException.class);
assertException(() -> (new TextQLParser(string2InputStream(" abc "))).stringLiteralToString(), ParseException.class);
}
use of edu.uci.ics.textdb.textql.languageparser.TextQLParser in project textdb by TextDB.
the class TextQLParserTest method testIdentifierLiteralToString.
/**
* Test the identifierLiteralToString method of the parser.
* It should parse a IDENTIFIER_LITERAL from the input and return it as a string.
* @throws ParseException if an unexpected ParseException is thrown
*/
@Test
public void testIdentifierLiteralToString() throws ParseException {
Assert.assertEquals((new TextQLParser(string2InputStream(" i "))).identifierLiteralToString(), "i");
Assert.assertEquals((new TextQLParser(string2InputStream(" id "))).identifierLiteralToString(), "id");
Assert.assertEquals((new TextQLParser(string2InputStream(" id de "))).identifierLiteralToString(), "id");
Assert.assertEquals((new TextQLParser(string2InputStream(" id0 "))).identifierLiteralToString(), "id0");
Assert.assertEquals((new TextQLParser(string2InputStream(" i6i8s7s "))).identifierLiteralToString(), "i6i8s7s");
Assert.assertEquals((new TextQLParser(string2InputStream(" j7i\\8s7s "))).identifierLiteralToString(), "j7i");
Assert.assertEquals((new TextQLParser(string2InputStream(" k8i\"8s7s "))).identifierLiteralToString(), "k8i");
Assert.assertEquals((new TextQLParser(string2InputStream(" aFROM "))).identifierLiteralToString(), "aFROM");
Assert.assertEquals((new TextQLParser(string2InputStream(" A "))).identifierLiteralToString(), "A");
Assert.assertEquals((new TextQLParser(string2InputStream(" FROMa "))).identifierLiteralToString(), "FROMa");
Assert.assertEquals((new TextQLParser(string2InputStream(" Ed0 "))).identifierLiteralToString(), "Ed0");
assertException(() -> (new TextQLParser(string2InputStream(" 2df "))).identifierLiteralToString(), ParseException.class);
assertException(() -> (new TextQLParser(string2InputStream(" _a "))).identifierLiteralToString(), TokenMgrError.class);
}
Aggregations