Don't require including std::string

Also runs the test file through clang-format.
This commit is contained in:
Jōshin 2024-06-06 21:57:08 -07:00
parent cd5e646b74
commit 8d4158571d
No known key found for this signature in database

View file

@ -18,12 +18,13 @@
#include "ctl/string.h" #include "ctl/string.h"
#include <__type_traits/is_same.h>
#include <__utility/move.h> #include <__utility/move.h>
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include <string> // #include <string>
// #define ctl std // #define ctl std
int int
@ -312,7 +313,7 @@ main()
s.append(" world"); s.append(" world");
} }
if (s != "hello world world world world world world world world world " if (s != "hello world world world world world world world world world "
"world world") { "world world") {
return 64; return 64;
} }
} }
@ -355,9 +356,10 @@ main()
{ {
ctl::string s; ctl::string s;
if constexpr (!std::is_same_v<ctl::string, std::string>) { #undef ctl
if constexpr (std::is_same_v<ctl::string, decltype(s)>) {
// tests the small-string optimization on ctl::string // tests the small-string optimization on ctl::string
char *d = s.data(); char* d = s.data();
for (int i = 0; i < 23; ++i) { for (int i = 0; i < 23; ++i) {
s.append('a'); s.append('a');
if (s.data() != d) { if (s.data() != d) {