refactor: rename testbench to test.
- rename testbench to test. - add benchmark for future development.
This commit is contained in:
20
test/yycc/macro/compiler_detector.cpp
Normal file
20
test/yycc/macro/compiler_detector.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/compiler_detector.hpp>
|
||||
|
||||
#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
|
18
test/yycc/macro/endian_detector.cpp
Normal file
18
test/yycc/macro/endian_detector.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/endian_detector.hpp>
|
||||
|
||||
#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
|
20
test/yycc/macro/os_detector.cpp
Normal file
20
test/yycc/macro/os_detector.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/os_detector.hpp>
|
||||
|
||||
#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
|
18
test/yycc/macro/ptr_size_detector.cpp
Normal file
18
test/yycc/macro/ptr_size_detector.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/ptr_size_detector.hpp>
|
||||
|
||||
#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
|
20
test/yycc/macro/stl_detector.cpp
Normal file
20
test/yycc/macro/stl_detector.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/stl_detector.hpp>
|
||||
|
||||
#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
|
31
test/yycc/macro/version_cmp.cpp
Normal file
31
test/yycc/macro/version_cmp.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <yycc.hpp>
|
||||
#include <yycc/macro/version_cmp.hpp>
|
||||
|
||||
namespace yycctest::macro::version_cmp {
|
||||
|
||||
TEST(MacroVersionCmp, Same) {
|
||||
// Test for same version.
|
||||
EXPECT_TRUE(YYCC_VERCMP_E(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_FALSE(YYCC_VERCMP_NE(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_FALSE(YYCC_VERCMP_G(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_TRUE(YYCC_VERCMP_GE(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_TRUE(YYCC_VERCMP_NL(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_FALSE(YYCC_VERCMP_L(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_TRUE(YYCC_VERCMP_LE(1, 2, 3, 1, 2, 3));
|
||||
EXPECT_TRUE(YYCC_VERCMP_NG(1, 2, 3, 1, 2, 3));
|
||||
}
|
||||
|
||||
TEST(MacroVersionCmp, Math) {
|
||||
// In version number, 1.2.10 is greater than 1.2.9
|
||||
EXPECT_FALSE(YYCC_VERCMP_E(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_TRUE(YYCC_VERCMP_NE(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_TRUE(YYCC_VERCMP_G(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_TRUE(YYCC_VERCMP_GE(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_TRUE(YYCC_VERCMP_NL(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_FALSE(YYCC_VERCMP_L(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_FALSE(YYCC_VERCMP_LE(1, 2, 10, 1, 2, 9));
|
||||
EXPECT_FALSE(YYCC_VERCMP_NG(1, 2, 10, 1, 2, 9));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user