Skip to content

Commit d657994

Browse files
committed
Add test
1 parent e06e98f commit d657994

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/testtokenize.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class TestTokenizer : public TestFixture {
292292

293293
TEST_CASE(attributeAlignasBefore);
294294
TEST_CASE(attributeAlignasAfter);
295+
TEST_CASE(simplifyAlignedStorage);
295296

296297
TEST_CASE(splitTemplateRightAngleBrackets);
297298

@@ -4379,6 +4380,21 @@ class TestTokenizer : public TestFixture {
43794380
ASSERT_EQUALS(var->getAttributeAlignas()[0], "long");
43804381
}
43814382

4383+
void simplifyAlignedStorage() {
4384+
const char code[] = "std::aligned_storage<sizeof(long), alignof(long)>::type buffer;";
4385+
const char expected[] = "std :: aligned_storage < sizeof ( long ) , alignof ( long ) > :: type buffer ;";
4386+
4387+
SimpleTokenizer tokenizer(settings2, *this);
4388+
ASSERT(tokenizer.tokenize(code));
4389+
4390+
ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false));
4391+
4392+
const Token *buffer = Token::findsimplematch(tokenizer.tokens(), "buffer");
4393+
ASSERT(buffer);
4394+
ASSERT(buffer->hasAttributeAlignas());
4395+
ASSERT_EQUALS("alignof ( long )", buffer->getAttributeAlignas()[0]);
4396+
}
4397+
43824398
void splitTemplateRightAngleBrackets() {
43834399
{
43844400
const char code[] = "; z = x < 0 ? x >> y : x >> y;";

0 commit comments

Comments
 (0)