Changeset 96 for trunk/tests


Ignore:
Timestamp:
06/10/08 10:01:16 (16 years ago)
Author:
ra33
Message:

Updated tests

Location:
trunk/tests/org/expeditee
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/org/expeditee/gui/AttributeUtilsTest.java

    r95 r96  
    11package org.expeditee.gui;
    22
     3import java.awt.Color;
     4
    35import junit.framework.TestCase;
     6
     7import org.expeditee.items.Text;
    48
    59public class AttributeUtilsTest extends TestCase {
    610
    711        public final void testExtractAttributes() {
    8                 //fail("Not yet implemented");
     12                assertEquals(null, AttributeUtils.extractAttributes(null));
    913        }
    1014
    1115        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());
    1333        }
    1434
    1535        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++) {
    2546                        assertEquals(data[i][1], AttributeUtils.getValue(data[i][0]));
    2647                }
     
    2849
    2950        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++) {
    3958                        assertEquals(data[i][1], AttributeUtils.getAttribute(data[i][0]));
    4059                }
    4160        }
    4261
    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                }
    4574        }
    4675
    4776        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                }
    4983        }
    5084
  • trunk/tests/org/expeditee/io/ConversionTest.java

    r86 r96  
    1111
    1212import org.expeditee.items.Item;
     13import org.expeditee.items.Justification;
    1314import org.expeditee.items.Text;
    1415
     
    105106
    106107        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")));
    148114        }
    149115
     
    228194                                        new Class[] { Point.class });
    229195                        Method setJustification = Text.class.getMethod("setJustification",
    230                                         new Class[] { int.class });
     196                                        new Class[] { Justification.class });
    231197                        Method setArrow = Text.class.getMethod("setArrow", new Class[] {
    232198                                        int.class, double.class });
     
    250216                                        null);
    251217                        assertEquals(1, result.length);
    252                         assertEquals(Conversion.getJustification(justificationCode),
     218                        assertEquals(Justification.getJustification(justificationCode),
    253219                                        result[0]);
    254220
     
    257223                                        .Convert(setJustification, justificationCode, "");
    258224                        assertEquals(1, result.length);
    259                         assertEquals(Conversion.getJustification(justificationCode),
     225                        assertEquals(Justification.getJustification(justificationCode),
    260226                                        result[0]);
    261227
     
    305271                                        "getJustification", new Class[] {});
    306272
    307                         assertEquals("C", Conversion.ConvertToExpeditee(getJustification,
    308                                         Item.JUSTIFICATION_CENTER));
     273                        assertEquals('C', Conversion.ConvertToExpeditee(getJustification,
     274                                        Justification.center));
    309275
    310276                        assertEquals("Test", Conversion.ConvertToExpeditee(getPosition,
Note: See TracChangeset for help on using the changeset viewer.