~ubuntu-branches/ubuntu/precise/xom/precise

« back to all changes in this revision

Viewing changes to src/nu/xom/tests/AttributeTypeTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2007-11-25 15:50:40 UTC
  • Revision ID: james.westby@ubuntu.com-20071125155040-r75ikcqf1vu0cei7
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2003 Elliotte Rusty Harold
 
2
   
 
3
   This library is free software; you can redistribute it and/or modify
 
4
   it under the terms of version 2.1 of the GNU Lesser General Public 
 
5
   License as published by the Free Software Foundation.
 
6
   
 
7
   This library is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 
10
   GNU Lesser General Public License for more details.
 
11
   
 
12
   You should have received a copy of the GNU Lesser General Public
 
13
   License along with this library; if not, write to the 
 
14
   Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
15
   Boston, MA 02111-1307  USA
 
16
   
 
17
   You can contact Elliotte Rusty Harold by sending e-mail to
 
18
   elharo@metalab.unc.edu. Please include the word "XOM" in the
 
19
   subject line. The XOM home page is located at http://www.xom.nu/
 
20
*/
 
21
package nu.xom.tests;
 
22
 
 
23
import nu.xom.Attribute;
 
24
import nu.xom.Text;
 
25
 
 
26
/**
 
27
 * <p>
 
28
 *   Tests for the <code>Attribute.Type</code> inner class.
 
29
 * </p>
 
30
 * 
 
31
 * @author Elliotte Rusty Harold
 
32
 * @version 1.0
 
33
 *
 
34
 */
 
