View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      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  package org.apache.commons.lang3.text.translate;
19  
20  import static org.junit.jupiter.api.Assertions.assertEquals;
21  
22  import org.apache.commons.lang3.AbstractLangTest;
23  import org.junit.jupiter.api.Test;
24  
25  /**
26   * Unit tests for {@link org.apache.commons.lang3.text.translate.OctalUnescaper}.
27   */
28  @Deprecated
29  public class OctalUnescaperTest extends AbstractLangTest {
30  
31      @Test
32      public void testBetween() {
33          final OctalUnescaper oue = new OctalUnescaper();   //.between("1", "377");
34  
35          String input = "\\45";
36          String result = oue.translate(input);
37          assertEquals("\45", result, "Failed to unescape octal characters via the between method");
38  
39          input = "\\377";
40          result = oue.translate(input);
41          assertEquals("\377", result, "Failed to unescape octal characters via the between method");
42  
43          input = "\\377 and";
44          result = oue.translate(input);
45          assertEquals("\377 and", result, "Failed to unescape octal characters via the between method");
46  
47          input = "\\378 and";
48          result = oue.translate(input);
49          assertEquals("\37" + "8 and", result, "Failed to unescape octal characters via the between method");
50  
51          input = "\\378";
52          result = oue.translate(input);
53          assertEquals("\37" + "8", result, "Failed to unescape octal characters via the between method");
54  
55          input = "\\1";
56          result = oue.translate(input);
57          assertEquals("\1", result, "Failed to unescape octal characters via the between method");
58  
59          input = "\\036";
60          result = oue.translate(input);
61          assertEquals("\036", result, "Failed to unescape octal characters via the between method");
62  
63          input = "\\0365";
64          result = oue.translate(input);
65          assertEquals("\036" + "5", result, "Failed to unescape octal characters via the between method");
66  
67          input = "\\003";
68          result = oue.translate(input);
69          assertEquals("\003", result, "Failed to unescape octal characters via the between method");
70  
71          input = "\\0003";
72          result = oue.translate(input);
73          assertEquals("\000" + "3", result, "Failed to unescape octal characters via the between method");
74  
75          input = "\\279";
76          result = oue.translate(input);
77          assertEquals("\279", result, "Failed to unescape octal characters via the between method");
78  
79          input = "\\999";
80          result = oue.translate(input);
81          assertEquals("\\999", result, "Failed to ignore an out of range octal character via the between method");
82      }
83  
84  }