mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Bug 422797 - API for retrieving QMake information from Qt project
Adding ...cdt.qt.tests/SimpleTests JUnit tests Change-Id: I68d8e56d6b81a65eb1b6823cf7f1df63f00c1a15 Signed-off-by: David Kaspar <dkaspar@blackberry.com> Reviewed-on: https://git.eclipse.org/r/19145 Tested-by: Hudson CI Reviewed-by: Doug Schaefer <dschaefer@qnx.com> IP-Clean: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
eb3b78ec86
commit
dc746352a3
3 changed files with 70 additions and 1 deletions
|
@ -13,4 +13,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Export-Package: org.eclipse.cdt.qt.core,
|
Export-Package: org.eclipse.cdt.qt.core,
|
||||||
org.eclipse.cdt.qt.core.index
|
org.eclipse.cdt.qt.core.index,
|
||||||
|
org.eclipse.cdt.internal.qt.core.index;x-friends:="org.eclipse.cdt.qt.tests"
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class AllQtTests extends TestSuite {
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
return
|
return
|
||||||
new TestSuite(
|
new TestSuite(
|
||||||
|
SimpleTests.class,
|
||||||
QObjectTests.class,
|
QObjectTests.class,
|
||||||
QtIndexTests.class);
|
QtIndexTests.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013 QNX Software Systems 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
|
||||||
|
*/
|
||||||
|
package org.eclipse.cdt.qt.tests;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.qt.core.index.QMakeInfo;
|
||||||
|
import org.eclipse.cdt.internal.qt.core.index.QMakeParser;
|
||||||
|
import org.eclipse.cdt.internal.qt.core.index.QMakeVersion;
|
||||||
|
|
||||||
|
public class SimpleTests extends TestCase {
|
||||||
|
|
||||||
|
public void testQMakeVersion() throws Exception {
|
||||||
|
// Make sure null is returned for invalid version strings.
|
||||||
|
assertNull(QMakeVersion.create(null));
|
||||||
|
assertNull(QMakeVersion.create(""));
|
||||||
|
assertNull(QMakeVersion.create("30"));
|
||||||
|
assertNull(QMakeVersion.create("2.a"));
|
||||||
|
|
||||||
|
// Check an expected value, avoid 0 to confirm that all digits are propertly parsed.
|
||||||
|
QMakeVersion two_dot_one = QMakeVersion.create("2.1");
|
||||||
|
assertNotNull(two_dot_one);
|
||||||
|
assertEquals(2, two_dot_one.getMajor());
|
||||||
|
assertEquals(1, two_dot_one.getMinor());
|
||||||
|
|
||||||
|
// Check the common expected value, make sure leading/trailing whitespace is ignored
|
||||||
|
QMakeVersion three_dot_zero = QMakeVersion.create(" 3.0 ");
|
||||||
|
assertNotNull(three_dot_zero);
|
||||||
|
assertEquals(3, three_dot_zero.getMajor());
|
||||||
|
assertEquals(0, three_dot_zero.getMinor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testQMakeInfo() throws Exception {
|
||||||
|
StringReader content = new StringReader("A = \\\\\\\"\nB = A\\n\\tB\nC = \"A \\\" B\" \"A \\\" B\"");
|
||||||
|
BufferedReader reader = new BufferedReader(content);
|
||||||
|
|
||||||
|
Map<String, String> result = QMakeParser.parse(QMakeInfo.PATTERN_EVAL_LINE, reader);
|
||||||
|
String A = QMakeParser.qmake3DecodeValue(result.get("A"));
|
||||||
|
assertNotNull(A);
|
||||||
|
assertEquals("\\\"", A);
|
||||||
|
|
||||||
|
String B = QMakeParser.qmake3DecodeValue(result.get("B"));
|
||||||
|
assertNotNull(B);
|
||||||
|
assertEquals("A\n\tB", B);
|
||||||
|
|
||||||
|
List<String> C = QMakeParser.qmake3DecodeValueList(result, "C");
|
||||||
|
assertNotNull(C);
|
||||||
|
assertEquals(2, C.size());
|
||||||
|
assertEquals("A \" B", C.get(0));
|
||||||
|
assertEquals("A \" B", C.get(1));
|
||||||
|
|
||||||
|
List<String> D = QMakeParser.qmake3DecodeValueList(result, "D");
|
||||||
|
assertNotNull(D);
|
||||||
|
assertEquals(0, D.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue