QueryExpStringTest.java revision 0
0N/A * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * @summary Test that QueryExp.toString() is reversible 0N/A * @author Eamonn McManus 0N/A * @run clean QueryExpStringTest 0N/A * @run build QueryExpStringTest 0N/A * @run main QueryExpStringTest 0N/A // Commented-out tests below require change to implementation 0N/A// complexString, "'a\\'b\\\\\\'\"'", 0N/A gt,
"(12345678) > (2.5)",
0N/A lt,
"(12345678) < (2.5)",
0N/A eq,
"(12345678) = (2.5)",
0N/A// initial, "attr like 'simpleString*'", 0N/A// initialStar, "attr like '\\\\**'", 0N/A// any, "attr like '*simpleString*'", 0N/A// anyStar, "attr like '*\\\\**'", 0N/A// ffinal, "attr like '*simpleString'", 0N/A// finalMagic, "attr like '*\\\\?\\\\*\\\\[\\\\\\\\'", 0N/A in,
"12345678 in (12345678, 2.5)",
0N/A and,
"((12345678) > (2.5)) and ((12345678) < (2.5))",
0N/A or,
"((12345678) > (2.5)) or ((12345678) < (2.5))",
0N/A not,
"not ((12345678) > (2.5))",
0N/A throw new Exception(
"Expected in or like after expression");
0N/A /* This is very ugly. We might have "(q1) and (q2)" here, or 0N/A we might have "(e1) < (e2)". Since the syntax for a query 0N/A (q1) is not the same as for an expression (e1), but can 0N/A begin with one, we try to parse the query, and if we get an 0N/A exception we then try to parse an expression. It's a hacky 0N/A kind of look-ahead. */ 0N/A /* Look ahead to see if we have an arithmetic operator. */ 0N/A throw new Exception(
"Expected arithmetic operator after space");
0N/A throw new Exception(
"Expected space after arithmetic operator");
0N/A throw new Exception(
"Empty string found, expression expected");
0N/A if (c ==
'.' || c ==
'e' || c ==
'E') {