Changeset 234 for trunk/tests
- Timestamp:
- 08/19/08 14:11:51 (16 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/org/expeditee/gui/AttributeValuePairTest.java
r227 r234 7 7 import org.expeditee.items.Text; 8 8 9 public class Attribute UtilsTest extends TestCase {9 public class AttributeValuePairTest extends TestCase { 10 10 11 11 public final void testExtractAttributes() { … … 14 14 15 15 public final void testSetAttribute() { 16 Text attributes = new Text("s:50"); 17 18 assertFalse( AttributeUtils.setAttribute(null,attributes)); 19 assertFalse( AttributeUtils.setAttribute(attributes,null)); 20 21 assertTrue( AttributeUtils.setAttribute(attributes, attributes)); 16 Text attributes = new Text(""); 17 Text text = new Text("Test"); 18 19 assertFalse(AttributeUtils.setAttribute(text, attributes)); 20 21 // Do a test with no attribute value pairs 22 attributes.setText("NO_AVP"); 23 assertFalse(AttributeUtils.setAttribute(text, attributes)); 24 25 assertFalse(AttributeUtils.setAttribute(null, attributes)); 26 assertFalse(AttributeUtils.setAttribute(attributes, null)); 27 28 attributes.setText("s:50"); 29 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); 22 30 assertEquals(50.0F, attributes.getSize()); 23 31 attributes.setText("size:25"); 24 32 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); 25 33 assertEquals(25.0F, attributes.getSize()); 26 34 27 35 attributes.setText("c:red"); 28 36 assertTrue(AttributeUtils.setAttribute(attributes, attributes)); … … 39 47 { "@NoValue", "" }, 40 48 { " @NoVaLuE ", "" }, 41 { "@Value : : : value3", "value3" }, 49 { "@Value : : : value3", "" }, 50 { "@Value: value3", "value3" }, 42 51 { " ", "" }, 43 { "Att: value4 " + (char)Character.LINE_SEPARATOR + "A comment", 44 "value4" } }; 52 { 53 "Att: value4 " + (char) Character.LINE_SEPARATOR 54 + "A comment", "value4" } }; 45 55 for (int i = 0; i < data.length; i++) { 46 assertEquals(data[i][1], AttributeUtils.getValue(data[i][0])); 56 AttributeValuePair avp = new AttributeValuePair(data[i][0]); 57 assertEquals(data[i][1], avp.getValue()); 47 58 } 48 59 } … … 50 61 public final void testGetAttribute() { 51 62 String[][] data = new String[][] { { "AtT1: Value1", "AtT1" }, 52 { " Att2 : Value2 ", "Att2" }, { "@NoValue", " @NoValue" },63 { " Att2 : Value2 ", "Att2" }, { "@NoValue", "NoValue" }, 53 64 { "@Att3 : Value", null }, { "@ Att3: Value", null }, 54 65 { " @Att3: Value ", "@Att3" }, { ": value3", null }, 55 66 { "@1Test: value3", null }, { "@t est: value3", null }, 56 { "Att4 : test : value4", "Att4" },{ "@", null },{ "a", null }, { "*!*", null } }; 67 { "Att4 : test : value4", "Att4 : test" }, { "@", null }, 68 { "a", null }, { "*!*", null }, { "*!*: @%@", "*!*" } }; 57 69 for (int i = 0; i < data.length; i++) { 58 assertEquals(data[i][1], AttributeUtils.getAttribute(data[i][0])); 70 // System.out.println("i = " + i); 71 AttributeValuePair avp = new AttributeValuePair(data[i][0]); 72 assertEquals(data[i][1], avp.getAttribute()); 59 73 } 60 74 } … … 64 78 { "AtT1: Value1", "NewValue", "AtT1: NewValue" }, 65 79 { " Att2 : Value2 ", "Att2", "Att2: Att2" }, 66 { " @NoValue ", " 15", "@NoValue: 15" } }; 80 { " @NoValue ", " 15", "@NoValue: 15" }, 81 { " 54 ", " 15", "54: 15" } }; 67 82 Text test = new Text(-1); 68 83 … … 75 90 76 91 public final void testGetDoubleValue() { 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())); 92 Object[][] validData = new Object[][] { { " Att2 : 3.5 ", 3.5 } }; 93 for (int i = 0; i < validData.length; i++) { 94 AttributeValuePair avp = new AttributeValuePair(validData[i][0] 95 .toString()); 96 assertEquals(validData[i][1], avp.getDoubleValue()); 97 } 98 Object[][] invalidData = new Object[][] { { "AtT1: Value1", null }, 99 { "@NoValue", null } }; 100 for (int i = 0; i < invalidData.length; i++) { 101 try { 102 AttributeValuePair avp = new AttributeValuePair( 103 invalidData[i][0].toString()); 104 avp.getDoubleValue(); 105 } catch (Exception e) { 106 continue; 107 } 108 fail(); 82 109 } 83 110 }
Note:
See TracChangeset
for help on using the changeset viewer.