module; export module lsp.test.lsp_any.common; import std; import lsp.test.framework; import lsp.protocol.common.basic_types; import lsp.codec.common; export namespace lsp::test { namespace transform = lsp::codec; class CommonTests { public: static void registerTests(TestRunner& runner); private: static TestResult testIsLSPBasicInteger(); static TestResult testIsLSPBasicUInteger(); static TestResult testIsLSPBasicBoolean(); static TestResult testIsLSPBasicString(); static TestResult testIsLSPBasicDecimal(); static TestResult testIsLSPBasicNullptr(); static TestResult testIsLSPBasicNegativeCases(); static TestResult testIsLSPContainerObject(); static TestResult testIsLSPContainerArray(); static TestResult testIsLSPContainerAny(); static TestResult testIsLSPContainerNegativeCases(); static TestResult testIsUserStructPositive(); static TestResult testIsUserStructExcludeArithmetic(); static TestResult testIsUserStructExcludeString(); static TestResult testIsUserStructExcludeLSPTypes(); static TestResult testIsUserStructExcludeVector(); static TestResult testIsUserStructExcludeMap(); static TestResult testIsUserStructExcludeOptional(); static TestResult testIsUserStructExcludeVariant(); static TestResult testIsUserStructExcludePointers(); }; } namespace lsp::test { struct UserStruct { int value; std::string name; }; void CommonTests::registerTests(TestRunner& runner) { runner.addTest("Common - is_lsp_basic_type (integer)", testIsLSPBasicInteger); runner.addTest("Common - is_lsp_basic_type (uinteger)", testIsLSPBasicUInteger); runner.addTest("Common - is_lsp_basic_type (boolean)", testIsLSPBasicBoolean); runner.addTest("Common - is_lsp_basic_type (string)", testIsLSPBasicString); runner.addTest("Common - is_lsp_basic_type (decimal)", testIsLSPBasicDecimal); runner.addTest("Common - is_lsp_basic_type (nullptr_t)", testIsLSPBasicNullptr); runner.addTest("Common - is_lsp_basic_type (负面案例)", testIsLSPBasicNegativeCases); runner.addTest("Common - is_lsp_container_type (LSPObject)", testIsLSPContainerObject); runner.addTest("Common - is_lsp_container_type (LSPArray)", testIsLSPContainerArray); runner.addTest("Common - is_lsp_container_type (LSPAny)", testIsLSPContainerAny); runner.addTest("Common - is_lsp_container_type (负面案例)", testIsLSPContainerNegativeCases); runner.addTest("Common - is_user_struct (用户结构体)", testIsUserStructPositive); runner.addTest("Common - is_user_struct (排除算术类型)", testIsUserStructExcludeArithmetic); runner.addTest("Common - is_user_struct (排除字符串)", testIsUserStructExcludeString); runner.addTest("Common - is_user_struct (排除LSP类型)", testIsUserStructExcludeLSPTypes); runner.addTest("Common - is_user_struct (排除vector)", testIsUserStructExcludeVector); runner.addTest("Common - is_user_struct (排除map)", testIsUserStructExcludeMap); runner.addTest("Common - is_user_struct (排除optional)", testIsUserStructExcludeOptional); runner.addTest("Common - is_user_struct (排除variant)", testIsUserStructExcludeVariant); runner.addTest("Common - is_user_struct (排除指针)", testIsUserStructExcludePointers); } TestResult CommonTests::testIsLSPBasicInteger() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "integer应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicUInteger() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "uinteger应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicBoolean() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "boolean应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicString() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "string应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicDecimal() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "decimal应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicNullptr() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_basic_type_v, "nullptr应该是LSP基本类型"); return result; } TestResult CommonTests::testIsLSPBasicNegativeCases() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_lsp_basic_type_v>, "vector不应是基本类型"); assertFalse(transform::is_lsp_basic_type_v, "用户结构体不应是基本类型"); return result; } TestResult CommonTests::testIsLSPContainerObject() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_container_type_v, "LSPObject应该是容器类型"); return result; } TestResult CommonTests::testIsLSPContainerArray() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_container_type_v, "LSPArray应该是容器类型"); return result; } TestResult CommonTests::testIsLSPContainerAny() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_lsp_container_type_v, "LSPAny应该是容器类型"); return result; } TestResult CommonTests::testIsLSPContainerNegativeCases() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_lsp_container_type_v, "int不是容器类型"); assertFalse(transform::is_lsp_container_type_v>, "vector不是容器类型"); return result; } TestResult CommonTests::testIsUserStructPositive() { TestResult result{ "", true, "成功" }; assertTrue(transform::is_user_struct_v, "UserStruct应该被识别为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeArithmetic() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v, "int不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeString() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v, "string不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeLSPTypes() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v, "LSPAny不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeVector() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v>, "vector不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeMap() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v>, "map不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeOptional() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v>, "optional不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludeVariant() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v>, "variant不应被视为用户结构体"); return result; } TestResult CommonTests::testIsUserStructExcludePointers() { TestResult result{ "", true, "成功" }; assertFalse(transform::is_user_struct_v, "指针不应被视为用户结构体"); return result; } }