100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair/* 200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Copyright 2008 the original author or authors. 300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * 400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Licensed under the Apache License, Version 2.0 (the "License"); 500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * you may not use this file except in compliance with the License. 600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * You may obtain a copy of the License at 700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * 800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * http://www.apache.org/licenses/LICENSE-2.0 900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * 1000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Unless required by applicable law or agreed to in writing, software 1100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * distributed under the License is distributed on an "AS IS" BASIS, 1200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * See the License for the specific language governing permissions and 1400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * limitations under the License. 1500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair */ 1600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairpackage org.mockftpserver.core.util 1700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 1800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairimport org.mockftpserver.test.AbstractGroovyTestCase 1900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 2000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair/** 2100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * Tests for the IoUtil class 2200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * 2300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * @version $Revision$ - $Date$ 2400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * 2500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair * @author Chris Mair 2600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair */ 2700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismairclass StringUtilTest extends AbstractGroovyTestCase { 2800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 2900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair void testPadRight() { 3000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('', 0) == '' 3100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('', 1) == ' ' 3200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('z', 1) == 'z' 3300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight(' z', 3) == ' z ' 3400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('z', 1) == 'z' 3500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('zzz', 1) == 'zzz' 3600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padRight('z', 5) == 'z ' 3700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair } 3800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 3900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair void testPadLeft() { 4000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('', 0) == '' 4100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('', 1) == ' ' 4200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('z', 1) == 'z' 4300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft(' z', 3) == ' z' 4400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('z', 1) == 'z' 4500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('zzz', 1) == 'zzz' 4600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.padLeft('z', 5) == ' z' 4700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair } 4800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 4900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair void testJoin() { 5000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join([], ' ') == '' 5100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join([], 'x') == '' 5200dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join(['a'], 'x') == 'a' 5300dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join(['a', 'b'], '') == 'ab' 5400dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join(['a', 'b'], ',') == 'a,b' 5500dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair assert StringUtil.join(['a', 'b', 'c'], ':') == 'a:b:c' 5600dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 5700dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair shouldFailWithMessageContaining('parts') { StringUtil.join(null, '') } 5800dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair shouldFailWithMessageContaining('delimiter') { StringUtil.join([], null) } 5900dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair } 6000dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair 6100dc7bdcf1df9e86789d963984dfc6912a8854c6chrismair}