Refactor some test fixtures.

This commit is contained in:
Gary Gregory 2021-11-20 09:42:57 -05:00
parent 8a4d1b82f8
commit 1f06eb4dce
3 changed files with 56 additions and 32 deletions

View File

@ -16,6 +16,10 @@
*/
package org.apache.commons.lang3;
import static org.apache.commons.lang3.Supplementary.CharU20000;
import static org.apache.commons.lang3.Supplementary.CharU20001;
import static org.apache.commons.lang3.Supplementary.CharUSuppCharHigh;
import static org.apache.commons.lang3.Supplementary.CharUSuppCharLow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -29,28 +33,6 @@ import org.junitpioneer.jupiter.DefaultLocale;
* Unit tests {@link org.apache.commons.lang3.StringUtils} - Contains methods
*/
public class StringUtilsContainsTest {
/**
* Supplementary character U+20000
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharU20000 = "\uD840\uDC00";
/**
* Supplementary character U+20001
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharU20001 = "\uD840\uDC01";
/**
* Incomplete supplementary character U+20000, high surrogate only.
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharUSuppCharHigh = "\uDC00";
/**
* Incomplete supplementary character U+20000, low surrogate only.
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharUSuppCharLow = "\uD840";
@Test
public void testContains_Char() {
assertFalse(StringUtils.contains(null, ' '));

View File

@ -16,6 +16,8 @@
*/
package org.apache.commons.lang3;
import static org.apache.commons.lang3.Supplementary.CharU20000;
import static org.apache.commons.lang3.Supplementary.CharU20001;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ -31,17 +33,8 @@ import org.junit.jupiter.api.Test;
* Unit tests {@link org.apache.commons.lang3.StringUtils} - Equals/IndexOf methods
*/
public class StringUtilsEqualsIndexOfTest {
private static final String BAR = "bar";
/**
* Supplementary character U+20000
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharU20000 = "\uD840\uDC00";
/**
* Supplementary character U+20001
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
private static final String CharU20001 = "\uD840\uDC01";
private static final String FOO = "foo";

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.lang3;
/**
* Supplementary character test fixtures.
*
* See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
public class Supplementary {
/**
* Supplementary character U+20000 See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
static final String CharU20000 = "\uD840\uDC00";
/**
* Supplementary character U+20001 See http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
static final String CharU20001 = "\uD840\uDC01";
/**
* Incomplete supplementary character U+20000, high surrogate only. See
* http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
static final String CharUSuppCharHigh = "\uDC00";
/**
* Incomplete supplementary character U+20000, low surrogate only. See
* http://www.oracle.com/technetwork/articles/javase/supplementary-142654.html
*/
static final String CharUSuppCharLow = "\uD840";
}