01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id$ */
19:
20: package org.apache.xmlgraphics.ps.dsc.events;
21:
22: import java.util.List;
23:
24: import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginResource;
25:
26: import junit.framework.TestCase;
27:
28: public class DSCValueParserTestCase extends TestCase {
29:
30: private String[] toArray(List params) {
31: return (String[]) params.toArray(new String[params.size()]);
32: }
33:
34: public void testText() throws Exception {
35: DSCCommentBeginResource obj = new DSCCommentBeginResource();
36: String[] res = toArray(obj.splitParams("procset Test"));
37: assertEquals(2, res.length);
38: assertEquals("procset", res[0]);
39: assertEquals("Test", res[1]);
40:
41: res = toArray(obj.splitParams("procset\tTest"));
42: assertEquals(2, res.length);
43: assertEquals("procset", res[0]);
44: assertEquals("Test", res[1]);
45: }
46:
47: public void testParentheseText() throws Exception {
48: DSCCommentBeginResource obj = new DSCCommentBeginResource();
49: String[] res = toArray(obj
50: .splitParams("procset (Hello World!)"));
51: assertEquals(2, res.length);
52: assertEquals("procset", res[0]);
53: assertEquals("Hello World!", res[1]);
54:
55: res = toArray(obj
56: .splitParams("procset\t(Hello\t\\\\wonderful/ World!)"));
57: assertEquals(2, res.length);
58: assertEquals("procset", res[0]);
59: assertEquals("Hello\t\\wonderful/ World!", res[1]);
60:
61: res = toArray(obj
62: .splitParams("procset (Hello \\042wonderful\\042 World!) blahblah"));
63: assertEquals(3, res.length);
64: assertEquals("procset", res[0]);
65: assertEquals("Hello \"wonderful\" World!", res[1]);
66: assertEquals("blahblah", res[2]);
67:
68: //Parentheses not balanced
69: res = toArray(obj
70: .splitParams("procset (Hello (wonderful) World! blahblah"));
71: assertEquals(2, res.length);
72: assertEquals("procset", res[0]);
73: assertEquals("Hello (wonderful) World! blahblah", res[1]);
74: }
75:
76: }
|