[libcxx-commits] [libcxx] Add `std::basic_string` test cases (PR #74830)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 8 03:45:40 PST 2023


https://github.com/AdvenamTacet created https://github.com/llvm/llvm-project/pull/74830

Extend `std::basic_string` tests to cover more buffer situations and length in general, particularly non-SSO cases after SSO test cases (changing buffers). This commit is a side effect of working on tests for ASan annotations.

Related PR: https://github.com/llvm/llvm-project/pull/72677

>From c69d3c957e4665de16e51bd6cb8ea37d2528946a Mon Sep 17 00:00:00 2001
From: Advenam Tacet <advenam.tacet at trailofbits.com>
Date: Fri, 8 Dec 2023 12:32:15 +0100
Subject: [PATCH] Add `std::basic_string` test cases

Extend `std::basic_string` tests to cover more buffer situations, particularly non-SSO cases after SSO test cases (changing buffers).
This commit is a side effect of working on tests for ASan annotations.

Related PR: https://github.com/llvm/llvm-project/pull/72677
---
 .../string.capacity/reserve.pass.cpp            |  1 +
 .../string.capacity/reserve_size.pass.cpp       |  1 +
 .../string.capacity/shrink_to_fit.pass.cpp      |  4 ++++
 .../string.cons/copy_assignment.pass.cpp        |  1 +
 .../string.cons/move_assignment.pass.cpp        |  1 +
 .../string.cons/pointer_assignment.pass.cpp     |  1 +
 .../string.cons/string_view_assignment.pass.cpp |  1 +
 .../string_append/T_size_size.pass.cpp          |  5 +++++
 .../string_append/push_back.pass.cpp            |  4 ++++
 .../string_append/size_char.pass.cpp            |  5 +++++
 .../string_append/string.pass.cpp               |  8 ++++++++
 .../string_append/string_size_size.pass.cpp     |  9 +++++++++
 .../string_append/string_view.pass.cpp          |  8 ++++++++
 .../string_assign/pointer.pass.cpp              |  5 +++++
 .../string_assign/pointer_size.pass.cpp         |  6 ++++++
 .../string.modifiers/string_copy/copy.pass.cpp  |  2 ++
 .../string_insert/iter_char.pass.cpp            | 17 +++++++++++++++++
 .../string_op_plus_equal/char.pass.cpp          |  1 +
 .../string_op_plus_equal/pointer.pass.cpp       | 10 ++++++++++
 .../string_op_plus_equal/string.pass.cpp        | 10 ++++++++++
 .../string.special/swap.pass.cpp                |  4 ++++
 .../string.ops/string_substr/substr.pass.cpp    |  9 +++++++++
 22 files changed, 113 insertions(+)

diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
index ecde912dc39f4..b740901be1c4d 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -39,6 +39,7 @@ template <class S>
 void test_string() {
   test<S>(0, 0);
   test<S>(10, 5);
+  test<S>(100, 5);
   test<S>(100, 50);
 }
 
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp
index bb804bf328b3b..dfb3b270f750e 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp
@@ -64,6 +64,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
     test<S>(0, 0, 50);
   }
   {
+    test<S>(100, 1, 5);
     test<S>(100, 50, 5);
     test<S>(100, 50, 10);
     test<S>(100, 50, 50);
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
index 1efebfc9cea56..66eefdd383dc0 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
@@ -36,6 +36,10 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   s.erase(5);
   test(s);
 
+  s.assign(50, 'a');
+  s.erase(5);
+  test(s);
+
   s.assign(100, 'a');
   s.erase(50);
   test(s);
diff --git a/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp
index 8d0fcb3c6d294..eb522aafa2430 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp
@@ -35,6 +35,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
 
   test(S(), S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("123456789"), S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+  test(S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"), S("123456789"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
        S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
diff --git a/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp
index 89cb44d62ef2b..cb0fe0396cb79 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp
@@ -40,6 +40,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
 
   test(S(), S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("123456789"), S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+  test(S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"), S("123456789"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
        S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp
index 4b3027a2aad11..eb3296d60403b 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp
@@ -37,6 +37,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
 
   test(S(), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
   test(S("123456789"), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+  test(S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"), "123456789");
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
        "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp
index 3c88f9e40fc0b..b41d1336fd134 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp
@@ -37,6 +37,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
 
   test(S(), SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("123456789"), SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+  test(S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"), SV("123456789"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
        SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
   test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
index cf45b368ebbca..e43c36c31e483 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
@@ -80,6 +80,11 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890"));
   test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
   test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, S("123456789012345678906789012345"));
+
+  // Starting from long string (no SSO)
+  test(S("1234512345678901234567890"), SV(), 0, 0, S("1234512345678901234567890"));
+  test(S("1234512345678901234567890"), SV("12345"), 1, 3, S("1234512345678901234567890234"));
+  test(S("1234512345678901234567890"), SV("12345678901234567890"), 5, 10, S("12345123456789012345678906789012345"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
index 0b8e5f65c15e9..120de4fef7406 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
@@ -68,6 +68,10 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S(), 'a', S(1, 'a'));
   test(S("12345"), 'a', S("12345a"));
   test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+  test(S("123abcabcdefghabcdefgh"), 'a', S("123abcabcdefghabcdefgha"));
+  test(S("123abcabcdefghabcdefgha"), 'b', S("123abcabcdefghabcdefghab"));
+  test(S("123abcabcdefghabcdefghab"), 'c', S("123abcabcdefghabcdefghabc"));
+  test(S("123abcabcdefghabcdefghabc"), 'd', S("123abcabcdefghabcdefghabcd"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
index eb0728456df5b..86072efc09cd4 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
@@ -38,6 +38,11 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
   test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
   test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+
+  // Starting from long string (no SSO)
+  test(S("1234567890123456789012345678901234567890"), 0, 'a', S("1234567890123456789012345678901234567890"));
+  test(S("1234567890123456789012345678901234567890"), 1, 'a', S("1234567890123456789012345678901234567890a"));
+  test(S("1234567890123456789012345678901234567890"), 10, 'a', S("1234567890123456789012345678901234567890aaaaaaaaaa"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp
index 21f2ff53004d1..9d6237507e8a3 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp
@@ -45,6 +45,14 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
   test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
   test(S("12345678901234567890"), S("12345678901234567890"), S("1234567890123456789012345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("123456789012345678901234567890"), S(), S("123456789012345678901234567890"));
+  test(S("123456789012345678901234567890"), S("12345"), S("12345678901234567890123456789012345"));
+  test(S("123456789012345678901234567890"), S("1234567890"), S("1234567890123456789012345678901234567890"));
+  test(S("123456789012345678901234567890"),
+       S("12345678901234567890"),
+       S("12345678901234567890123456789012345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
index 902d29c53ac69..5b578a1a0bf8d 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
@@ -79,6 +79,15 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
   test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
   test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, S("123456789012345678906789012345"));
+
+  // Starting from long string (no SSO)
+  test(S("123456789012345678901234567890"), S(), 0, 0, S("123456789012345678901234567890"));
+  test(S("123456789012345678901234567890"), S("12345"), 1, 3, S("123456789012345678901234567890234"));
+  test(S("123456789012345678901234567890"),
+       S("12345678901234567890"),
+       5,
+       10,
+       S("1234567890123456789012345678906789012345"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp
index c09cdde1bc105..9de48ca2463e2 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp
@@ -47,6 +47,14 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345"));
   test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
   test(S("12345678901234567890"), SV("12345678901234567890"), S("1234567890123456789012345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("123456789012345678901234567890"), SV(), S("123456789012345678901234567890"));
+  test(S("123456789012345678901234567890"), SV("12345"), S("12345678901234567890123456789012345"));
+  test(S("123456789012345678901234567890"), SV("1234567890"), S("1234567890123456789012345678901234567890"));
+  test(S("123456789012345678901234567890"),
+       SV("12345678901234567890"),
+       S("12345678901234567890123456789012345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
index 11e12c318a2e8..175062c91a883 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
@@ -37,6 +37,11 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), "", S());
   test(S("12345678901234567890"), "12345", S("12345"));
   test(S("12345678901234567890"), "12345678901234567890", S("12345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("1234512345678901234567890"), "", S());
+  test(S("1234512345678901234567890"), "12345", S("12345"));
+  test(S("1234512345678901234567890"), "12345678901234567890", S("12345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
index 2738a9a6ffad5..851f016829c3f 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
@@ -42,6 +42,12 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), "", 0, S());
   test(S("12345678901234567890"), "12345", 5, S("12345"));
   test(S("12345678901234567890"), "12345678901234567890", 20, S("12345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("1234512345678901234567890"), "", 0, S());
+  test(S("1234512345678901234567890"), "12345", 5, S("12345"));
+  test(S("1234512345678901234567890"), "12345678901234567890", 20, S("12345678901234567890"));
+  test(S("1234512345678901234567890"), "123451234512345678901234567890", 30, S("123451234512345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
index e1904baeb9033..1bd686c5edbf8 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
@@ -102,6 +102,8 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("abcdefghijklmnopqrst"), s, 20, 0);
   test(S("abcdefghijklmnopqrst"), s, 20, 1);
   test(S("abcdefghijklmnopqrst"), s, 21, 0);
+  test(S("abcdefghijklmnopqrstabcdefghijklmnopqrst"), s, 40, 1);
+  test(S("abcdefghijklmnopqrstabcdefghijklmnopqrst"), s, 40, 0);
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
index bc3ce511ab5c2..eb1c10b070a2c 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
@@ -47,6 +47,23 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(s, s.begin() + 4, 'A', S("a567A1432dcb"));
   test(s, s.begin() + 5, 'B', S("a567AB1432dcb"));
   test(s, s.begin() + 6, 'C', S("a567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin(), 'x', S("xxxxxxxxxxxxxxxxa567ABC1432dcb"));
+  test(s, s.begin() + 1, 'x', S("xxxxxxxxxxxxxxxxxa567ABC1432dcb"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
index 1e03d8c1b6147..3d5e2c0cbf699 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
@@ -29,6 +29,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345"), 'a', S("12345a"));
   test(S("1234567890"), 'a', S("1234567890a"));
   test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+  test(S("1234567890123456789012345678901234567890"), 'a', S("1234567890123456789012345678901234567890a"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
index 2d8c535b354c2..ba14b3831778f 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
@@ -44,6 +44,16 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
   test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
   test(S("12345678901234567890"), "12345678901234567890", S("1234567890123456789012345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("1234567890123456789012345678901234567890"), "", S("1234567890123456789012345678901234567890"));
+  test(S("1234567890123456789012345678901234567890"), "12345", S("123456789012345678901234567890123456789012345"));
+  test(S("1234567890123456789012345678901234567890"),
+       "12345678901234567890",
+       S("123456789012345678901234567890123456789012345678901234567890"));
+  test(S("1234567890123456789012345678901234567890"),
+       "1234567890123456789012345678901234567890",
+       S("12345678901234567890123456789012345678901234567890123456789012345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
index e02ced737ae16..59c76ece67c66 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
@@ -45,6 +45,16 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
   test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
   test(S("12345678901234567890"), S("12345678901234567890"), S("1234567890123456789012345678901234567890"));
+
+  // Starting from long string (no SSO)
+  test(S("1234567890123456789012345678901234567890"), S(), S("1234567890123456789012345678901234567890"));
+  test(S("1234567890123456789012345678901234567890"), S("12345"), S("123456789012345678901234567890123456789012345"));
+  test(S("1234567890123456789012345678901234567890"),
+       S("12345678901234567890"),
+       S("123456789012345678901234567890123456789012345678901234567890"));
+  test(S("1234567890123456789012345678901234567890"),
+       S("1234567890123456789012345678901234567890"),
+       S("12345678901234567890123456789012345678901234567890123456789012345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
index da6fc11c14329..376637e3efc94 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
@@ -49,6 +49,10 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("abcdefghijklmnopqrst"), S("12345"));
   test(S("abcdefghijklmnopqrst"), S("1234567890"));
   test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+  test(S("abcdefghijklmnopqrst123456LONG1234567890"), S(""));
+  test(S("abcdefghijklmnopqrst123456LONG1234567890"), S("12345"));
+  test(S("abcdefghijklmnopqrst123456LONG1234567890"), S("1234567890"));
+  test(S("abcdefghijklmnopqrst123456LONG1234567890"), S("12345678901234567890"));
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
index 83cfa8737408c..9b8b7a8a223d8 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -102,6 +102,15 @@ TEST_CONSTEXPR_CXX20 void test_string() {
   test(S("ktsrmnqagdecfhijpobl"), 19, 1);
   test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
   test(S("dplqartnfgejichmoskb"), 21, 0);
+  test(S("gbmetiprqdoasckjfhlnxx"), 0, 22);
+  test(S("gbmetiprqdoasckjfhlnxa"), 0, 8);
+  test(S("gbmetiprqdoasckjfhlnxb"), 1, 0);
+  test(S("LONGtiprqdoasckjfhlnxxo"), 0, 23);
+  test(S("LONGtiprqdoasckjfhlnxap"), 0, 8);
+  test(S("LONGtiprqdoasckjfhlnxbl"), 1, 0);
+  test(S("LONGtiprqdoasckjfhlnxxyy"), 0, 24);
+  test(S("LONGtiprqdoasckjfhlnxxyr"), 0, 8);
+  test(S("LONGtiprqdoasckjfhlnxxyz"), 1, 0);
 }
 
 TEST_CONSTEXPR_CXX20 bool test() {



More information about the libcxx-commits mailing list