diff --git a/src/yycc/macro/stl_detector.hpp b/src/yycc/macro/stl_detector.hpp index cfddda9..c7c616c 100644 --- a/src/yycc/macro/stl_detector.hpp +++ b/src/yycc/macro/stl_detector.hpp @@ -17,9 +17,9 @@ namespace yycc::macro::stl { /// @brief The STL implementation kind. enum class StlKind { - MSSTL, ///< Microsoft STL - GNUSTL, ///< GNU STL - CLANGSTL ///< Clang STL + MsStl, ///< Microsoft STL + GnuStl, ///< GNU STL + ClangStl ///< Clang STL }; /** @@ -28,11 +28,11 @@ namespace yycc::macro::stl { */ inline constexpr StlKind get_stl() { #if defined(YYCC_STL_MSSTL) - return StlKind::MSSTL; + return StlKind::MsStl; #elif defined(YYCC_STL_GNUSTL) - return StlKind::GNUSTL; + return StlKind::GnuStl; #else - return StlKind::CLANGSTL; + return StlKind::ClangStl; #endif } diff --git a/testbench/CMakeLists.txt b/testbench/CMakeLists.txt index 9a731b6..582f773 100644 --- a/testbench/CMakeLists.txt +++ b/testbench/CMakeLists.txt @@ -7,6 +7,11 @@ PRIVATE main.cpp yycc/macro/version_cmp.cpp + yycc/macro/os_detector.cpp + yycc/macro/compiler_detector.cpp + yycc/macro/endian_detector.cpp + yycc/macro/ptr_size_detector.cpp + yycc/macro/stl_detector.cpp yycc/flag_enum.cpp yycc/constraint.cpp yycc/constraint/builder.cpp diff --git a/testbench/yycc/macro/compiler_detector.cpp b/testbench/yycc/macro/compiler_detector.cpp new file mode 100644 index 0000000..0e41e67 --- /dev/null +++ b/testbench/yycc/macro/compiler_detector.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +#define COMPILER ::yycc::macro::compiler + +namespace yycctest::macro::compiler { + + TEST(MacroCompiler, Main) { + auto rv = COMPILER::get_compiler(); +#if defined(YYCC_CC_MSVC) + EXPECT_EQ(rv, COMPILER::CompilerKind::Msvc); +#elif defined(YYCC_CC_GCC) + EXPECT_EQ(rv, COMPILER::CompilerKind::Gcc); +#else + EXPECT_EQ(rv, COMPILER::CompilerKind::Clang); +#endif + } + +} // namespace yycctest::macro::compiler diff --git a/testbench/yycc/macro/endian_detector.cpp b/testbench/yycc/macro/endian_detector.cpp new file mode 100644 index 0000000..dda289f --- /dev/null +++ b/testbench/yycc/macro/endian_detector.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +#define ENDIAN ::yycc::macro::endian + +namespace yycctest::macro::endian { + + TEST(MacroEndian, Main) { + auto rv = ENDIAN::get_endian(); +#if defined(YYCC_ENDIAN_LITTLE) + EXPECT_EQ(rv, ENDIAN::EndianKind::Little); +#else + EXPECT_EQ(rv, ENDIAN::EndianKind::Big); +#endif + } + +} // namespace yycctest::macro::endian diff --git a/testbench/yycc/macro/os_detector.cpp b/testbench/yycc/macro/os_detector.cpp new file mode 100644 index 0000000..9b7fecf --- /dev/null +++ b/testbench/yycc/macro/os_detector.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +#define OS ::yycc::macro::os + +namespace yycctest::macro::os { + + TEST(MacroOs, Main) { + auto rv = OS::get_os(); +#if defined(YYCC_OS_WINDOWS) + EXPECT_EQ(rv, OS::OsKind::Windows); +#elif defined(YYCC_OS_LINUX) + EXPECT_EQ(rv, OS::OsKind::Linux); +#else + EXPECT_EQ(rv, OS::OsKind::MacOs); +#endif + } + +} // namespace yycctest::macro::os diff --git a/testbench/yycc/macro/ptr_size_detector.cpp b/testbench/yycc/macro/ptr_size_detector.cpp new file mode 100644 index 0000000..ce313c2 --- /dev/null +++ b/testbench/yycc/macro/ptr_size_detector.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +#define PTR_SIZE ::yycc::macro::ptr_size + +namespace yycctest::macro::ptr_size { + + TEST(MacroPtrSize, Main) { + auto rv = PTR_SIZE::get_ptr_size(); +#if defined(YYCC_PTRSIZE_32) + EXPECT_EQ(rv, PTR_SIZE::PtrSizeKind::Bits32); +#else + EXPECT_EQ(rv, PTR_SIZE::PtrSizeKind::Bits64); +#endif + } + +} // namespace yycctest::macro::ptr_size diff --git a/testbench/yycc/macro/stl_detector.cpp b/testbench/yycc/macro/stl_detector.cpp new file mode 100644 index 0000000..b08c57c --- /dev/null +++ b/testbench/yycc/macro/stl_detector.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +#define STL ::yycc::macro::stl + +namespace yycctest::macro::stl { + + TEST(MacroStl, Main) { + auto rv = STL::get_stl(); +#if defined(YYCC_STL_MSSTL) + EXPECT_EQ(rv, STL::StlKind::MsStl); +#elif defined(YYCC_STL_GNUSTL) + EXPECT_EQ(rv, STL::StlKind::GnuStl); +#else + EXPECT_EQ(rv, STL::StlKind::ClangStl); +#endif + } + +} // namespace yycctest::macro::stl