35
public class AttributeTypeTest extends XOMTestCase {
 
36
 
 
37
    public AttributeTypeTest(String name) {
 
38
        super(name);   
 
39
    }
 
40
 
 
41
    public void testEquals() {
 
42
        assertEquals(Attribute.Type.CDATA, Attribute.Type.CDATA);
 
43
        assertEquals(Attribute.Type.ID, Attribute.Type.ID);
 
44
        assertEquals(Attribute.Type.IDREF, Attribute.Type.IDREF);
 
45
        assertEquals(Attribute.Type.IDREFS, Attribute.Type.IDREFS);
 
46
        assertEquals(Attribute.Type.UNDECLARED, Attribute.Type.UNDECLARED);
 
47
        assertEquals(Attribute.Type.NMTOKEN, Attribute.Type.NMTOKEN);
 
48
        assertEquals(Attribute.Type.NMTOKENS, Attribute.Type.NMTOKENS);
 
49
        assertEquals(Attribute.Type.NOTATION, Attribute.Type.NOTATION);
 
50
        assertEquals(Attribute.Type.ENTITY, Attribute.Type.ENTITY);
 
51
        assertEquals(Attribute.Type.ENTITIES, Attribute.Type.ENTITIES);
 
52
        assertTrue(Attribute.Type.ENTITIES != Attribute.Type.ENTITY);
 
53
        assertTrue(Attribute.Type.CDATA != Attribute.Type.ID);
 
54
        assertTrue(Attribute.Type.ID != Attribute.Type.IDREF);
 
55
        assertTrue(Attribute.Type.ID != Attribute.Type.IDREFS);
 
56
        assertTrue(Attribute.Type.ID != Attribute.Type.NMTOKEN);
 
57
        assertTrue(Attribute.Type.ID != Attribute.Type.NMTOKENS);
 
58
        assertTrue(Attribute.Type.UNDECLARED != Attribute.Type.CDATA);
 
59
        assertTrue(Attribute.Type.NMTOKEN != Attribute.Type.CDATA);
 
60
        
 
61
        assertFalse(Attribute.Type.CDATA.equals(new Integer(1)));
 
62
        assertFalse(Attribute.Type.CDATA.equals(new Text("data")));
 
63
    }
 
64
 
 
65
    public void testToString() {
 
66
        assertNotNull(Attribute.Type.CDATA.toString());
 
67
        assertNotNull(Attribute.Type.ID.toString());
 
68
        assertNotNull(Attribute.Type.IDREF.toString());
 
69
        assertNotNull(Attribute.Type.IDREFS.toString());
 
70
        assertNotNull(Attribute.Type.UNDECLARED.toString());
 
71
        assertNotNull(Attribute.Type.NMTOKEN.toString());
 
72
        assertNotNull(Attribute.Type.NMTOKENS.toString());
 
73
        assertNotNull(Attribute.Type.NOTATION.toString());
 
74
        assertNotNull(Attribute.Type.ENTITY.toString());
 
75
        assertNotNull(Attribute.Type.ENTITIES.toString());
 
76
 
 
77
        assertTrue(Attribute.Type.CDATA.toString().length() > 10);
 
78
        assertTrue(Attribute.Type.ID.toString().length() > 10);
 
79
        assertTrue(Attribute.Type.IDREF.toString().length() > 10);
 
80
        assertTrue(Attribute.Type.IDREFS.toString().length() > 10);
 
81
        assertTrue(Attribute.Type.UNDECLARED.toString().length() > 10);
 
82
        assertTrue(Attribute.Type.NMTOKEN.toString().length() > 10);
 
83
        assertTrue(Attribute.Type.NMTOKENS.toString().length() > 10);
 
84
        assertTrue(Attribute.Type.NOTATION.toString().length() > 10);
 
85
        assertTrue(Attribute.Type.ENTITY.toString().length() > 10);
 
86
        assertTrue(Attribute.Type.ENTITIES.toString().length() > 10);
 
87
 
 
88
        assertTrue(Attribute.Type.CDATA.toString().startsWith("[Attribute.Type"));
 
89
        assertTrue(Attribute.Type.ID.toString().startsWith("[Attribute.Type"));
 
90
        assertTrue(Attribute.Type.IDREF.toString().startsWith("[Attribute.Type"));
 
91
        assertTrue(Attribute.Type.IDREFS.toString().startsWith("[Attribute.Type"));
 
92
        assertTrue(Attribute.Type.UNDECLARED.toString().startsWith("[Attribute.Type"));
 
93
        assertTrue(Attribute.Type.NMTOKEN.toString().startsWith("[Attribute.Type"));
 
94
        assertTrue(Attribute.Type.NMTOKENS.toString().startsWith("[Attribute.Type"));
 
95
        assertTrue(Attribute.Type.NOTATION.toString().startsWith("[Attribute.Type"));
 
96
        assertTrue(Attribute.Type.ENTITY.toString().startsWith("[Attribute.Type"));
 
97
        assertTrue(Attribute.Type.ENTITIES.toString().startsWith("[Attribute.Type"));
 
98
 
 
99
        assertTrue(Attribute.Type.CDATA.toString().endsWith("]"));
 
100
        assertTrue(Attribute.Type.ID.toString().endsWith("]"));
 
101
        assertTrue(Attribute.Type.IDREF.toString().endsWith("]"));
 
102
        assertTrue(Attribute.Type.IDREFS.toString().endsWith("]"));
 
103
        assertTrue(Attribute.Type.UNDECLARED.toString().endsWith("]"));
 
104
        assertTrue(Attribute.Type.NMTOKEN.toString().endsWith("]"));
 
105
        assertTrue(Attribute.Type.NMTOKENS.toString().endsWith("]"));
 
106
        assertTrue(Attribute.Type.NOTATION.toString().endsWith("]"));
 
107
        assertTrue(Attribute.Type.ENTITY.toString().endsWith("]"));
 
108
        assertTrue(Attribute.Type.ENTITIES.toString().endsWith("]"));
 
109
 
 
110
    }
 
111
 
 
112
    public void testGetName() {
 
113
        assertEquals("ENUMERATION", Attribute.Type.ENUMERATION.getName());
 
114
        assertEquals("NOTATION", Attribute.Type.NOTATION.getName());
 
115
        assertEquals("ENTITY", Attribute.Type.ENTITY.getName());
 
116
        assertEquals("ENTITIES", Attribute.Type.ENTITIES.getName());
 
117
        assertEquals("CDATA", Attribute.Type.CDATA.getName());
 
118
        assertEquals("ID", Attribute.Type.ID.getName());
 
119
        assertEquals("IDREF", Attribute.Type.IDREF.getName());
 
120
        assertEquals("IDREFS", Attribute.Type.IDREFS.getName());
 
121
        assertEquals("NMTOKEN", Attribute.Type.NMTOKEN.getName());
 
122
        assertEquals("NMTOKENS", Attribute.Type.NMTOKENS.getName());
 
123
    }
 
124
 
 
125
}