Class AddressTest


  • class AddressTest
    extends java.lang.Object
    • Constructor Detail

      • AddressTest

        AddressTest()
    • Method Detail

      • getAddress

        @DisplayName("Should return a valid Address object according to the input data")
        @ParameterizedTest(name="Input column:{0}, row:{1}, address:{2}, type:{3}, should lead to an address: {6} (C:{4}/R:{5}) with type {7}")
        @CsvSource({"2,3,,,2,3,C4,Default","4,8,,FixedRow,4,8,E$9,FixedRow","0,0,X22,,23,21,X22,Default","0,0,C11,FixedColumn,2,10,$C11,FixedColumn","0,0,$F20,,5,19,$F20,FixedColumn","0,0,B$8,,1,7,B$8,FixedRow","0,0,$F$13,,5,12,$F$13,FixedRowAndColumn","0,0,A999,FixedRowAndColumn,0,998,$A$999,FixedRowAndColumn"})
        void getAddress​(int col,
                        int row,
                        java.lang.String addr,
                        Cell.AddressType type,
                        int expCol,
                        int expRow,
                        java.lang.String expAddr,
                        Cell.AddressType expType)
      • getColumn

        @DisplayName("Should return a valid column letter according to the input data")
        @ParameterizedTest(name="Input column:{0}, row:{1}, address:{2}, type:{3}, should lead to the column letter: {4}")
        @CsvSource({"2,3,,,C","4,8,,FixedRow,E","0,0,X22,,X","0,0,R21,FixedColumn,R","0,0,AAB99,FixedRowAndColumn,AAB"})
        void getColumn​(int col,
                       int row,
                       java.lang.String addr,
                       Cell.AddressType type,
                       java.lang.String expCol)
      • equalsTest

        @DisplayName("Should return true if (identical) input 1 and 2 are compared using the equals method")
        @ParameterizedTest(name="Input 1 (C:{0}; R:{1}; A:{2}; T:{3}) compared with input 2: (C:{4}; R:{5}; A:{6}; T:{7}) should lead to {8}")
        @CsvSource({"0,0,A1,FixedColumn,0,0,A1,FixedColumn,true","0,0,A1,FixedColumn,0,0,A1,FixedRow,true","1,2,,Default,0,0,B3,Default,true","1,2,,Default,0,0,B3,FixedRow,true","0,0,X11,FixedColumn,0,0,X12,FixedColumn,false","1,2,,Default,0,0,B4,Default,false","1,2,,FixedRow,0,0,B4,Default,false"})
        void equalsTest​(int col1,
                        int row1,
                        java.lang.String addr1,
                        Cell.AddressType type1,
                        int col2,
                        int row2,
                        java.lang.String addr2,
                        Cell.AddressType type2,
                        boolean expectedResult)
      • toStringTest

        @DisplayName("Should return the expected cell address as string")
        @ParameterizedTest(name="Address {0} (Type: {1}) should lead to a valid address string")
        @CsvSource({"A1,,A1","A1,Default,A1","B22,FixedRow,B$22","AX1,FixedColumn,$AX1","S775,FixedRowAndColumn,$S$775"})
        void toStringTest​(java.lang.String address,
                          Cell.AddressType type,
                          java.lang.String expectedString)
      • invalidTest

        @DisplayName("Should lead to an exception if an illegal address is defined")
        @ParameterizedTest(name="Address C:{0}; R:{1}; A:{2}; T:{3} should lead to an exception")
        @CsvSource({"0,0,TTTTTTT1,","0,0,$,Default","0,0,125475,","0,0,##15,","-10,0,,","12,-2,,Default","-1,-1,,FixedRow","99999999,22,,FixedColumn","0,0,\'\',Default"})
        void invalidTest​(int col,
                         int row,
                         java.lang.String address,
                         Cell.AddressType type)
      • buildAddress

        public static Address buildAddress​(int col,
                                           int row,
                                           java.lang.String addr,
                                           Cell.AddressType type)