mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-03 08:20:28 +00:00
append test is better
This modifies the new test we introduced to also run on std::string, but it just does the append without expecting anything about how its data is stored. We also check that the string has the right value afterwards.
This commit is contained in:
parent
13fe4849e9
commit
cd5e646b74
1 changed files with 19 additions and 9 deletions
|
@ -353,19 +353,29 @@ main()
|
|||
return 78;
|
||||
}
|
||||
|
||||
if constexpr (!std::is_same_v<ctl::string, std::string>) {
|
||||
// tests the small-string optimization on ctl::string
|
||||
{
|
||||
ctl::string s;
|
||||
char *d = s.data();
|
||||
for (int i = 0; i < 23; ++i) {
|
||||
if constexpr (!std::is_same_v<ctl::string, std::string>) {
|
||||
// tests the small-string optimization on ctl::string
|
||||
char *d = s.data();
|
||||
for (int i = 0; i < 23; ++i) {
|
||||
s.append('a');
|
||||
if (s.data() != d) {
|
||||
return 79 + i;
|
||||
}
|
||||
}
|
||||
s.append('a');
|
||||
if (s.data() != d) {
|
||||
return 79 + i;
|
||||
if (s.data() == d) {
|
||||
return 103;
|
||||
}
|
||||
} else {
|
||||
// just check that append in a loop works
|
||||
for (int i = 0; i < 24; ++i) {
|
||||
s.append('a');
|
||||
}
|
||||
}
|
||||
s.append('a');
|
||||
if (s.data() == d) {
|
||||
return 103;
|
||||
if (s != "aaaaaaaaaaaaaaaaaaaaaaaa") {
|
||||
return 104;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue