KPN/tests/test_fixed_string.cpp
2026-05-08 17:48:16 +02:00

28 lines
833 B
C++

#include <catch2/catch_test_macros.hpp>
#include <kpn/fixed_string.hpp>
using namespace kpn;
TEST_CASE("fixed_string equality", "[fixed_string]") {
constexpr fixed_string a("img");
constexpr fixed_string b("img");
constexpr fixed_string c("sigma");
STATIC_REQUIRE(a == b);
STATIC_REQUIRE(!(a == c));
}
TEST_CASE("fixed_string view", "[fixed_string]") {
constexpr fixed_string s("hello");
REQUIRE(s.view() == "hello");
}
TEST_CASE("index_of hit", "[fixed_string]") {
constexpr auto idx = index_of<fixed_string("b"), fixed_string("a"), fixed_string("b"), fixed_string("c")>();
STATIC_REQUIRE(idx == 1);
}
TEST_CASE("index_of miss returns npos", "[fixed_string]") {
constexpr auto idx = index_of<fixed_string("z"), fixed_string("a"), fixed_string("b")>();
STATIC_REQUIRE(idx == npos);
}