Changeset 96 for trunk/tests
- Timestamp:
- 06/10/08 10:01:16 (16 years ago)
- Location:
- trunk/tests/org/expeditee
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/org/expeditee/gui/AttributeUtilsTest.java
r95 r96 1 1 package org.expeditee.gui; 2 2 3 import java.awt.Color; 4 3 5 import junit.framework.TestCase; 6 7 import org.expeditee.items.Text; 4 8 5 9 public class AttributeUtilsTest extends TestCase { 6 10 7 11 public final void testExtractAttributes() { 8 //fail("Not yet implemented");12 assertEquals(null, AttributeUtils.extractAttributes(null)); 9 13 } 10 14 11 15 public final void testSetAttribute() { 12 //fail("Not yet implemented"); 16 Text attributes = new Text(-1, "s:50"); 17 18 assertFalse( AttributeUtils.setAttribute(null,attributes)); 19 assertFalse( AttributeUtils.setAttribute(attributes,null)); 20 21 assertTrue( AttributeUtils.setAttribute(attributes, attributes)); 22 assertEquals(50, attributes.getSize()); 23 attributes.setText("size:25"); 24 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); 25 assertEquals(25, attributes.getSize()); 26 27 attributes.setText("c:red"); 28 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); 29 assertEquals(Color.red, attributes.getColor()); 30 attributes.setText("color:green"); 31 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); 32 assertEquals(Color.green, attributes.getColor()); 13 33 } 14 34 15 35 public final void testGetValue() { 16 String[][] data = new String[][]{ 17 {"Att: Value1", "Value1"}, 18 {" Att : Value2 ", "Value2"}, 19 {"@NoValue",""}, 20 {" @VaLuE ", "@VaLuE"}, 21 {"@Value : : : value3", "value3"}, 22 {"Att: value4 \nA comment", "value4 \nA comment"} 23 }; 24 for(int i = 0; i < data.length; i++){ 36 String[][] data = new String[][] { 37 { "Att:Value1", "Value1" }, 38 { " Att : Value2 ", "Value2" }, 39 { "@NoValue", "" }, 40 { " @NoVaLuE ", "" }, 41 { "@Value : : : value3", "value3" }, 42 { " ", "" }, 43 { "Att: value4 " + (char)Character.LINE_SEPARATOR + "A comment", 44 "value4" } }; 45 for (int i = 0; i < data.length; i++) { 25 46 assertEquals(data[i][1], AttributeUtils.getValue(data[i][0])); 26 47 } … … 28 49 29 50 public final void testGetAttribute() { 30 String[][] data = new String[][]{ 31 {"AtT1: Value1", "AtT1"}, 32 {" Att2 : Value2 ", "Att2"}, 33 {"@NoValue",null}, 34 {" @Att3 : Value ", "@Att3"}, 35 {" : value3", null}, 36 {"Att4 : test : value4", "Att4"} 37 }; 38 for(int i = 0; i < data.length; i++){ 51 String[][] data = new String[][] { { "AtT1: Value1", "AtT1" }, 52 { " Att2 : Value2 ", "Att2" }, { "@NoValue", null }, 53 { "@Att3 : Value", null }, { "@ Att3: Value", null }, 54 { " @Att3: Value ", "@Att3" }, { ": value3", null }, 55 { "@1Test: value3", null }, { "@t est: value3", null }, 56 { "Att4 : test : value4", "Att4" } }; 57 for (int i = 0; i < data.length; i++) { 39 58 assertEquals(data[i][1], AttributeUtils.getAttribute(data[i][0])); 40 59 } 41 60 } 42 61 43 public final void testSetSingleValue() { 44 //fail("Not yet implemented"); 62 public final void testReplaceValue() { 63 String[][] data = new String[][] { 64 { "AtT1: Value1", "NewValue", "AtT1: NewValue" }, 65 { " Att2 : Value2 ", "Att2", "Att2: Att2" }, 66 { " @NoValue ", " 15", "@NoValue: 15" } }; 67 Text test = new Text(-1); 68 69 for (int i = 0; i < data.length; i++) { 70 test.setText(data[i][0]); 71 AttributeUtils.replaceValue(test, data[i][1]); 72 assertEquals(data[i][2], test.getText()); 73 } 45 74 } 46 75 47 76 public final void testGetDoubleValue() { 48 //fail("Not yet implemented"); 77 Object[][] data = new Object[][] { { "AtT1: Value1", null }, 78 { " Att2 : 3.5 ", 3.5 }, { "@NoValue", null } }; 79 for (int i = 0; i < data.length; i++) { 80 assertEquals(data[i][1], AttributeUtils.getDoubleValue(data[i][0] 81 .toString())); 82 } 49 83 } 50 84 -
trunk/tests/org/expeditee/io/ConversionTest.java
r86 r96 11 11 12 12 import org.expeditee.items.Item; 13 import org.expeditee.items.Justification; 13 14 import org.expeditee.items.Text; 14 15 … … 105 106 106 107 public final void testGetFrameset() { 107 assertTrue(Conversion.getFrameset("a1").equals("a")); 108 assertTrue(Conversion.getFrameset("a91").equals("a")); 109 assertTrue(Conversion.getFrameset("Aa1C1").equals("aa1c")); 110 assertTrue(Conversion.getFrameset("Aa1C1", false).equals("Aa1C")); 111 assertTrue(Conversion.getFrameset("Abc1C1", true).equals( 112 Conversion.getFrameset("Abc1C1"))); 113 } 114 115 public final void testGetJustification() { 116 assertEquals(Item.JUSTIFICATION_CENTER, Conversion 117 .getJustification("center")); 118 assertEquals(Item.JUSTIFICATION_CENTER, Conversion 119 .getJustification("c")); 120 assertEquals(Item.JUSTIFICATION_RIGHT, Conversion.getJustification("R")); 121 assertEquals(Item.JUSTIFICATION_RIGHT, Conversion 122 .getJustification("RIGHT")); 123 assertEquals(Item.JUSTIFICATION_LEFT, Conversion.getJustification("L")); 124 assertEquals(Item.JUSTIFICATION_LEFT, Conversion 125 .getJustification("lEfT")); 126 assertEquals(Item.JUSTIFICATION_FULL, Conversion.getJustification("f")); 127 assertEquals(Item.JUSTIFICATION_FULL, Conversion 128 .getJustification("FuLl")); 129 assertEquals(Item.JUSTIFICATION_NONE, Conversion 130 .getJustification("NONE")); 131 } 132 133 public final void testGetExpediteeJustificationCode() { 134 assertEquals("C", Conversion 135 .getExpediteeJustificationCode(Item.JUSTIFICATION_CENTER)); 136 assertEquals("L", Conversion 137 .getExpediteeJustificationCode(Item.JUSTIFICATION_LEFT)); 138 assertEquals("R", Conversion 139 .getExpediteeJustificationCode(Item.JUSTIFICATION_RIGHT)); 140 assertEquals("F", Conversion 141 .getExpediteeJustificationCode(Item.JUSTIFICATION_FULL)); 142 assertEquals(null, Conversion 143 .getExpediteeJustificationCode(Item.JUSTIFICATION_NONE)); 144 assertEquals(null, Conversion 145 .getExpediteeJustificationCode(Integer.MAX_VALUE)); 146 assertEquals(null, Conversion 147 .getExpediteeJustificationCode(Integer.MIN_VALUE)); 108 assertTrue(Conversion.getFramesetName("a1").equals("a")); 109 assertTrue(Conversion.getFramesetName("a91").equals("a")); 110 assertTrue(Conversion.getFramesetName("Aa1C1").equals("aa1c")); 111 assertTrue(Conversion.getFramesetName("Aa1C1", false).equals("Aa1C")); 112 assertTrue(Conversion.getFramesetName("Abc1C1", true).equals( 113 Conversion.getFramesetName("Abc1C1"))); 148 114 } 149 115 … … 228 194 new Class[] { Point.class }); 229 195 Method setJustification = Text.class.getMethod("setJustification", 230 new Class[] { int.class });196 new Class[] { Justification.class }); 231 197 Method setArrow = Text.class.getMethod("setArrow", new Class[] { 232 198 int.class, double.class }); … … 250 216 null); 251 217 assertEquals(1, result.length); 252 assertEquals( Conversion.getJustification(justificationCode),218 assertEquals(Justification.getJustification(justificationCode), 253 219 result[0]); 254 220 … … 257 223 .Convert(setJustification, justificationCode, ""); 258 224 assertEquals(1, result.length); 259 assertEquals( Conversion.getJustification(justificationCode),225 assertEquals(Justification.getJustification(justificationCode), 260 226 result[0]); 261 227 … … 305 271 "getJustification", new Class[] {}); 306 272 307 assertEquals( "C", Conversion.ConvertToExpeditee(getJustification,308 Item.JUSTIFICATION_CENTER));273 assertEquals('C', Conversion.ConvertToExpeditee(getJustification, 274 Justification.center)); 309 275 310 276 assertEquals("Test", Conversion.ConvertToExpeditee(getPosition,
Note:
See TracChangeset
for help on using the changeset viewer.