MCPcopy Index your code
hub / github.com/pytorch/pytorch / test_str_ops

Method test_str_ops

test/test_jit_string.py:9–318  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class TestScript(JitTestCase):
9 def test_str_ops(self):
10 def test_str_is(s: str) -> Tuple[bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool]:
11 return s.isupper(), s.islower(), s.isdigit(), s.isspace(), \
12 s.isalnum(), s.isalpha(), s.isdecimal(), s.isnumeric(), \
13 s.isidentifier(), s.istitle(), s.isprintable()
14
15 def test_str_to(s: str) -> Tuple[str, str, str, str, str]:
16 return s.upper(), s.lower(), s.capitalize(), s.title(), s.swapcase()
17
18 def test_str_strip(s: str) -> Tuple[str, str, str]:
19 return (
20 s.lstrip(),
21 s.rstrip(),
22 s.strip(),
23 )
24
25 def test_str_strip_char_set(s: str, char_set: str) -> Tuple[str, str, str]:
26 return (
27 s.lstrip(char_set),
28 s.rstrip(char_set),
29 s.strip(char_set),
30 )
31
32 inputs = ["", "12a", "!B", "12", "a", "B", "aB", "$12", "B12", "AB ",
33 " \t", " \n", "\na", "abc", "123.3", "s a", "b12a ",
34 "more strings with spaces", "Titular Strings", "\x0acan'tprintthis",
35 "spaces at the end ", " begin"]
36
37 def test_str_center(i: int, s: str) -> str:
38 return s.center(i)
39
40 def test_str_center_fc(i: int, s: str) -> str:
41 return s.center(i, '*')
42
43 def test_str_center_error(s: str) -> str:
44 return s.center(10, '**')
45
46 def test_ljust(s: str, i: int) -> str:
47 return s.ljust(i)
48
49 def test_ljust_fc(s: str, i: int, fc: str) -> str:
50 return s.ljust(i, fc)
51
52 def test_ljust_fc_err(s: str) -> str:
53 return s.ljust(10, '**')
54
55 def test_rjust(s: str, i: int) -> str:
56 return s.rjust(i)
57
58 def test_rjust_fc(s: str, i: int, fc: str) -> str:
59 return s.rjust(i, fc)
60
61 def test_rjust_fc_err(s: str) -> str:
62 return s.rjust(10, '**')
63
64 def test_zfill(s: str, i: int) -> str:
65 return s.zfill(i)
66

Callers

nothing calls this directly

Calls 4

checkScriptMethod · 0.80
assertRaisesMethod · 0.80
rangeFunction · 0.50

Tested by

no test coverage detected