Browse Source

test: perf exposer impl

legacy
Dnomd343 9 months ago
parent
commit
364a2bd197
  1. 8
      src/core_test/cases/all_cases.cc
  2. 8
      src/core_test/codec/short_code.cc
  3. 8
      src/core_test/ffi/all_cases.cc
  4. 8
      src/core_test/utility/exposer.h

8
src/core_test/cases/all_cases.cc

@ -23,8 +23,8 @@ static constexpr std::array<uint64_t, 16> ALL_CASES_XXH3 = {
};
/// Forcibly modify private variables to reset state.
PRIVATE_ACCESS(AllCases, available_, bool)
PRIVATE_ACCESS(BasicRanges, available_, bool)
FORCIBLY_ACCESS(AllCases, available_, bool)
FORCIBLY_ACCESS(BasicRanges, available_, bool)
class BR_Test final {
public:
@ -36,7 +36,7 @@ public:
/// Reset basic ranges build state, note it is thread-unsafe.
static void reset() {
access_BasicRanges_available_(BasicRanges::instance()) = false;
exposer::BasicRanges_available_(BasicRanges::instance()) = false;
}
/// Verify that whether basic ranges data is correct.
@ -55,7 +55,7 @@ public:
/// Reset all cases build state, note it is thread-unsafe.
static void reset() {
access_AllCases_available_(AllCases::instance()) = false;
exposer::AllCases_available_(AllCases::instance()) = false;
}
/// Verify that whether all cases data is correct.

8
src/core_test/codec/short_code.cc

@ -21,17 +21,17 @@ using klotski::codec::SHORT_CODE_LIMIT;
static const auto TEST_THREAD_NUM = 256;
/// Forcibly modify private variables to reset state.
PRIVATE_ACCESS(AllCases, available_, bool)
PRIVATE_ACCESS(BasicRanges, available_, bool)
FORCIBLY_ACCESS(AllCases, available_, bool)
FORCIBLY_ACCESS(BasicRanges, available_, bool)
/// Reset basic ranges build state, note it is thread-unsafe.
void basic_ranges_reset() {
access_BasicRanges_available_(BasicRanges::instance()) = false;
exposer::BasicRanges_available_(BasicRanges::instance()) = false;
}
/// Reset all cases build state, note it is thread-unsafe.
void all_cases_reset() {
access_AllCases_available_(AllCases::instance()) = false;
exposer::AllCases_available_(AllCases::instance()) = false;
}
TEST(ShortCode, limit) {

8
src/core_test/ffi/all_cases.cc

@ -18,17 +18,17 @@ using klotski::cases::ALL_CASES_NUM;
static const std::string ALL_CASES_MD5 = "3888e9fab8d3cbb50908b12b147cfb23";
/// Forcibly modify private variables to reset state.
PRIVATE_ACCESS(AllCases, available_, bool)
PRIVATE_ACCESS(BasicRanges, available_, bool)
FORCIBLY_ACCESS(AllCases, available_, bool)
FORCIBLY_ACCESS(BasicRanges, available_, bool)
/// Reset basic ranges build state, note it is thread-unsafe.
void basic_ranges_reset() {
access_BasicRanges_available_(BasicRanges::instance()) = false;
exposer::BasicRanges_available_(BasicRanges::instance()) = false;
}
/// Reset all cases build state, note it is thread-unsafe.
void all_cases_reset() {
access_AllCases_available_(AllCases::instance()) = false;
exposer::AllCases_available_(AllCases::instance()) = false;
}
TEST(AllCases, all_cases_prebuild) {

8
src/core_test/utility/exposer.h

@ -26,8 +26,10 @@ typename ExposerImpl<T, Ptr>::Factory ExposerImpl<T, Ptr>::factory;
} // namespace exposer
#define PRIVATE_ACCESS(Class, Member, Type) \
template struct ::exposer::ExposerImpl<decltype(&Class::Member), &Class::Member>; \
Type& access_##Class##_##Member(Class &T) { \
#define FORCIBLY_ACCESS(Class, Member, Type) \
namespace exposer { \
template struct ExposerImpl<decltype(&Class::Member), &Class::Member>; \
inline auto& Class##_##Member(Class &T) { \
return T.*exposer::Exposer<Type Class::*>::ptr; \
} \
}

Loading…
Cancel
Save