Skip to content

Commit 0783e47

Browse files
committed
Convert org.eclipse.cdt.core.parser.tests.ast2.SemanticTestBase to JUnit5
SemanticTestBase is the base class for a huge hierarchy of tests and all those test updates are included in this commit.
1 parent 6574af3 commit 0783e47

File tree

93 files changed

+3787
-922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+3787
-922
lines changed

core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java

Lines changed: 61 additions & 13 deletions
Large diffs are not rendered by default.

core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
*******************************************************************************/
1717
package org.eclipse.cdt.core.parser.tests.ast2;
1818

19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
import static org.junit.jupiter.api.Assertions.assertFalse;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
import static org.junit.jupiter.api.Assertions.assertSame;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
1925
import java.io.IOException;
2026

2127
import org.eclipse.cdt.core.dom.ast.IASTImplicitDestructorName;
@@ -31,26 +37,14 @@
3137
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
3238
import org.eclipse.cdt.core.parser.ParserLanguage;
3339
import org.eclipse.cdt.internal.core.parser.ParserException;
34-
35-
import junit.framework.TestSuite;
40+
import org.junit.jupiter.api.Test;
3641

3742
/**
3843
* Tests for classes implementing {@link IASTImplicitNameOwner} and {@link IASTImplicitDestructorNameOwner}
3944
* interfaces.
4045
*/
4146
public class AST2CPPImplicitNameTests extends AST2TestBase {
4247

43-
public AST2CPPImplicitNameTests() {
44-
}
45-
46-
public AST2CPPImplicitNameTests(String name) {
47-
super(name);
48-
}
49-
50-
public static TestSuite suite() {
51-
return suite(AST2CPPImplicitNameTests.class);
52-
}
53-
5448
protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException {
5549
String code = getAboveComment();
5650
return new AST2AssertionHelper(code, ParserLanguage.CPP);
@@ -103,6 +97,7 @@ protected IASTImplicitDestructorName[] getImplicitDestructorNames(IASTTranslatio
10397
// -p;
10498
// +p;
10599
// }
100+
@Test
106101
public void testBinaryExpressions() throws Exception {
107102
BindingAssertionHelper ba = getAssertionHelper();
108103
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -147,6 +142,7 @@ public void testBinaryExpressions() throws Exception {
147142
// int* y;
148143
// *y; //2
149144
// }
145+
@Test
150146
public void testPointerDereference() throws Exception {
151147
BindingAssertionHelper ba = getAssertionHelper();
152148
ba.assertImplicitName("*x;", 1, ICPPFunction.class);
@@ -165,6 +161,7 @@ public void testPointerDereference() throws Exception {
165161
// X (Y::*px1) = &Y::x; // not the overloaded operator
166162
// X* px2 = &y; // overloaded
167163
// }
164+
@Test
168165
public void testPointerToMember() throws Exception {
169166
BindingAssertionHelper ba = getAssertionHelper();
170167
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -198,6 +195,7 @@ public void testPointerToMember() throws Exception {
198195
// SecondLevelProxy p2;
199196
// p2->doA();
200197
// }
198+
@Test
201199
public void testArrowOperator() throws Exception {
202200
String contents = getAboveComment();
203201
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
@@ -226,6 +224,7 @@ public void testArrowOperator() throws Exception {
226224
// (p1++).x; //1
227225
// (++p1).x; //2
228226
// }
227+
@Test
229228
public void testUnaryPrefixAndPostfix() throws Exception {
230229
BindingAssertionHelper ba = getAssertionHelper();
231230
ba.assertImplicitName("++).x; //1", 2, ICPPFunction.class);
@@ -252,6 +251,7 @@ public void testUnaryPrefixAndPostfix() throws Exception {
252251
// D d;
253252
// test(a, b, c, d); // func
254253
// }
254+
@Test
255255
public void testCommaOperator1() throws Exception {
256256
BindingAssertionHelper ba = getAssertionHelper();
257257
// expression lists are used in function calls but they should not resolve to the comma operator
@@ -287,6 +287,7 @@ public void testCommaOperator1() throws Exception {
287287
// int test(A a, B b, C c, D d) {
288288
// (a, b, c, d).ee; // expr
289289
// }
290+
@Test
290291
public void testCommaOperator2() throws Exception {
291292
BindingAssertionHelper ba = getAssertionHelper();
292293

@@ -318,6 +319,7 @@ public void testCommaOperator2() throws Exception {
318319
// x(); // 2
319320
// x(1, 2); // 3
320321
// }
322+
@Test
321323
public void testFunctionCallOperator() throws Exception {
322324
BindingAssertionHelper ba = getAssertionHelper();
323325
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -359,6 +361,7 @@ public void testFunctionCallOperator() throws Exception {
359361
// B b;
360362
// b = a; // should not resolve
361363
// }
364+
@Test
362365
public void testCopyAssignmentOperator() throws Exception {
363366
BindingAssertionHelper ba = getAssertionHelper();
364367
ba.assertNoImplicitName("= a;", 1);
@@ -377,6 +380,7 @@ public void testCopyAssignmentOperator() throws Exception {
377380
// func(x[0]); //1
378381
// func(y[q]); //2
379382
// }
383+
@Test
380384
public void testArraySubscript() throws Exception {
381385
BindingAssertionHelper ba = getAssertionHelper();
382386
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -412,6 +416,7 @@ public void testArraySubscript() throws Exception {
412416
// delete[] x;
413417
// delete 1;
414418
// }
419+
@Test
415420
public void testDelete() throws Exception {
416421
BindingAssertionHelper ba = getAssertionHelper();
417422
IASTImplicitName[] names = ba.getImplicitNames("delete x;", 6);
@@ -446,6 +451,7 @@ public void testDelete() throws Exception {
446451
// B* b = new B;
447452
// delete b;
448453
// }
454+
@Test
449455
public void testOverloadedDelete_Bug351547() throws Exception {
450456
BindingAssertionHelper bh = getAssertionHelper();
451457
IBinding m = bh.assertNonProblem("operator delete(void * a)", 15);
@@ -473,6 +479,7 @@ public void testOverloadedDelete_Bug351547() throws Exception {
473479
// A *a = new A;
474480
// B* b = new B;
475481
// }
482+
@Test
476483
public void testOverloadedNew_Bug354585() throws Exception {
477484
BindingAssertionHelper bh = getAssertionHelper();
478485
IBinding m = bh.assertNonProblem("operator new(size_t a)", 12);
@@ -492,6 +499,7 @@ public void testOverloadedNew_Bug354585() throws Exception {
492499
// X* xs = new X[5];
493500
// delete[] x;
494501
// }
502+
@Test
495503
public void testImplicitNewAndDelete() throws Exception {
496504
BindingAssertionHelper ba = getAssertionHelper();
497505
ba.assertNoImplicitName("new X", 3);
@@ -511,6 +519,7 @@ public void testImplicitNewAndDelete() throws Exception {
511519
// int* p = new (nothrow) int[5];
512520
// int* p2 = new (5, 6) int[5];
513521
// }
522+
@Test
514523
public void testNew() throws Exception {
515524
BindingAssertionHelper ba = getAssertionHelper();
516525
IASTImplicitName n1 = ba.assertImplicitName("new (nothrow) X", 3, ICPPFunction.class);
@@ -529,6 +538,7 @@ public void testNew() throws Exception {
529538
// int test() {
530539
// throw;
531540
// }
541+
@Test
532542
public void testEmptyThrow() throws Exception {
533543
BindingAssertionHelper ba = getAssertionHelper();
534544
ba.assertNoImplicitName("throw;", 5);
@@ -558,6 +568,7 @@ public void testEmptyThrow() throws Exception {
558568
// C(int p) : u(), v(p) {}
559569
// };
560570
// B C::t = 1;
571+
@Test
561572
public void testConstructorCall() throws Exception {
562573
BindingAssertionHelper ba = getAssertionHelper();
563574
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -597,6 +608,7 @@ public void testConstructorCall() throws Exception {
597608
// if (aa==b) {
598609
// }
599610
// }
611+
@Test
600612
public void testBuiltinOperators_294543() throws Exception {
601613
BindingAssertionHelper ba = getAssertionHelper();
602614
IASTTranslationUnit tu = ba.getTranslationUnit();
@@ -613,6 +625,7 @@ public void testBuiltinOperators_294543() throws Exception {
613625
// int x;
614626
// x = A().a;
615627
// }
628+
@Test
616629
public void testTemporaryDestruction() throws Exception {
617630
BindingAssertionHelper ba = getAssertionHelper();
618631
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A().a");
@@ -628,6 +641,7 @@ public void testTemporaryDestruction() throws Exception {
628641
// A x;
629642
// x = A();
630643
// }
644+
@Test
631645
public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception {
632646
BindingAssertionHelper ba = getAssertionHelper();
633647
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A()");
@@ -641,6 +655,7 @@ public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception {
641655
// int test() {
642656
// return (new A())->a;
643657
// }
658+
@Test
644659
public void testTemporaryNotCreatesInNewExpression() throws Exception {
645660
BindingAssertionHelper ba = getAssertionHelper();
646661
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("(new A())->a");
@@ -654,6 +669,7 @@ public void testTemporaryNotCreatesInNewExpression() throws Exception {
654669
// void test() {
655670
// A& x = A();
656671
// }
672+
@Test
657673
public void testTemporaryBoundToReference() throws Exception {
658674
BindingAssertionHelper ba = getAssertionHelper();
659675
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("A()");
@@ -671,6 +687,7 @@ public void testTemporaryBoundToReference() throws Exception {
671687
// const S& s2 = S(1);
672688
// S s3;
673689
// }//1
690+
@Test
674691
public void testOrderOfDestruction() throws Exception {
675692
BindingAssertionHelper ba = getAssertionHelper();
676693
IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("}//1", 1);

0 commit comments

Comments
 (0)