Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/port80/graph/test/TestDotParser01.java


1   //
2   // Copyright(c) 2002, Chris Leung
3   //
4   
5   package com.port80.graph.test;
6   
7   import java.util.HashMap;
8   import java.util.Map;
9   
10  import com.port80.graph.IGraph;
11  import com.port80.graph.dot.impl.Dot;
12  import com.port80.graph.dot.impl.DotEdge;
13  import com.port80.graph.dot.impl.DotGraph;
14  import com.port80.graph.dot.impl.DotVertex;
15  import com.port80.graph.dot.parser.DotParser;
16  import com.port80.util.msg;
17  
18  /**
19   * Basic tests for DotParser.
20   * 
21   * @author chrisl
22   */
23  public class TestDotParser01 {
24  
25    private static final String NAME = "TestDotParser01";
26    private static final String USAGE =
27      "\n"
28        + "java TestAcyclic01 [-options] <test1.dot>\n"
29        + "\n"
30        + "where\n"
31        + "  <test1.dot> is the .dot file for test1(), eg: testArrow01.dot.\n"
32        + "\n"
33        + "Options:\n"
34        + "\n"
35        + "  -h|help    Help\n"
36        + "  -v|verbose    Enable verbose.\n"
37        + "\n"
38        + "  -test =s    Run test <s> only (default: all test)\n";
39  
40    private static final boolean DEBUG = false;
41    private static boolean VERBOSE = false;
42  
43    ////////////////////////////////////////////////////////////////////////
44  
45    public static void main(String[] args) {
46      Map opt = new HashMap();
47      if (args.length == 0)
48        msg.usage(USAGE);
49      String[] cmdargs = msg.getArgs(opt, NAME, args, " help=h verbose=v test:");
50      if (opt.get("help") != null)
51        msg.usage(USAGE);
52      if (opt.get("verbose") != null)
53        VERBOSE = true;
54      //
55      //
56      //
57      int exitcode = 0;
58      if (!test1(opt, cmdargs))
59        exitcode++;
60      System.exit(exitcode);
61    }
62  
63    ////////////////////////////////////////////////////////////////////////
64  
65    public static boolean test1(Map opt, String[] args) {
66      final String PREFIX = NAME + ".test1(): ";
67      boolean ret = true;
68      Dot.setVerbose(VERBOSE);
69      for (int argn = 0; argn < args.length; ++argn) {
70        DotParser parser = Dot.parseFile(args[argn]);
71        if (parser == null) {
72          msg.println(PREFIX + "FAIL: parse error: file=" + args[0]);
73          ret = false;
74        }
75      }
76      return ret;
77    }
78  
79    ////////////////////////////////////////////////////////////////////////
80  
81  }