[logback-dev] svn commit: r957 - logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Sun Nov 19 16:24:14 CET 2006
Author: ceki
Date: Sun Nov 19 16:24:13 2006
New Revision: 957
Modified:
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
Log:
silent tests are beautiful
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/OptionTokenizerTest.java Sun Nov 19 16:24:13 2006
@@ -1,5 +1,5 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -7,6 +7,7 @@
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
+
package ch.qos.logback.core.pattern.parser;
import java.util.ArrayList;
@@ -19,98 +20,97 @@
public class OptionTokenizerTest extends TestCase {
- public void testEmpty() throws ScanException {
- {
- List ol = new OptionTokenizer("").tokenize();
- List witness = new ArrayList();
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer(" ").tokenize();
- List witness = new ArrayList();
- assertEquals(witness, ol);
- }
- }
-
-
- public void testSimple() throws ScanException {
- {
- List ol = new OptionTokenizer("abc").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add("abc");
- assertEquals(witness, ol);
- }
- }
-
- public void testSingleQuote() throws ScanException {
- {
- List ol = new OptionTokenizer("' '").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" ");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("' x\t'").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\t");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("' x\\t'").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\t");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("' x\\''").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\'");
- assertEquals(witness, ol);
- }
- }
-
- public void testDoubleQuote() throws ScanException {
- {
- List ol = new OptionTokenizer("\" \"").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" ");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("\" x\t\"").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\t");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("\" x\\t\"").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\t");
- assertEquals(witness, ol);
- }
-
- {
- List ol = new OptionTokenizer("\" x\\\"\"").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add(" x\"");
- assertEquals(witness, ol);
- }
- }
-
- public void testMultiple() throws ScanException {
- {
- List ol = new OptionTokenizer("a, b").tokenize();
- List<String> witness = new ArrayList<String>();
- witness.add("a");
- witness.add("b");
- assertEquals(witness, ol);
- }
- }
+ public void testEmpty() throws ScanException {
+ {
+ List ol = new OptionTokenizer("").tokenize();
+ List witness = new ArrayList();
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer(" ").tokenize();
+ List witness = new ArrayList();
+ assertEquals(witness, ol);
+ }
+ }
+
+ public void testSimple() throws ScanException {
+ {
+ List ol = new OptionTokenizer("abc").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add("abc");
+ assertEquals(witness, ol);
+ }
+ }
+
+ public void testSingleQuote() throws ScanException {
+ {
+ List ol = new OptionTokenizer("' '").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" ");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("' x\t'").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\t");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("' x\\t'").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\t");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("' x\\''").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\'");
+ assertEquals(witness, ol);
+ }
+ }
+
+ public void testDoubleQuote() throws ScanException {
+ {
+ List ol = new OptionTokenizer("\" \"").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" ");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("\" x\t\"").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\t");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("\" x\\t\"").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\t");
+ assertEquals(witness, ol);
+ }
+
+ {
+ List ol = new OptionTokenizer("\" x\\\"\"").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add(" x\"");
+ assertEquals(witness, ol);
+ }
+ }
+
+ public void testMultiple() throws ScanException {
+ {
+ List ol = new OptionTokenizer("a, b").tokenize();
+ List<String> witness = new ArrayList<String>();
+ witness.add("a");
+ witness.add("b");
+ assertEquals(witness, ol);
+ }
+ }
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java Sun Nov 19 16:24:13 2006
@@ -1,6 +1,14 @@
-package ch.qos.logback.core.pattern.parser;
-
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+package ch.qos.logback.core.pattern.parser;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -8,7 +16,7 @@
public class PackageTest extends TestCase {
- public static Test suite() {
+ public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TokenStreamTest.class);
suite.addTestSuite(OptionTokenizerTest.class);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/ParserTest.java Sun Nov 19 16:24:13 2006
@@ -1,5 +1,5 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
* Copyright (C) 1999-2006, QOS.ch
*
@@ -79,9 +79,6 @@
}
public void testComposite() throws Exception {
-
- System.out.println();
- System.out.println("testRecursive");
{
Parser p = new Parser("hello%(%child)");
Node t = p.parse();
@@ -92,13 +89,13 @@
composite.setChildNode(child);
witness.next = composite;
- System.out.println("w:" + witness);
- System.out.println(t);
+ // System.out.println("w:" + witness);
+ // System.out.println(t);
assertEquals(witness, t);
}
- System.out.println("testRecursive part 2");
+ // System.out.println("testRecursive part 2");
{
Parser p = new Parser("hello%(%child )");
Node t = p.parse();
@@ -248,8 +245,6 @@
public void testCompositeFormatting() throws Exception {
- System.out.println();
- System.out.println("testRecursive");
{
Parser p = new Parser("hello%5(XYZ)");
Node t = p.parse();
@@ -264,9 +259,10 @@
assertEquals(witness, t);
}
}
+
public static Test Xsuite() {
TestSuite suite = new TestSuite();
suite.addTest(new ParserTest("testFormattingInfo"));
return suite;
- }
+ }
}
\ No newline at end of file
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/TokenStreamTest.java Sun Nov 19 16:24:13 2006
@@ -1,12 +1,13 @@
/**
- * LOGBack: the reliable, fast and flexible logging library for Java.
+ * Logback: the generic, reliable, fast and flexible logging framework.
*
- * Copyright (C) 1999-2006, QOS.ch, LOGBack.com
+ * Copyright (C) 1999-2006, QOS.ch
*
* This library is free software, you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation.
*/
+
package ch.qos.logback.core.pattern.parser;
import junit.framework.*;
@@ -20,154 +21,154 @@
public class TokenStreamTest extends TestCase {
- public TokenStreamTest(String arg0) {
- super(arg0);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testEmpty() throws ScanException {
- List tl = new TokenStream("").tokenize();
- List witness = new ArrayList();
- assertEquals(witness, tl);
- }
-
- public void testSingleLiteral() throws ScanException {
- List tl = new TokenStream("hello").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "hello"));
- assertEquals(witness, tl);
- }
-
- public void testLiteralWithPercent() throws ScanException {
- {
- List tl = new TokenStream("hello\\%world").tokenize();
-
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "hello%world"));
- assertEquals(witness, tl);
- }
- {
- List tl = new TokenStream("hello\\%").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "hello%"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("\\%").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "%"));
- assertEquals(witness, tl);
- }
- }
-
- public void testBasic() throws ScanException {
-
- // test "%c"
- {
- List tl = new TokenStream("%c").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "c"));
- assertEquals(witness, tl);
- }
-
- {
- // test "xyz%-34c"
- List tl = new TokenStream("%a%b").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "a"));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "b"));
- assertEquals(witness, tl);
- }
-
- {
- // test "xyz%-34c"
- List tl = new TokenStream("xyz%-34c").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "xyz"));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.FORMAT_MODIFIER, "-34"));
- witness.add(new Token(Token.KEYWORD, "c"));
- assertEquals(witness, tl);
- }
- }
-
- public void testComplexNR() throws ScanException {
- List tl = new TokenStream("%d{1234} [%34.-67toto] %n").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "d"));
- witness.add(new Token(Token.OPTION, "1234"));
- witness.add(new Token(Token.LITERAL, " ["));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.FORMAT_MODIFIER, "34.-67"));
- witness.add(new Token(Token.KEYWORD, "toto"));
- witness.add(new Token(Token.LITERAL, "] "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "n"));
- assertEquals(witness, tl);
- }
-
- public void testEmptyP() throws ScanException {
- List tl = new TokenStream("()").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "("));
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- assertEquals(witness, tl);
- }
-
- public void testEmptyP2() throws ScanException {
- List tl = new TokenStream("%()").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- assertEquals(witness, tl);
- }
-
- public void testEscape() throws ScanException {
- {
- List tl = new TokenStream("\\%").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "%"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("\\%\\(\\t\\)\\r\\n").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "%(\t)\r\n"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("\\\\%x").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "\\"));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("%x\\)").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- witness.add(new Token(Token.LITERAL, ")"));
- assertEquals(witness, tl);
- }
-
+ public TokenStreamTest(String arg0) {
+ super(arg0);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testEmpty() throws ScanException {
+ List tl = new TokenStream("").tokenize();
+ List witness = new ArrayList();
+ assertEquals(witness, tl);
+ }
+
+ public void testSingleLiteral() throws ScanException {
+ List tl = new TokenStream("hello").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "hello"));
+ assertEquals(witness, tl);
+ }
+
+ public void testLiteralWithPercent() throws ScanException {
+ {
+ List tl = new TokenStream("hello\\%world").tokenize();
+
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "hello%world"));
+ assertEquals(witness, tl);
+ }
+ {
+ List tl = new TokenStream("hello\\%").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "hello%"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("\\%").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "%"));
+ assertEquals(witness, tl);
+ }
+ }
+
+ public void testBasic() throws ScanException {
+
+ // test "%c"
+ {
+ List tl = new TokenStream("%c").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "c"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ // test "xyz%-34c"
+ List tl = new TokenStream("%a%b").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "a"));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "b"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ // test "xyz%-34c"
+ List tl = new TokenStream("xyz%-34c").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "xyz"));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.FORMAT_MODIFIER, "-34"));
+ witness.add(new Token(Token.KEYWORD, "c"));
+ assertEquals(witness, tl);
+ }
+ }
+
+ public void testComplexNR() throws ScanException {
+ List tl = new TokenStream("%d{1234} [%34.-67toto] %n").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "d"));
+ witness.add(new Token(Token.OPTION, "1234"));
+ witness.add(new Token(Token.LITERAL, " ["));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.FORMAT_MODIFIER, "34.-67"));
+ witness.add(new Token(Token.KEYWORD, "toto"));
+ witness.add(new Token(Token.LITERAL, "] "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "n"));
+ assertEquals(witness, tl);
+ }
+
+ public void testEmptyP() throws ScanException {
+ List tl = new TokenStream("()").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "("));
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ assertEquals(witness, tl);
+ }
+
+ public void testEmptyP2() throws ScanException {
+ List tl = new TokenStream("%()").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ assertEquals(witness, tl);
+ }
+
+ public void testEscape() throws ScanException {
+ {
+ List tl = new TokenStream("\\%").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "%"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("\\%\\(\\t\\)\\r\\n").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "%(\t)\r\n"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("\\\\%x").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "\\"));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("%x\\)").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ witness.add(new Token(Token.LITERAL, ")"));
+ assertEquals(witness, tl);
+ }
+
{
List tl = new TokenStream("%x\\_a").tokenize();
List<Token> witness = new ArrayList<Token>();
@@ -185,130 +186,130 @@
witness.add(new Token(Token.KEYWORD, "b"));
assertEquals(witness, tl);
}
- }
+ }
+
+ public void testOptions() throws ScanException {
+ {
+ List tl = new TokenStream("%x{t}").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ witness.add(new Token(Token.OPTION, "t"));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("%x{t,y}").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ witness.add(new Token(Token.OPTION, "t,y"));
+ assertEquals(witness, tl);
+ }
- public void testOptions() throws ScanException {
- {
- List tl = new TokenStream("%x{t}").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- witness.add(new Token(Token.OPTION, "t"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("%x{t,y}").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- witness.add(new Token(Token.OPTION, "t,y"));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("%x{\"hello world.\", \"12y \"}").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- witness.add(new Token(Token.OPTION, "\"hello world.\", \"12y \""));
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("%x{opt\\}}").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "x"));
- witness.add(new Token(Token.OPTION, "opt}"));
- assertEquals(witness, tl);
- }
- }
-
- public void testSimpleP() throws ScanException {
- List tl = new TokenStream("%(hello %class{.4?})").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(new Token(Token.LITERAL, "hello "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "class"));
- witness.add(new Token(Token.OPTION, ".4?"));
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- assertEquals(witness, tl);
- }
-
- public void testSimpleP2() throws ScanException {
- List tl = new TokenStream("X %a %-12.550(hello %class{.4?})").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "X "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "a"));
- witness.add(new Token(Token.LITERAL, " "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.FORMAT_MODIFIER, "-12.550"));
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(new Token(Token.LITERAL, "hello "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "class"));
- witness.add(new Token(Token.OPTION, ".4?"));
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- assertEquals(witness, tl);
- }
-
- public void testMultipleRecursion() throws ScanException {
- List tl = new TokenStream("%-1(%d %45(%class %file))").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.FORMAT_MODIFIER, "-1"));
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "d"));
- witness.add(new Token(Token.LITERAL, " "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.FORMAT_MODIFIER, "45"));
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "class"));
- witness.add(new Token(Token.LITERAL, " "));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "file"));
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
-
- assertEquals(witness, tl);
- }
-
- public void testNested() throws ScanException {
- {
- List tl = new TokenStream("%(%a%(%b))").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(Token.PERCENT_TOKEN);
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "a"));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(Token.LEFT_PARENTHESIS_TOKEN);
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "b"));
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
- witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
-
- assertEquals(witness, tl);
- }
-
- {
- List tl = new TokenStream("\\(%h\\)").tokenize();
- List<Token> witness = new ArrayList<Token>();
- witness.add(new Token(Token.LITERAL, "("));
- witness.add(Token.PERCENT_TOKEN);
- witness.add(new Token(Token.KEYWORD, "h"));
- witness.add(new Token(Token.LITERAL, ")"));
-
- assertEquals(witness, tl);
- }
+ {
+ List tl = new TokenStream("%x{\"hello world.\", \"12y \"}").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ witness.add(new Token(Token.OPTION, "\"hello world.\", \"12y \""));
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("%x{opt\\}}").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "x"));
+ witness.add(new Token(Token.OPTION, "opt}"));
+ assertEquals(witness, tl);
+ }
+ }
+
+ public void testSimpleP() throws ScanException {
+ List tl = new TokenStream("%(hello %class{.4?})").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(new Token(Token.LITERAL, "hello "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "class"));
+ witness.add(new Token(Token.OPTION, ".4?"));
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ assertEquals(witness, tl);
+ }
+
+ public void testSimpleP2() throws ScanException {
+ List tl = new TokenStream("X %a %-12.550(hello %class{.4?})").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "X "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "a"));
+ witness.add(new Token(Token.LITERAL, " "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.FORMAT_MODIFIER, "-12.550"));
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(new Token(Token.LITERAL, "hello "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "class"));
+ witness.add(new Token(Token.OPTION, ".4?"));
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ assertEquals(witness, tl);
+ }
+
+ public void testMultipleRecursion() throws ScanException {
+ List tl = new TokenStream("%-1(%d %45(%class %file))").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.FORMAT_MODIFIER, "-1"));
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "d"));
+ witness.add(new Token(Token.LITERAL, " "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.FORMAT_MODIFIER, "45"));
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "class"));
+ witness.add(new Token(Token.LITERAL, " "));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "file"));
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+
+ assertEquals(witness, tl);
+ }
+
+ public void testNested() throws ScanException {
+ {
+ List tl = new TokenStream("%(%a%(%b))").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "a"));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(Token.LEFT_PARENTHESIS_TOKEN);
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "b"));
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+ witness.add(Token.RIGHT_PARENTHESIS_TOKEN);
+
+ assertEquals(witness, tl);
+ }
+
+ {
+ List tl = new TokenStream("\\(%h\\)").tokenize();
+ List<Token> witness = new ArrayList<Token>();
+ witness.add(new Token(Token.LITERAL, "("));
+ witness.add(Token.PERCENT_TOKEN);
+ witness.add(new Token(Token.KEYWORD, "h"));
+ witness.add(new Token(Token.LITERAL, ")"));
+
+ assertEquals(witness, tl);
+ }
- //
- }
+ //
+ }
}
\ No newline at end of file
More information about the logback-dev
mailing list