Skip to content

Commit b9fcdb5

Browse files
committed
fix clang-format and use do-while in ASSERT_ macro.
1 parent d085cc0 commit b9fcdb5

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

libc/test/UnitTest/Test.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@
4141
// they all provide.
4242

4343
#define ASSERT_ERRNO_EQ(VAL) \
44-
ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno)); \
45-
LIBC_NAMESPACE::libc_errno = 0
44+
do { \
45+
ASSERT_EQ(VAL, static_cast<int>(LIBC_NAMESPACE::libc_errno)); \
46+
LIBC_NAMESPACE::libc_errno = 0; \
47+
} while (0)
4648
#define ASSERT_ERRNO_SUCCESS() \
4749
ASSERT_EQ(0, static_cast<int>(LIBC_NAMESPACE::libc_errno))
4850
#define ASSERT_ERRNO_FAILURE() \
49-
ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)); \
50-
LIBC_NAMESPACE::libc_errno = 0
51+
do { \
52+
ASSERT_NE(0, static_cast<int>(LIBC_NAMESPACE::libc_errno)); \
53+
LIBC_NAMESPACE::libc_errno = 0; \
54+
} while (0)
5155

5256
#endif // LLVM_LIBC_TEST_UNITTEST_TEST_H

libc/test/src/unistd/access_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ using LlvmLibcAccessTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
2222
TEST_F(LlvmLibcAccessTest, CreateAndTest) {
2323
// The test strategy is to repeatedly create a file in different modes and
2424
// test that it is accessable in those modes but not in others.
25-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
2625
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
26+
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
2727
constexpr const char *FILENAME = "access.test";
2828
auto TEST_FILE = libc_make_test_file_path(FILENAME);
2929
int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT, S_IRWXU);

0 commit comments

Comments
 (0)