| 765 | } |
| 766 | |
| 767 | static bool testMethod_substr_AtEnd(cm::String str) |
| 768 | { |
| 769 | cm::String substr = str.substr(1); |
| 770 | ASSERT_TRUE(substr.data() == str.data() + 1); |
| 771 | ASSERT_TRUE(substr.size() == 2); |
| 772 | ASSERT_TRUE(!substr.is_stable()); |
| 773 | |
| 774 | // c_str() at the end of the buffer does not internally mutate. |
| 775 | ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0); |
| 776 | ASSERT_TRUE(substr.c_str() == str.data() + 1); |
| 777 | ASSERT_TRUE(substr.data() == str.data() + 1); |
| 778 | ASSERT_TRUE(substr.size() == 2); |
| 779 | ASSERT_TRUE(!substr.is_stable()); |
| 780 | |
| 781 | // str() internally mutates. |
| 782 | ASSERT_TRUE(substr.str() == "bc"); |
| 783 | ASSERT_TRUE(substr.is_stable()); |
| 784 | ASSERT_TRUE(substr.data() != str.data() + 1); |
| 785 | ASSERT_TRUE(substr.size() == 2); |
| 786 | ASSERT_TRUE(substr.c_str() != str.data() + 1); |
| 787 | ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0); |
| 788 | return true; |
| 789 | } |
| 790 | |
| 791 | static bool testMethod_substr_AtEndBorrowed() |
| 792 | { |