19 sys.path.insert(1,
"../")
23 from StringUtil
import *
32 OpenRTM_aist.Manager.instance().shutdownManager()
36 self.assertEqual(
isEscaped(
"test\\\\test",5),
True,
"Result failed.")
40 self.assertEqual(
escape(
"test\ttest"),
"test\\ttest",
"Result failed.")
41 self.assertEqual(
escape(
"test\ntest"),
"test\\ntest",
"Result failed.")
42 self.assertEqual(
escape(
"test\ftest"),
"test\\ftest",
"Result failed.")
43 self.assertEqual(
escape(
"test\rtest"),
"test\\rtest",
"Result failed.")
47 self.assertEqual(
unescape(
"test\\ttest"),
"test\ttest",
"Result failed.")
48 self.assertEqual(
unescape(
"test\\ntest"),
"test\ntest",
"Result failed.")
49 self.assertEqual(
unescape(
"test\\ftest"),
"test\ftest",
"Result failed.")
50 self.assertEqual(
unescape(
"test\\rtest"),
"test\rtest",
"Result failed.")
56 self.assertEqual(_str[0],
"test",
"Result failed.")
60 self.assertEqual(_str[0],
"test",
"Result failed.")
64 self.assertEqual(_str[0],
"test",
"Result failed.")
68 self.assertEqual(_str[0],
"",
"Result failed.")
72 self.assertEqual(_str[0],
"\ntest")
76 self.assertEqual(_str[0],
"\\ttest",
"Result failed.")
81 self.assertEqual(_str[0],
"test",
"Result failed.")
85 self.assertEqual(_str[0],
"test",
"Result failed.")
89 self.assertEqual(_str[0],
"test",
"Result failed.")
93 self.assertEqual(_str[0],
"",
"Result failed.")
97 self.assertEqual(_str[0],
"\n test",
"Result failed.")
101 self.assertEqual(_str[0],
"\\t test",
"Result failed.")
113 self.assertEqual(_str[0],
"test",
"Result failed.")
117 self.assertEqual(_str[0],
"test",
"Result failed.")
121 self.assertEqual(_str[0],
"test",
"Result failed.")
125 self.assertEqual(_str[0],
"test\t\n",
"Result failed.")
129 self.assertEqual(_str[0],
"test\\t",
"Result failed.")
137 _str = [
" NORMALIZE "]
139 self.assertEqual(_str[0],
"normalize")
141 _str = [
" \t \tNORmALIZE "]
143 self.assertEqual(_str[0],
"normalize")
145 _str = [
" nORMALIZE\t \t\t\t"]
147 self.assertEqual(_str[0],
"normalize")
153 self.assertEqual(_str[0], "reprace",
"Result failed.")
157 self.assertEqual(_str[0],
"place",
"Result failed.")
161 self.assertEqual(_str[0],
"raplaca",
"Result failed.")
165 _str =
split(
"test0,test1,test2",
",")
166 self.assertEqual(_str[0],
"test0",
"Result failed.")
167 self.assertEqual(_str[1],
"test1",
"Result failed.")
168 self.assertEqual(_str[2],
"test2",
"Result failed.")
170 _str =
split(
"test0.test1.test2",
".")
171 self.assertEqual(_str[0],
"test0",
"Result failed.")
172 self.assertEqual(_str[1],
"test1",
"Result failed.")
173 self.assertEqual(_str[2],
"test2",
"Result failed.")
175 _str =
split(
"test0/test1/test2",
"/")
176 self.assertEqual(_str[0],
"test0",
"Result failed.")
177 self.assertEqual(_str[1],
"test1",
"Result failed.")
178 self.assertEqual(_str[2],
"test2",
"Result failed.")
180 _str =
split(
"test0 test1 test2",
" ")
181 self.assertEqual(_str[0],
"test0",
"Result failed.")
182 self.assertEqual(_str[1],
"test1",
"Result failed.")
183 self.assertEqual(_str[2],
"test2",
"Result failed.")
187 ret =
toBool(
"yes",
"yes",
"no",
True)
188 self.assertEqual(ret,
True,
"Result failed.")
190 ret =
toBool(
"no",
"yes",
"no",
True)
191 self.assertEqual(ret,
False,
"Result failed.")
193 ret =
toBool(
"Yes",
"YES",
"NO",
True)
194 self.assertEqual(ret,
True,
"Result failed.")
196 ret =
toBool(
"No",
"YES",
"NO",
True)
197 self.assertEqual(ret,
False,
"Result failed.")
200 self.assertEqual(
includes([
"abc",
"abcde",
"ABC"],
"abc"),
True)
201 self.assertEqual(
includes([
"abc",
"abcde",
"ABC"],
"a"),
False)
202 self.assertEqual(
includes([
"abc",
"abcde",
"ABC"],
"ABC"),
True)
203 self.assertEqual(
includes(
"abc,abcde,ABC",
"ABC"),
True)
204 self.assertEqual(
includes(
"abc,abcde,ABC",
"AbC",
False),
False)
205 self.assertEqual(
includes([
"abc",
"abcde",
"AbC"],
"ABC"),
True)
206 self.assertEqual(
includes([
"abc",
"abcde",
"AbC"],
"ABC",
False),
False)
210 self.assertEqual(
isAbsolutePath(
"/usr/loca/bin"),
True,
"Result failed.")
212 self.assertEqual(
isAbsolutePath(
"\\\\localhost"),
True,
"Result failed.")
218 self.assertEqual(
isURL(
"http://www.google.co.jp"),
True,
"Result failed.")
226 self.assertEqual(
otos(123),
"123",
"Result failed.")
227 self.assertEqual(
otos(
"123"),
"123",
"Result failed.")
228 self.assertEqual(
otos(123456789123456789),
"123456789123456789",
"Result failed.")
229 self.assertEqual(
otos(0.123),
"0.123",
"Result failed.")
236 list_ = [[0.0,0.0,0.0,0.0]]
244 self.assertEqual(int_[0], 123,
"Result failed.")
245 self.assertEqual(long_[0], 123,
"Result failed.")
246 self.assertEqual(float_[0], 0.123,
"Result failed.")
247 self.assertEqual(list_[0], [0,1.1,2.2,3.3],
"Result failed.")
248 self.assertEqual(str_[0],
"hoge",
"Result failed.")
255 sv = [
"test0",
"test1",
"test0",
"test2",
"test0"]
257 self.assertEqual(sv_ret[0],
"test0",
"Result failed.")
258 self.assertEqual(sv_ret[1],
"test1",
"Result failed.")
259 self.assertEqual(sv_ret[2],
"test2",
"Result failed.")
260 self.assertEqual(len(sv_ret), 3,
"Result failed.")
270 sv = [
"test0",
"test1",
"test2"]
272 self.assertEqual(sv_ret,
"test0, test1, test2",
"Result failed.")
284 if __name__ ==
'__main__':
def replaceString(str, _from, _to)
Replace string.
def eraseHeadBlank(_str)
Erase the head blank characters of string.
def test_eraseBlank(self)
def split(input, delimiter)
Split string by delimiter.
def unescape(_str)
Unescape string.
def otos(n)
Convert the given object to st::string.
def stringTo(_type, _str)
Convert the given object to st::string.
def escape(_str)
Escape string.
def isEscaped(_str, pos)
Whether the character is escaped or not.
def isURL(str)
Investigate whether the given string is URL or not.
def test_eraseTailBlank(self)
def eraseTailBlank(_str)
Erase the tail blank characters of string.
def test_replaceString(self)
def isAbsolutePath(str)
Investigate whether the given string is absolute path or not.
def includes(_list, value, ignore_case=True)
Include if a string is included in string list.
def test_eraseHeadBlank(self)
def eraseBlank(str)
Erase blank characters of string.
def toBool(_str, yes, no, default_value=None)
Convert given string to bool value.
def test_isAbsolutePath(self)