| 18 | } |
| 19 | |
| 20 | void work_with_string(object print) |
| 21 | { |
| 22 | str data("this is a demo string"); |
| 23 | print(data.split(" ")); |
| 24 | print(data.split(" ",3)); |
| 25 | print(str("<->").join(data.split(" "))); |
| 26 | print(data.capitalize()); |
| 27 | print('[' + data.center(30) + ']'); |
| 28 | print(data.count("t")); |
| 29 | #if PY_VERSION_HEX < 0x03000000 |
| 30 | print(data.encode("utf-8")); |
| 31 | print(data.decode("utf-8")); |
| 32 | #else |
| 33 | print(data.encode("utf-8").attr("decode")("utf-8")); |
| 34 | print(data.encode("utf-8").attr("decode")("utf-8")); |
| 35 | #endif |
| 36 | |
| 37 | BOOST_ASSERT(!data.endswith("xx")); |
| 38 | BOOST_ASSERT(!data.startswith("test")); |
| 39 | |
| 40 | print(data.splitlines()); |
| 41 | print(data.strip()); |
| 42 | print(data.swapcase()); |
| 43 | print(data.title()); |
| 44 | |
| 45 | print("find"); |
| 46 | print(data.find("demo")); |
| 47 | print(data.find("demo"),3,5); |
| 48 | print(data.find(std::string("demo"))); |
| 49 | print(data.find(std::string("demo"),9)); |
| 50 | |
| 51 | print("expandtabs"); |
| 52 | str tabstr("\t\ttab\tdemo\t!"); |
| 53 | print(tabstr.expandtabs()); |
| 54 | print(tabstr.expandtabs(4)); |
| 55 | print(tabstr.expandtabs(7L)); |
| 56 | |
| 57 | print("operators"); |
| 58 | print( str("part1") + str("part2") ); |
| 59 | // print( str("a test string").slice(3,_) ); |
| 60 | // print( str("another test")[5] ); |
| 61 | |
| 62 | print(data.replace("demo",std::string("blabla"))); |
| 63 | print(data.rfind("i",5)); |
| 64 | print(data.rindex("i",5)); |
| 65 | |
| 66 | BOOST_ASSERT(!data.startswith("asdf")); |
| 67 | BOOST_ASSERT(!data.endswith("asdf")); |
| 68 | |
| 69 | print(data.translate(str('a')*256)); |
| 70 | |
| 71 | |
| 72 | bool tmp = data.isalnum() || data.isalpha() || data.isdigit() || data.islower() || |
| 73 | data.isspace() || data.istitle() || data.isupper(); |
| 74 | (void)tmp; // ignored. |
| 75 | } |
| 76 | |
| 77 |
nothing calls this directly
no test coverage detected