1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.google.android.mail.common.base; 18 19import android.test.suitebuilder.annotation.SmallTest; 20 21import junit.framework.TestCase; 22 23@SmallTest 24public class StringUtilTest extends TestCase { 25 public void testUnescapeHtml() { 26 // Unicode Character 'KISSING CAT FACE WITH CLOSED EYES' (U+1F63D) 27 final String unescaped1 = StringUtil.unescapeHTML("😽"); 28 assertEquals(unescaped1, "\uD83D\uDE3D"); 29 30 // Unicode Character 'KISSING CAT FACE WITH CLOSED EYES' (U+1F63D) 31 final String unescaped2 = StringUtil.unescapeHTML("😽"); 32 assertEquals(unescaped2, "\uD83D\uDE3D"); 33 34 // Unpaired surrogate, should not be converted 35 final String unescaped3 = StringUtil.unescapeHTML("&#D83D;"); 36 assertEquals(unescaped3, "&#D83D;"); 37 38 // Paired surrogate, also should not be converted according to HTML spec 39 final String unescaped4 = StringUtil.unescapeHTML("&#D83D;&#DE3D;"); 40 assertEquals(unescaped4, "&#D83D;&#DE3D;"); 41 42 // Named entity lowercase 43 final String unescaped5 = StringUtil.unescapeHTML("α"); 44 assertEquals(unescaped5, "\u03B1"); 45 46 // Named entity uppercase 47 final String unescaped6 = StringUtil.unescapeHTML("Α"); 48 assertEquals(unescaped6, "\u0391"); 49 } 50} 51