#define STRINGBUILDER_IMPLEMENTATION #include "../include/stringbuilder.h" #include #define PRINTF(sb) printf("jac_sb { .data = \"%s\", .size = %zu, .cap = %zu }\n", sb.data, sb.size, sb.cap) int main() { jac_sb sb = jac_sb_from_buf("Hello, world!"); PRINTF(sb); for (size_t i = 0; i < 10; ++i) { jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); jac_sb_append_buf(&sb, " Actually this is a very long sentence that will probably cause several reallocations "); } // PRINTF(sb); jac_sb_free(sb); sb = jac_sb_empty(); jac_sb_append_buf(&sb, ""); for (size_t i = 0; i < 2048; ++i) jac_sb_putc(&sb, 69); PRINTF(sb); if (sb.size != 3088 || sb.cap != 4096) return 1; jac_sb_free(sb); return 0; }