Last active
July 1, 2021 11:44
-
-
Save tylov/08590082975a7ef45bf20abf96b0da8c to your computer and use it in GitHub Desktop.
Small test for sso_string.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "sso_string.h" | |
#include <stdio.h> | |
void print(string s) { | |
printf("short: %d, %s: %u %u\n", !string_is_long(&s), string_str(&s), string_size(s), string_capacity(s)); | |
} | |
int main() | |
{ | |
string s1 = string_lit("Hello!"); | |
string s2 = string_lit("Is this a short string?"); | |
string s3 = string_lit("Yes, but this is a long string!"); | |
printf("%zu %d\n", sizeof s1, SSO_CAP); | |
print(s1); | |
print(s2); | |
print(s3); | |
string_append_s(&s1, s1); | |
print(s1); | |
string_replace(&s1, 1, 2, "a"); | |
print(s1); | |
string_append(&s1, string_str(&s1)); | |
print(s1); | |
string_shrink_to_fit(&s1); | |
print(s1); | |
string_assign_n(&s2, string_str(&s2) + 8, 14); | |
print(s2); | |
string_resize(&s2, 25, '?'); | |
print(s2); | |
string_del(&s1); | |
string_del(&s2); | |
string_del(&s3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment