pmd-cpp: checkstyle, formatting
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.cpd;
|
package net.sourceforge.pmd.cpd;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -11,18 +12,22 @@ import java.util.Properties;
|
|||||||
public class CPPLanguage extends AbstractLanguage {
|
public class CPPLanguage extends AbstractLanguage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of {@link CPPLanguage} with the default extensions for c/c++ files.
|
* Creates a new instance of {@link CPPLanguage} with the default extensions
|
||||||
|
* for c/c++ files.
|
||||||
*/
|
*/
|
||||||
public CPPLanguage() {
|
public CPPLanguage() {
|
||||||
super("C++", "cpp", new CPPTokenizer(), ".h", ".hpp", ".hxx", ".c", ".cpp", ".cxx", ".cc", ".C");
|
super("C++", "cpp", new CPPTokenizer(), ".h", ".hpp", ".hxx", ".c", ".cpp", ".cxx", ".cc", ".C");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see net.sourceforge.pmd.cpd.AbstractLanguage#setProperties(java.util.Properties)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see net.sourceforge.pmd.cpd.AbstractLanguage#setProperties(java.util.
|
||||||
|
* Properties)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setProperties(Properties properties) {
|
public void setProperties(Properties properties) {
|
||||||
super.setProperties(properties);
|
super.setProperties(properties);
|
||||||
((CPPTokenizer)getTokenizer()).setProperties(properties);
|
((CPPTokenizer) getTokenizer()).setProperties(properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.cpd;
|
package net.sourceforge.pmd.cpd;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -9,6 +10,8 @@ import java.io.Reader;
|
|||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import net.sourceforge.pmd.PMD;
|
import net.sourceforge.pmd.PMD;
|
||||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||||
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
import net.sourceforge.pmd.lang.LanguageVersionHandler;
|
||||||
@ -18,8 +21,6 @@ import net.sourceforge.pmd.lang.cpp.CppLanguageModule;
|
|||||||
import net.sourceforge.pmd.lang.cpp.ast.Token;
|
import net.sourceforge.pmd.lang.cpp.ast.Token;
|
||||||
import net.sourceforge.pmd.util.IOUtil;
|
import net.sourceforge.pmd.util.IOUtil;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The C++ tokenizer.
|
* The C++ tokenizer.
|
||||||
*/
|
*/
|
||||||
@ -31,7 +32,9 @@ public class CPPTokenizer implements Tokenizer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the possible options for the C++ tokenizer.
|
* Sets the possible options for the C++ tokenizer.
|
||||||
* @param properties the properties
|
*
|
||||||
|
* @param properties
|
||||||
|
* the properties
|
||||||
* @see #OPTION_SKIP_BLOCKS
|
* @see #OPTION_SKIP_BLOCKS
|
||||||
* @see #OPTION_SKIP_BLOCKS_PATTERN
|
* @see #OPTION_SKIP_BLOCKS_PATTERN
|
||||||
*/
|
*/
|
||||||
@ -58,8 +61,9 @@ public class CPPTokenizer implements Tokenizer {
|
|||||||
.getDefaultVersion().getLanguageVersionHandler();
|
.getDefaultVersion().getLanguageVersionHandler();
|
||||||
reader = new StringReader(maybeSkipBlocks(buffer.toString()));
|
reader = new StringReader(maybeSkipBlocks(buffer.toString()));
|
||||||
reader = IOUtil.skipBOM(reader);
|
reader = IOUtil.skipBOM(reader);
|
||||||
TokenManager tokenManager = languageVersionHandler.getParser(
|
TokenManager tokenManager = languageVersionHandler
|
||||||
languageVersionHandler.getDefaultParserOptions()).getTokenManager(sourceCode.getFileName(), reader);
|
.getParser(languageVersionHandler.getDefaultParserOptions())
|
||||||
|
.getTokenManager(sourceCode.getFileName(), reader);
|
||||||
Token currentToken = (Token) tokenManager.getNextToken();
|
Token currentToken = (Token) tokenManager.getNextToken();
|
||||||
while (currentToken.image.length() > 0) {
|
while (currentToken.image.length() > 0) {
|
||||||
tokenEntries.add(new TokenEntry(currentToken.image, sourceCode.getFileName(), currentToken.beginLine));
|
tokenEntries.add(new TokenEntry(currentToken.image, sourceCode.getFileName(), currentToken.beginLine));
|
||||||
@ -98,7 +102,8 @@ public class CPPTokenizer implements Tokenizer {
|
|||||||
if (!skip) {
|
if (!skip) {
|
||||||
filtered.append(line);
|
filtered.append(line);
|
||||||
}
|
}
|
||||||
filtered.append(PMD.EOL); // always add a new line to keep the line-numbering
|
// always add a new line to keep the line-numbering
|
||||||
|
filtered.append(PMD.EOL);
|
||||||
}
|
}
|
||||||
return filtered.toString();
|
return filtered.toString();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -31,7 +32,9 @@ public class ContinuationReader extends Reader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link ContinuationReader} which filters the given reader.
|
* Creates a new {@link ContinuationReader} which filters the given reader.
|
||||||
* @param in the given reader
|
*
|
||||||
|
* @param in
|
||||||
|
* the given reader
|
||||||
*/
|
*/
|
||||||
public ContinuationReader(Reader in) {
|
public ContinuationReader(Reader in) {
|
||||||
this.in = new PushbackReader(in, 2);
|
this.in = new PushbackReader(in, 2);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.AbstractLanguageVersionHandler;
|
import net.sourceforge.pmd.lang.AbstractLanguageVersionHandler;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.BaseLanguageModule;
|
import net.sourceforge.pmd.lang.BaseLanguageModule;
|
||||||
@ -16,7 +17,8 @@ public class CppLanguageModule extends BaseLanguageModule {
|
|||||||
public static final String TERSE_NAME = "cpp";
|
public static final String TERSE_NAME = "cpp";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of {@link CppLanguageModule} with the default file extensions for C++.
|
* Creates a new instance of {@link CppLanguageModule} with the default file
|
||||||
|
* extensions for C++.
|
||||||
*/
|
*/
|
||||||
public CppLanguageModule() {
|
public CppLanguageModule() {
|
||||||
super(NAME, null, TERSE_NAME, null, "h", "c", "cpp", "cxx", "cc", "C");
|
super(NAME, null, TERSE_NAME, null, "h", "c", "cpp", "cxx", "cc", "C");
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
@ -20,7 +21,9 @@ public class CppParser extends AbstractParser {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new C++ Parser.
|
* Creates a new C++ Parser.
|
||||||
* @param parserOptions the options
|
*
|
||||||
|
* @param parserOptions
|
||||||
|
* the options
|
||||||
*/
|
*/
|
||||||
public CppParser(ParserOptions parserOptions) {
|
public CppParser(ParserOptions parserOptions) {
|
||||||
super(parserOptions);
|
super(parserOptions);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
@ -17,7 +18,9 @@ public class CppTokenManager implements TokenManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new C++ Token Manager from the given source code.
|
* Creates a new C++ Token Manager from the given source code.
|
||||||
* @param source the source code
|
*
|
||||||
|
* @param source
|
||||||
|
* the source code
|
||||||
*/
|
*/
|
||||||
public CppTokenManager(Reader source) {
|
public CppTokenManager(Reader source) {
|
||||||
tokenManager = new CppParserTokenManager(new SimpleCharStream(new ContinuationReader(source)));
|
tokenManager = new CppParserTokenManager(new SimpleCharStream(new ContinuationReader(source)));
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd;
|
package net.sourceforge.pmd;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||||
import net.sourceforge.pmd.lang.cpp.CppLanguageModule;
|
import net.sourceforge.pmd.lang.cpp.CppLanguageModule;
|
||||||
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
public class LanguageVersionTest extends AbstractLanguageVersionTest {
|
public class LanguageVersionTest extends AbstractLanguageVersionTest {
|
||||||
|
|
||||||
public LanguageVersionTest(String name, String terseName, String version, LanguageVersion expected) {
|
public LanguageVersionTest(String name, String terseName, String version, LanguageVersion expected) {
|
||||||
@ -21,7 +22,12 @@ public class LanguageVersionTest extends AbstractLanguageVersionTest {
|
|||||||
@Parameters
|
@Parameters
|
||||||
public static Collection<Object[]> data() {
|
public static Collection<Object[]> data() {
|
||||||
return Arrays.asList(new Object[][] {
|
return Arrays.asList(new Object[][] {
|
||||||
{ CppLanguageModule.NAME, CppLanguageModule.TERSE_NAME, "", LanguageRegistry.getLanguage(CppLanguageModule.NAME).getDefaultVersion() }
|
{
|
||||||
});
|
CppLanguageModule.NAME,
|
||||||
|
CppLanguageModule.TERSE_NAME,
|
||||||
|
"",
|
||||||
|
LanguageRegistry.getLanguage(CppLanguageModule.NAME).getDefaultVersion(),
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.cpd;
|
package net.sourceforge.pmd.cpd;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -8,11 +9,11 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import net.sourceforge.pmd.PMD;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.sourceforge.pmd.PMD;
|
||||||
|
|
||||||
public class CPPTokenizerTest {
|
public class CPPTokenizerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -24,25 +25,16 @@ public class CPPTokenizerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnicodeSupport() {
|
public void testUnicodeSupport() {
|
||||||
String code = "\ufeff" +
|
String code = "\ufeff" + "#include <iostream>\n" + "#include <string>\n" + "\n" + "// example\n" + "\n"
|
||||||
"#include <iostream>\n" +
|
+ "int main()\n" + "{\n" + " std::string text(\"ąęćśźńó\");\n" + " std::cout << text;\n"
|
||||||
"#include <string>\n" +
|
+ " return 0;\n" + "}\n";
|
||||||
"\n" +
|
|
||||||
"// example\n" +
|
|
||||||
"\n" +
|
|
||||||
"int main()\n" +
|
|
||||||
"{\n" +
|
|
||||||
" std::string text(\"ąęćśźńó\");\n" +
|
|
||||||
" std::cout << text;\n" +
|
|
||||||
" return 0;\n" +
|
|
||||||
"}\n";
|
|
||||||
Tokens tokens = parse(code);
|
Tokens tokens = parse(code);
|
||||||
assertTrue(TokenEntry.getEOF() != tokens.getTokens().get(0));
|
assertTrue(TokenEntry.getEOF() != tokens.getTokens().get(0));
|
||||||
assertEquals(24, tokens.size());
|
assertEquals(24, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiLineMacros() throws Throwable {
|
public void testMultiLineMacros() {
|
||||||
Tokens tokens = parse(TEST1);
|
Tokens tokens = parse(TEST1);
|
||||||
assertEquals(7, tokens.size());
|
assertEquals(7, tokens.size());
|
||||||
}
|
}
|
||||||
@ -64,14 +56,14 @@ public class CPPTokenizerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContinuation_IntraToken() {
|
public void testContinuation_IntraToken() {
|
||||||
Tokens tokens = parse(TEST5);
|
Tokens tokens = parse(TEST5);
|
||||||
assertEquals(7, tokens.size());
|
assertEquals(7, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testContinuation_InterToken() {
|
public void testContinuation_InterToken() {
|
||||||
Tokens tokens = parse(TEST6);
|
Tokens tokens = parse(TEST6);
|
||||||
assertEquals(17, tokens.size());
|
assertEquals(17, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -96,7 +88,7 @@ public class CPPTokenizerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
//ASM code containing the '@' character
|
// ASM code containing the '@' character
|
||||||
public void testAsmWithAtSign() {
|
public void testAsmWithAtSign() {
|
||||||
Tokens tokens = parse(TEST7);
|
Tokens tokens = parse(TEST7);
|
||||||
assertEquals(22, tokens.size());
|
assertEquals(22, tokens.size());
|
||||||
@ -124,17 +116,13 @@ public class CPPTokenizerTest {
|
|||||||
Tokens tokens = parse("szPath = m_sdcacheDir + _T(\"\\ oMedia\");" + PMD.EOL);
|
Tokens tokens = parse("szPath = m_sdcacheDir + _T(\"\\ oMedia\");" + PMD.EOL);
|
||||||
assertEquals(10, tokens.size());
|
assertEquals(10, tokens.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRawStringLiteral() {
|
public void testRawStringLiteral() {
|
||||||
String code =
|
String code = "const char* const KDefaultConfig = R\"(\n" + " [Sinks.1]\n" + " Destination=Console\n"
|
||||||
"const char* const KDefaultConfig = R\"(\n" +
|
+ " AutoFlush=true\n"
|
||||||
" [Sinks.1]\n" +
|
+ " Format=\"[%TimeStamp%] %ThreadId% %QueryIdHigh% %QueryIdLow% %LoggerFile%:%Line% (%Severity%) - %Message%\"\n"
|
||||||
" Destination=Console\n" +
|
+ " Filter=\"%Severity% >= WRN\"\n" + ")\";\n";
|
||||||
" AutoFlush=true\n" +
|
|
||||||
" Format=\"[%TimeStamp%] %ThreadId% %QueryIdHigh% %QueryIdLow% %LoggerFile%:%Line% (%Severity%) - %Message%\"\n" +
|
|
||||||
" Filter=\"%Severity% >= WRN\"\n" +
|
|
||||||
")\";\n";
|
|
||||||
Tokens tokens = parse(code);
|
Tokens tokens = parse(code);
|
||||||
assertTrue(TokenEntry.getEOF() != tokens.getTokens().get(0));
|
assertTrue(TokenEntry.getEOF() != tokens.getTokens().get(0));
|
||||||
assertEquals(9, tokens.size());
|
assertEquals(9, tokens.size());
|
||||||
@ -143,9 +131,11 @@ public class CPPTokenizerTest {
|
|||||||
private Tokens parse(String snippet) {
|
private Tokens parse(String snippet) {
|
||||||
return parse(snippet, false);
|
return parse(snippet, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tokens parse(String snippet, boolean skipBlocks) {
|
private Tokens parse(String snippet, boolean skipBlocks) {
|
||||||
return parse(snippet, skipBlocks, null);
|
return parse(snippet, skipBlocks, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tokens parse(String snippet, boolean skipBlocks, String skipPattern) {
|
private Tokens parse(String snippet, boolean skipBlocks, String skipPattern) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(skipBlocks));
|
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(skipBlocks));
|
||||||
@ -162,59 +152,26 @@ public class CPPTokenizerTest {
|
|||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TEST1 =
|
private static final String TEST1 = "#define FOO a +\\" + PMD.EOL + " b +\\" + PMD.EOL
|
||||||
"#define FOO a +\\" + PMD.EOL +
|
+ " c +\\" + PMD.EOL + " d +\\" + PMD.EOL + " e +\\" + PMD.EOL
|
||||||
" b +\\" + PMD.EOL +
|
+ " f +\\" + PMD.EOL + " g" + PMD.EOL + " void main() {}";
|
||||||
" c +\\" + PMD.EOL +
|
|
||||||
" d +\\" + PMD.EOL +
|
|
||||||
" e +\\" + PMD.EOL +
|
|
||||||
" f +\\" + PMD.EOL +
|
|
||||||
" g" + PMD.EOL +
|
|
||||||
" void main() {}";
|
|
||||||
|
|
||||||
private static final String TEST2 =
|
private static final String TEST2 = " void main() { int x$y = 42; }";
|
||||||
" void main() { int x$y = 42; }";
|
|
||||||
|
|
||||||
private static final String TEST3 =
|
private static final String TEST3 = " void main() { int $x = 42; }";
|
||||||
" void main() { int $x = 42; }";
|
|
||||||
|
|
||||||
private static final String TEST4 =
|
private static final String TEST4 = " void main() { char x = L'a'; }";
|
||||||
" void main() { char x = L'a'; }";
|
|
||||||
|
|
||||||
private static final String TEST5 =
|
|
||||||
"v\\" + PMD.EOL +
|
|
||||||
"o\\" + PMD.EOL +
|
|
||||||
"i\\" + PMD.EOL +
|
|
||||||
"d\\" + PMD.EOL +
|
|
||||||
" \\" + PMD.EOL +
|
|
||||||
"m\\" + PMD.EOL +
|
|
||||||
"a\\" + PMD.EOL +
|
|
||||||
"i\\" + PMD.EOL +
|
|
||||||
"n\\" + PMD.EOL +
|
|
||||||
"(\\" + PMD.EOL +
|
|
||||||
")\\" + PMD.EOL +
|
|
||||||
" \\" + PMD.EOL +
|
|
||||||
"{\\" + PMD.EOL +
|
|
||||||
" \\" + PMD.EOL +
|
|
||||||
"}\\" + PMD.EOL;
|
|
||||||
|
|
||||||
private static final String TEST6 =
|
|
||||||
"#include <iostream>" + PMD.EOL +
|
|
||||||
PMD.EOL +
|
|
||||||
"int main()" + PMD.EOL +
|
|
||||||
"{" + PMD.EOL +
|
|
||||||
" std::cout << \"Hello, \" \\" + PMD.EOL +
|
|
||||||
" \"world!\\n\";" + PMD.EOL +
|
|
||||||
" return 0;" + PMD.EOL +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
private static final String TEST7 =
|
private static final String TEST5 = "v\\" + PMD.EOL + "o\\" + PMD.EOL + "i\\" + PMD.EOL + "d\\" + PMD.EOL + " \\"
|
||||||
"asm void eSPI_boot()" + PMD.EOL +
|
+ PMD.EOL + "m\\" + PMD.EOL + "a\\" + PMD.EOL + "i\\" + PMD.EOL + "n\\" + PMD.EOL + "(\\" + PMD.EOL + ")\\"
|
||||||
"{" + PMD.EOL +
|
+ PMD.EOL + " \\" + PMD.EOL + "{\\" + PMD.EOL + " \\" + PMD.EOL + "}\\" + PMD.EOL;
|
||||||
" // setup stack pointer" + PMD.EOL +
|
|
||||||
" lis r1, _stack_addr@h" + PMD.EOL +
|
private static final String TEST6 = "#include <iostream>" + PMD.EOL + PMD.EOL + "int main()" + PMD.EOL + "{"
|
||||||
" ori r1, r1, _stack_addr@l" + PMD.EOL +
|
+ PMD.EOL + " std::cout << \"Hello, \" \\" + PMD.EOL + " \"world!\\n\";" + PMD.EOL
|
||||||
"}";
|
+ " return 0;" + PMD.EOL + "}";
|
||||||
|
|
||||||
|
private static final String TEST7 = "asm void eSPI_boot()" + PMD.EOL + "{" + PMD.EOL + " // setup stack pointer"
|
||||||
|
+ PMD.EOL + " lis r1, _stack_addr@h" + PMD.EOL + " ori r1, r1, _stack_addr@l" + PMD.EOL + "}";
|
||||||
|
|
||||||
public static junit.framework.Test suite() {
|
public static junit.framework.Test suite() {
|
||||||
return new junit.framework.JUnit4TestAdapter(CPPTokenizerTest.class);
|
return new junit.framework.JUnit4TestAdapter(CPPTokenizerTest.class);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.sourceforge.pmd.lang.cpp;
|
package net.sourceforge.pmd.lang.cpp;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
Reference in New Issue
Block a user