aoc-2025/libguf/test/test_str.hpp
2025-12-23 21:13:41 +01:00

34 lines
1.0 KiB
C++
Executable File

#pragma once
#include <vector>
#include <string>
#include "test.hpp"
extern "C"
{
#include "guf_str.h"
#include "guf_alloc_libc.h"
}
struct StrTest : public Test
{
StrTest(const std::string& nm) : Test(nm)
{
allocator_ctx.zero_init = false;
guf_alloc_tracker_init(&allocator_ctx.tracker, 4, "StrTest_allocator", NULL, NULL);
guf_libc_allocator_init(&allocator, &allocator_ctx);
};
void run() override;
private:
guf_allocator allocator;
guf_libc_alloc_ctx allocator_ctx;
void test_init_free(std::string str);
void test_init_empty();
void test_append_char(std::string str, bool include_null = false);
void append_str(const std::string& a, const std::string& b);
std::vector<std::string_view> test_popsplit(std::string_view str, std::string_view delim);
std::vector<std::string_view> get_toks(std::string_view sv_in, const std::vector<std::string_view>& delims_in, bool preserve_delims = false, guf_str_tok_delim_opt opt = GUF_STR_TOK_DELIM_OPT_MATCH_LONGEST);
};