refactor: start to refactor project
This commit is contained in:
49
testbench/yycc/constraint.cpp
Normal file
49
testbench/yycc/constraint.cpp
Normal 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());
|
||||
}
|
||||
|
||||
}
|
5
testbench/yycc/constraint/builder.cpp
Normal file
5
testbench/yycc/constraint/builder.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace yycctest::constraint::builder {
|
||||
|
||||
}
|
2
testbench/yycc/string.cpp
Normal file
2
testbench/yycc/string.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
namespace yycctest::string {}
|
37
testbench/yycc/string/op.cpp
Normal file
37
testbench/yycc/string/op.cpp
Normal 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) {
|
||||
|
||||
}
|
||||
|
||||
}
|
6
testbench/yycc/string/reinterpret.cpp
Normal file
6
testbench/yycc/string/reinterpret.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
|
||||
namespace yycctest::string::reinterpret {
|
||||
|
||||
}
|
Reference in New Issue
Block a user