From f901a575a58ba151b1b37fa482aa7bb3968ffa44 Mon Sep 17 00:00:00 2001 From: killcerr <93478098+killcerr@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:44:24 +0800 Subject: [PATCH] feat: test --- test/test.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/test.cpp diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 0000000..a0a73c1 --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,49 @@ + +#include "../CTCompare.hpp" + +#include "../CTStr.hpp" +bool test_CTSTR() { + CTC::CTStr a{"123"}; + CTC::CTStr b{"123"}; + CTC::CTStr c{"1234"}; + return a == b && b != c; +} +#include "../CTCStr.hpp" +bool test_CTCSTR() { + CTC::CTCStr a{"123"}; + CTC::CTCStr b{"123"}; + CTC::CTCStr c{"1234"}; + return a == b && b != c; +} +bool test_STR() { + CTC::CTCStr a{"123"}; + CTC::CTStr b{"123"}; + CTC::CTCStr c{"1234"}; + return a == b && b != c; +} +#include "../CTVec.hpp" +bool test_CTVEC() { + CTC::CTVec a{1, 2, 3}; + CTC::CTVec b{1, 2, 3}; + CTC::CTVec c{1, 2, 3, 4}; + return a == b && b != c; +} +#include "../CTDArray.hpp" +consteval bool test_CTDARRAY() { + CTC::CTDArray a{1}; + a.push_back(1); + a.pop_back(); + return a.size() == 1; +} +#include "../Type.hpp" +bool test_TYPE() { return CTC::name_of() == CTC::CTCStr{"int"} && CTC::hash_of() != CTC::hash_of(); } +#include "../Any.hpp" +consteval bool test_ANY() { + CTC::Any a(0); + return a.cast_to_ref() == 0; +} +int main() { + return test_CTSTR() && test_CTCSTR() && test_STR() && test_CTVEC() && test_CTDARRAY() && test_TYPE() && test_ANY() + ? 0 + : 1; +}