1 package org.melati.poem.test;
2
3 import java.text.DateFormat;
4 import java.util.Enumeration;
5
6 import org.melati.poem.DisplayLevelPoemType;
7 import org.melati.poem.Searchability;
8 import org.melati.poem.SearchabilityPoemType;
9 import org.melati.poem.Searchability.NameUnrecognisedException;
10 import org.melati.poem.PoemLocale;
11
12
13
14
15
16
17 public class SearchabilityPoemTypeTest extends NotNullableIntegerPoemTypeTest {
18
19 public SearchabilityPoemTypeTest() {
20 }
21
22 public SearchabilityPoemTypeTest(String name) {
23 super(name);
24 }
25
26 void setObjectUnderTest() {
27 it = new SearchabilityPoemType();
28 }
29
30
31
32
33 public void testToString() {
34 assertEquals("searchability (INT (org.melati.poem.SearchabilityPoemType))", it.toString());
35 }
36
37 public void testRawOfCooked() {
38 super.testRawOfCooked();
39 assertEquals(Searchability.primary.getIndex(),
40 it.rawOfCooked(Searchability.primary));
41 }
42
43 public void testPossibleRaws() {
44 Enumeration<Integer> them = it.possibleRaws();
45 int count = 0;
46 while(them.hasMoreElements()) {
47 them.nextElement();
48 count++;
49 }
50 assertEquals(3,count);
51 }
52
53 public void testStringOfCooked() {
54 super.testStringOfCooked();
55 assertEquals("primary",
56 it.stringOfCooked(Searchability.primary, PoemLocale.HERE, DateFormat.MEDIUM));
57 }
58
59 public void testCanRepresent() {
60 assertNull(it.canRepresent(new DisplayLevelPoemType()));
61 }
62
63
64
65
66 public void testNamed() {
67 assertEquals(Searchability.primary, Searchability.named("primary"));
68 try {
69 Searchability.named("kk");
70 fail("should have blown up");
71 } catch (NameUnrecognisedException e) {
72 e = null;
73 }
74 }
75 }