1   /*
2    * Copyright (C) 2006  Tom Gibara
3    *
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not, write to the Free Software
16   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17   */
18  package com.tomgibara.pronto.control.impl;
19  
20  import java.text.ParseException;
21  
22  import com.tomgibara.pronto.control.EngineControlAdapter;
23  
24  import junit.framework.TestCase;
25  
26  public class TestCheckedAdapter extends TestCase {
27  
28      private CheckedAdapter adapter = new CheckedAdapter(new EngineControlAdapter() {
29          public Object labelFromName(String name) {
30              return name;
31          }
32  
33          public String nameFromLabel(Object label) {
34              return null;
35          }
36  
37          public Object parseParameter(String string) throws ParseException {
38              return null;
39          }
40      });
41  
42      public void testValidNames() {
43          assertNotNull(adapter.labelFromName("init"));
44          assertNotNull(adapter.labelFromName("1234"));
45          assertNotNull(adapter.labelFromName("level1"));
46          assertNotNull(adapter.labelFromName("level-1"));
47          assertNotNull(adapter.labelFromName("1x"));
48          assertNotNull(adapter.labelFromName("1"));
49          assertNotNull(adapter.labelFromName("a"));
50          assertNotNull(adapter.labelFromName("entré"));
51          assertNotNull(adapter.labelFromName("20_20"));
52      }
53  
54      public void testInvalidNames() {
55          assertNull(adapter.labelFromName(""));
56          assertNull(adapter.labelFromName("*stars*"));
57          assertNull(adapter.labelFromName("(brackets)"));
58          assertNull(adapter.labelFromName("s p a c e s"));
59      }
60  
61  }