refactor: start to refactor project

This commit is contained in:
2025-06-20 23:38:34 +08:00
parent bec36b4b3c
commit df3b602110
70 changed files with 2093 additions and 779 deletions

View File

@ -0,0 +1,49 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/constraint.hpp>
#include <yycc/prelude/rust.hpp>
#define CONSTRAINT ::yycc::constraint::Constraint
namespace yycctest::constraint {
template<typename T>
bool check(const T& value) {
return false;
}
template<typename T>
T clamp(const T& value) {
return value;
}
TEST(Constraint, Normal) {
CONSTRAINT<u32> instance(check<u32>, clamp<u32>);
EXPECT_TRUE(instance.support_check());
EXPECT_TRUE(instance.support_clamp());
EXPECT_FALSE(instance.check(0));
EXPECT_EQ(instance.clamp(0), 0);
}
TEST(Constraint, SomeNone) {
{
CONSTRAINT<u32> instance(check<u32>, nullptr);
EXPECT_TRUE(instance.support_check());
EXPECT_FALSE(instance.support_clamp());
EXPECT_FALSE(instance.check(0));
}
{
CONSTRAINT<u32> instance(nullptr, clamp<u32>);
EXPECT_FALSE(instance.support_check());
EXPECT_TRUE(instance.support_clamp());
EXPECT_EQ(instance.clamp(0), 0);
}
}
TEST(Constraint, AllNone) {
CONSTRAINT<u32> instance(nullptr, nullptr);
EXPECT_FALSE(instance.support_check());
EXPECT_FALSE(instance.support_clamp());
}
}

View File

@ -0,0 +1,5 @@
#include <gtest/gtest.h>
namespace yycctest::constraint::builder {
}

View File

@ -0,0 +1,2 @@
namespace yycctest::string {}

View File

@ -0,0 +1,37 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/string/op.hpp>
#include <yycc/string/reinterpret.hpp>
#define OP ::yycc::string::op
namespace yycctest::string::op {
TEST(StringOp, Printf) {
auto rv = OP::printf(YYCC_U8("%s == %s"), YYCC_U8("Hello World"), YYCC_U8("Hello, world"));
EXPECT_EQ(rv, YYCC_U8("Hello World == Hello, world"));
}
TEST(StringOp, Replace) {
}
TEST(StringOp, Lower) {
auto rv = OP::lower(YYCC_U8("LOWER"));
EXPECT_EQ(rv, YYCC_U8("lower"));
}
TEST(StringOp, Upper) {
auto rv = OP::upper(YYCC_U8("upper"));
EXPECT_EQ(rv, YYCC_U8("UPPER"));
}
TEST(StringOp, Join) {
}
TEST(StringOp, Split) {
}
}

View File

@ -0,0 +1,6 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
namespace yycctest::string::reinterpret {
}