tests: move tests for PROTECT_ERRNO to the right file

Also, rename them to uppercase so that the test name matches what we're
actually testing.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-11-06 17:15:56 +01:00
parent 2ba6823716
commit 737f274e1e
2 changed files with 31 additions and 31 deletions

View File

@@ -47,4 +47,35 @@ TEST(STRERROR_OR_ELSE) {
log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM));
}
TEST(PROTECT_ERRNO) {
errno = 12;
{
PROTECT_ERRNO;
errno = 11;
}
assert_se(errno == 12);
}
static void test_unprotect_errno_inner_function(void) {
PROTECT_ERRNO;
errno = 2222;
}
TEST(UNPROTECT_ERRNO) {
errno = 4711;
PROTECT_ERRNO;
errno = 815;
UNPROTECT_ERRNO;
assert_se(errno == 4711);
test_unprotect_errno_inner_function();
assert_se(errno == 4711);
}
DEFINE_TEST_MAIN(LOG_INFO);

View File

@@ -83,37 +83,6 @@ TEST(log2i) {
assert_se(log2i(INT_MAX) == sizeof(int)*8-2);
}
TEST(protect_errno) {
errno = 12;
{
PROTECT_ERRNO;
errno = 11;
}
assert_se(errno == 12);
}
static void test_unprotect_errno_inner_function(void) {
PROTECT_ERRNO;
errno = 2222;
}
TEST(unprotect_errno) {
errno = 4711;
PROTECT_ERRNO;
errno = 815;
UNPROTECT_ERRNO;
assert_se(errno == 4711);
test_unprotect_errno_inner_function();
assert_se(errno == 4711);
}
TEST(eqzero) {
const uint32_t zeros[] = {0, 0, 0};
const uint32_t ones[] = {1, 1};