Skip to content

Commit

Permalink
adding more tests for std::string on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Nyarko authored and Emmanuel Nyarko committed Feb 11, 2024
1 parent 00d78a1 commit 25167bd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions source/stdcpp/test/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ unittest
assert(a.back() == 'a');
a.resize(4); // shrinks a to "hell"
assert(a.size() == 4);
auto b = std_string("Hi, this is a test for string capacity growth for a length more than the base SSO");
assert(b.capacity == stringCapacity("Hi, this is a test for string capacity growth for a length more than the base SSO"));
immutable LongStr = "Hi, this is a test for string capacity growth for a length more than the base SSO";
auto b = std_string(LongStr);
assert(b.capacity == stringCapacity(LongStr.ptr));
a.swap(b); // a and b swaps
assert(a.capacity == stringCapacity("Hi, this is a test for string capacity growth for a length more than the base SSO"));
assert(a.capacity == stringCapacity(LongStr.ptr));
assert(b.capacity == stringCapacity("hell")); // a was shrinked to hell so b contains 'hell'
b.pop_back();
assert(b.size() == 3);
assert(a.empty == 0);
a.clear();
assert(a.empty == 1);

}

0 comments on commit 25167bd

Please sign in to comment.