Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/Format/FormatTest.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 23,006 Lines • ▼ Show 20 Lines | TEST_F(FormatTest, AtomicQualifier) { | ||||
Style.SpacesInParentheses = false; | Style.SpacesInParentheses = false; | ||||
verifyFormat("x = ( _Atomic(uint64_t) )*a;", Style); | verifyFormat("x = ( _Atomic(uint64_t) )*a;", Style); | ||||
Style.SpacesInCStyleCastParentheses = false; | Style.SpacesInCStyleCastParentheses = false; | ||||
Style.SpacesInParentheses = true; | Style.SpacesInParentheses = true; | ||||
verifyFormat("x = (_Atomic( uint64_t ))*a;", Style); | verifyFormat("x = (_Atomic( uint64_t ))*a;", Style); | ||||
verifyFormat("x = (_Atomic( uint64_t ))&a;", Style); | verifyFormat("x = (_Atomic( uint64_t ))&a;", Style); | ||||
} | } | ||||
TEST_F(FormatTest, C11Generic) { | |||||
verifyFormat("_Generic(x, int: 1, default: 0)"); | |||||
verifyFormat("#define cbrt(X) _Generic((X), float: cbrtf, default: cbrt)(X)"); | |||||
verifyFormat("_Generic(x, const char *: 1, char *const: 16, int: 8);"); | |||||
verifyFormat("_Generic(x, int: f1, const int: f2)();"); | |||||
verifyFormat("_Generic(x, struct A: 1, void (*)(void): 2);"); | |||||
verifyFormat("_Generic(x,\n" | |||||
" float: f,\n" | |||||
" default: d,\n" | |||||
" long double: ld,\n" | |||||
" float _Complex: fc,\n" | |||||
" double _Complex: dc,\n" | |||||
" long double _Complex: ldc)"); | |||||
FormatStyle Style = getLLVMStyle(); | |||||
Style.ColumnLimit = 40; | |||||
verifyFormat("#define LIMIT_MAX(T) \\\n" | |||||
" _Generic(((T)0), \\\n" | |||||
" unsigned int: UINT_MAX, \\\n" | |||||
" unsigned long: ULONG_MAX, \\\n" | |||||
" unsigned long long: ULLONG_MAX)", | |||||
Style); | |||||
verifyFormat("_Generic(x,\n" | |||||
" struct A: 1,\n" | |||||
" void (*)(void): 2);", | |||||
Style); | |||||
Style.ContinuationIndentWidth = 2; | |||||
verifyFormat("_Generic(x,\n" | |||||
" struct A: 1,\n" | |||||
" void (*)(void): 2);", | |||||
Style); | |||||
} | |||||
TEST_F(FormatTest, AmbersandInLamda) { | TEST_F(FormatTest, AmbersandInLamda) { | ||||
// Test case reported in https://bugs.llvm.org/show_bug.cgi?id=41899 | // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=41899 | ||||
FormatStyle AlignStyle = getLLVMStyle(); | FormatStyle AlignStyle = getLLVMStyle(); | ||||
AlignStyle.PointerAlignment = FormatStyle::PAS_Left; | AlignStyle.PointerAlignment = FormatStyle::PAS_Left; | ||||
verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle); | verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle); | ||||
AlignStyle.PointerAlignment = FormatStyle::PAS_Right; | AlignStyle.PointerAlignment = FormatStyle::PAS_Right; | ||||
verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle); | verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,132 Lines • Show Last 20 Lines |