Commit 8623e80d authored by Kevin Modzelewski's avatar Kevin Modzelewski

minor

parent c8579e00
......@@ -483,15 +483,11 @@ Box* strCapitalize(BoxedString* self) {
std::string s(self->s);
for (auto& i : s) {
if (std::isupper(i)) {
i = std::tolower(i);
}
i = std::tolower(i);
}
if (!s.empty()) {
if (std::islower(s[0])) {
s[0] = std::toupper(s[0]);
}
s[0] = std::toupper(s[0]);
}
return boxString(s);
......
......@@ -2,15 +2,15 @@
# Testing capitalize/title methods.
def test(s):
print 'string:', repr(s), 'capitalize:', s.capitalize(), 'titLe:', s.titLe()
print 'string:', repr(s), 'capitalize:', s.capitalize(), 'title:', s.title()
test(' hello ')
test('Hello ')
test('hello ')
test('aaaa')
test('AaAa')
test('fOrMaT thIs aS titLe String')
test('fOrMaT,thIs-aS*titLe;String')
test('fOrMaT thIs aS title String')
test('fOrMaT,thIs-aS*title;String')
test('getInt')
var = 'hello'
......@@ -26,3 +26,9 @@ try:
print 'TypeError not raised'
except TypeError:
print 'TypeError raised'
for i in xrange(256):
c = chr(i)
s = "a%sb" % c
if s.title()[2] == 'b':
print repr(c)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment