Skip to main content
summaryrefslogtreecommitdiffstats
blob: d3dd2f853916f67f69c992ce97b41d7d51eed23e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*******************************************************************************
 * Copyright (c) 2011, 2012 Tomasz Wesolowski and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tomasz Wesolowski - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.ui.quickfix;

import org.eclipse.cdt.codan.internal.checkers.CatchByReference;
import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;

/**
 * @author Tomasz Wesolowski
 */
@SuppressWarnings("restriction")
public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
	@Override
	public void setUp() throws Exception {
		super.setUp();
		enableProblems(CatchByReference.ER_ID);
	}

	@Override
	public boolean isCpp() {
		return true;
	}

	@Override
	protected AbstractCodanCMarkerResolution createQuickFix() {
		return null; // quick fix to be chosen per test
	}

	// struct C {
	// };
	// void foo() {
	//    try {
	//    } catch (C exception) {
	//    }
	// }
	public void testCatchByReference() throws Exception {
		setQuickFix(new CatchByReferenceQuickFix());
		loadcode(getAboveComment());
		String result = runQuickFixOneFile();
		assertContainedIn("catch (C & exception)", result); //$NON-NLS-1$
	}

	// struct C {
	// };
	// void foo() {
	//    try {
	//    } catch (C) {
	//    }
	// }
	public void testCatchByReferenceNoDeclName() throws Exception {
		setQuickFix(new CatchByReferenceQuickFix());
		loadcode(getAboveComment());
		String result = runQuickFixOneFile();
		assertContainedIn("catch (C &)", result); //$NON-NLS-1$
	}

	// struct C {
	// };
	// void foo() {
	//    try {
	//    } catch (C exception) {
	//    }
	// }
	public void testCatchByConstReference() throws Exception {
		setQuickFix(new CatchByConstReferenceQuickFix());
		loadcode(getAboveComment());
		String result = runQuickFixOneFile();
		assertContainedIn("catch (const C & exception)", result); //$NON-NLS-1$
	}

	// struct C {
	// };
	// void foo() {
	//    try {
	//    } catch (C) {
	//    }
	// }
	public void testCatchByConstReferenceNoDeclName() throws Exception {
		setQuickFix(new CatchByConstReferenceQuickFix());
		loadcode(getAboveComment());
		String result = runQuickFixOneFile();
		assertContainedIn("catch (const C &)", result); //$NON-NLS-1$
	}
}

Back to the top