src: misc cleanups
This commit is contained in:
parent
dadee7acfb
commit
2578102be9
@ -377,6 +377,9 @@ private:
|
||||
|
||||
|
||||
namespace compile_time {
|
||||
constexpr size_t string_len(const char *a) {
|
||||
return *a == '\0' ? 0 : 1 + string_len(a + 1);
|
||||
}
|
||||
constexpr bool string_eq(const char *a, const char *b) {
|
||||
return *a == *b && (*a == '\0' || string_eq(a + 1, b + 1));
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
#if defined(DOCTEST_CONFIG_DISABLE)
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
return 0;
|
||||
#else
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (e && e[0] && strcmp(e, "0") != 0)
|
||||
@ -72,8 +73,8 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
return 1;
|
||||
if (context.shouldExit())
|
||||
return 2;
|
||||
#endif // DOCTEST_CONFIG_DISABLE
|
||||
return 0;
|
||||
#endif // DOCTEST_CONFIG_DISABLE
|
||||
}
|
||||
|
||||
int upx_doctest_check() { return upx_doctest_check(0, nullptr); }
|
||||
@ -98,6 +99,9 @@ ACC_COMPILE_TIME_ASSERT_HEADER(bswap32(0x04030201) == 0x01020304)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(bswap64(0x0807060504030201ull) == 0x0102030405060708ull)
|
||||
#endif
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("") == 0)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("a") == 1)
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_eq("", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("a", ""))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("", "a"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user