001 /*
002 * Copyright 2010 - 2010 JEuclid, http://jeuclid.sf.net
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 */
016
017 /* $Id: StringUtilTest.java,v 92b6a7c39d7f 2010/08/11 20:23:17 max $ */
018
019 package net.sourceforge.jeuclid.test;
020
021 import net.sourceforge.jeuclid.elements.support.text.StringUtil;
022
023 import org.junit.Assert;
024 import org.junit.Test;
025
026 /**
027 * Tests for {@link StringUtil}.
028 *
029 * @version $Revision: 92b6a7c39d7f $
030 */
031 public class StringUtilTest {
032
033 /** Default constructor. */
034 public StringUtilTest() {
035 // nothing to do.
036 }
037
038 /**
039 * Test for {@link StringUtil#countDisplayableCharacters(String)}.
040 */
041 @Test
042 public void testCountDisplayableCharacters() {
043 Assert.assertEquals(StringUtil.countDisplayableCharacters(null), 0);
044 Assert.assertEquals(StringUtil.countDisplayableCharacters(""), 0);
045 Assert.assertEquals(StringUtil.countDisplayableCharacters("a"), 1);
046 Assert.assertEquals(StringUtil.countDisplayableCharacters("abc"), 3);
047
048 // High surrogate
049 Assert.assertEquals(
050 StringUtil.countDisplayableCharacters("\uD834\uDD1E"), 1);
051
052 // Combining mark
053 Assert.assertEquals(StringUtil.countDisplayableCharacters("i\u0302"), 1);
054
055 }
056 }