blob: ff556adb2a70a74bd5ca9c67d85aa7de345e9f6c (
plain)
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
|
package com.jogamp.gluegen.jcpp;
import com.jogamp.common.util.IOUtil;
import java.io.IOException;
import java.io.Reader;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import com.jogamp.gluegen.Logging;
import com.jogamp.gluegen.Logging.LoggerIf;
import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.*;
/**
* https://github.com/shevek/jcpp/issues/25
*
* @author shevek
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TokenPastingWhitespaceTest extends SingletonJunitCase {
private static final LoggerIf LOG = Logging.getLogger(TokenPastingWhitespaceTest.class);
@Test
public void test01WhitespacePasting() throws IOException {
final Preprocessor pp = new Preprocessor();
testWhitespacePastingImpl(pp);
}
void testWhitespacePastingImpl(final Preprocessor pp) throws IOException {
pp.addInput(new StringLexerSource(
"#define ONE(arg) one_##arg\n"
+ "#define TWO(arg) ONE(two_##arg)\n"
+ "\n"
+ "TWO(good)\n"
+ "TWO( /* evil newline */\n"
+ " bad)\n"
+ "\n"
+ "ONE(good)\n"
+ "ONE( /* evil newline */\n"
+ " bad)\n", true));
final Reader r = new CppReader(pp);
final String text = IOUtil.appendCharStream(new StringBuilder(), r).toString().trim();
LOG.info("Output is:\n" + text);
assertEquals("one_two_good\n"
+ "one_two_bad\n"
+ "\n"
+ "one_good\n"
+ "one_bad", text);
}
public static void main(final String args[]) throws IOException {
final String tstname = TokenPastingWhitespaceTest.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
}
|