Skip to content

Commit 6d73c0a

Browse files
committed
tests
1 parent 8bb772d commit 6d73c0a

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎test/testclass.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class TestClass : public TestFixture {
199199
TEST_CASE(const100);
200200
TEST_CASE(const101);
201201
TEST_CASE(const102);
202+
TEST_CASE(const103);
202203

203204
TEST_CASE(const_handleDefaultParameters);
204205
TEST_CASE(const_passThisToMemberOfOtherClass);
@@ -7045,6 +7046,15 @@ class TestClass : public TestFixture {
70457046
errout_str());
70467047
}
70477048

7049+
void const103() {
7050+
checkConst("constexpr int BITS{4};\n"
7051+
"struct Struct {\n"
7052+
" unsigned int data() const { return m_data; }\n"
7053+
" unsigned int m_data : BITS;\n"
7054+
"};\n");
7055+
ASSERT_EQUALS("", errout_str());
7056+
}
7057+
70487058
void const_handleDefaultParameters() {
70497059
checkConst("struct Foo {\n"
70507060
" void foo1(int i, int j = 0) {\n"

‎test/testtokenize.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class TestTokenizer : public TestFixture {
342342
TEST_CASE(bitfields19); // ticket #13733
343343
TEST_CASE(bitfields20);
344344
TEST_CASE(bitfields21);
345+
TEST_CASE(bitfields22);
345346

346347
TEST_CASE(simplifyNamespaceStd);
347348

@@ -5371,6 +5372,14 @@ class TestTokenizer : public TestFixture {
53715372
ASSERT_EQUALS(1, b->bits());
53725373
}
53735374

5375+
void bitfields22() {
5376+
const char code[] = "constexpr int BITS{4};\n"
5377+
"struct Struct { unsigned int m_data : BITS; };\n";
5378+
const char expected[] = "constexpr int BITS { 4 } ;\n"
5379+
"struct Struct { unsigned int m_data ; } ;";
5380+
ASSERT_EQUALS(expected, tokenizeAndStringify(code));
5381+
}
5382+
53745383
void simplifyNamespaceStd() {
53755384
const char *expected;
53765385

0 commit comments

Comments
 (0)