001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.util;
017
018import org.junit.jupiter.api.Test;
019
020import static org.junit.jupiter.api.Assertions.assertEquals;
021import static org.junit.jupiter.api.Assertions.assertNull;
022
023public class UnicodeUtilsTest {
024
025  @Test
026  public void testAscii() {
027    String x = "À Á Â Ã Ä Å Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö Ø Ù Ú Û Ü Ý Ÿ à á â ã ä å ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ø ù ú û ü ý ÿ";
028    String x2 = "A A A A A A C E E E E I I I I D N O O O O O O U U U U Y Y a a a a a a c e e e e i i i i d n o o o o o o u u u u y y";
029    assertEquals(x2, UnicodeUtils.ascii(x));
030    assertNull(UnicodeUtils.ascii(null));
031  }
032
033  @Test
034  public void testDecompose() {
035    String x = "Æ œ Œ IJ ij Lj lj \u0238 \u0239 ß st ſt ff fi fl ffi ffl";
036    String x2 = "Ae oe Oe Ij ij Lj lj db qp ss st ft ff fi fl ffi ffl";
037    assertEquals(x2, UnicodeUtils.decompose(x));
038    assertNull(UnicodeUtils.decompose(null));
039    assertEquals("fjaelje", UnicodeUtils.decompose("fjælje"));
040  }
041}