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: */package org.apache.solr.util;
17:
18: import junit.framework.TestCase;
19:
20: import java.util.List;
21:
22: /**
23: * @author yonik
24: * @version $Id: TestUtils.java 488728 2006-12-19 17:08:17Z yonik $
25: */
26: public class TestUtils extends TestCase {
27: public static void testSplitEscaping() {
28: List<String> arr = StrUtils.splitSmart("\\r\\n:\\t\\f\\b", ":",
29: true);
30: assertEquals(2, arr.size());
31: assertEquals("\r\n", arr.get(0));
32: assertEquals("\t\f\b", arr.get(1));
33:
34: arr = StrUtils.splitSmart("\\r\\n:\\t\\f\\b", ":", false);
35: assertEquals(2, arr.size());
36: assertEquals("\\r\\n", arr.get(0));
37: assertEquals("\\t\\f\\b", arr.get(1));
38:
39: arr = StrUtils.splitWS("\\r\\n \\t\\f\\b", true);
40: assertEquals(2, arr.size());
41: assertEquals("\r\n", arr.get(0));
42: assertEquals("\t\f\b", arr.get(1));
43:
44: arr = StrUtils.splitWS("\\r\\n \\t\\f\\b", false);
45: assertEquals(2, arr.size());
46: assertEquals("\\r\\n", arr.get(0));
47: assertEquals("\\t\\f\\b", arr.get(1));
48:
49: arr = StrUtils.splitSmart("\\:foo\\::\\:bar\\:", ":", true);
50: assertEquals(2, arr.size());
51: assertEquals(":foo:", arr.get(0));
52: assertEquals(":bar:", arr.get(1));
53:
54: arr = StrUtils.splitWS("\\ foo\\ \\ bar\\ ", true);
55: assertEquals(2, arr.size());
56: assertEquals(" foo ", arr.get(0));
57: assertEquals(" bar ", arr.get(1));
58: }
59:
60: }
|