Skip to content

Commit

Permalink
add test cases for ZSS-502
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkchen committed Nov 4, 2013
1 parent 733fdfa commit b706bdb
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions zss.test/src/test/java/org/zkoss/zss/api/impl/Issue500Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package org.zkoss.zss.api.impl;

import static org.junit.Assert.assertEquals;

import java.util.Locale;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.zkoss.zss.Setup;
import org.zkoss.zss.Util;
import org.zkoss.zss.api.Range;
import org.zkoss.zss.api.Ranges;
import org.zkoss.zss.api.model.Book;
import org.zkoss.zss.api.model.Sheet;

/**
* @author Hawk
*
*/
public class Issue500Test {

@BeforeClass
public static void setUpLibrary() throws Exception {
Setup.touch();
}

@Before
public void startUp() throws Exception {
Setup.pushZssContextLocale(Locale.TAIWAN);
}

@After
public void tearDown() throws Exception {
Setup.popZssContextLocale();
}


@Test
public void testZSS502_2003(){
Book book = Util.loadBook(this,"book/502-crossSheetReference.xls");
Sheet sheet = book.getSheet("cell-reference");
Range referencingCell = Ranges.range(sheet, "C4");
assertEquals("=row!A1", referencingCell.getCellEditText());
assertEquals("The first row is freezed.", referencingCell.getCellFormatText());

Ranges.range(book.getSheet("row")).deleteSheet();

assertEquals("='#REF'!A1", referencingCell.getCellEditText());
//because ZSS-474 is unresolved, the assert below won't pass
//assertEquals("#REF", referencingCell.getCellFormatText());
}

@Test
public void testZSS502_2007(){
Book book = Util.loadBook(this,"book/502-crossSheetReference.xlsx");
Sheet sheet = book.getSheet("cell-reference");
Range referencingCell = Ranges.range(sheet, "C4");
assertEquals("=row!A1", referencingCell.getCellEditText());
assertEquals("The first row is freezed.", referencingCell.getCellFormatText());

Ranges.range(book.getSheet("row")).deleteSheet();

assertEquals("=row!A1", referencingCell.getCellEditText());
//because ZSS-474 is unresolved, the assert below won't pass
// assertEquals("#REF", referencingCell.getCellFormatText());
}


@Test
public void testZSS502_NonExistingSheet2003(){
Book book = Util.loadBook(this,"book/blank.xls");
Sheet sheet = book.getSheetAt(0);
Range cell = Ranges.range(sheet, "A1");
cell.setCellEditText("=nonExisted!B1");
assertEquals("='#REF'!B1", cell.getCellEditText());
assertEquals("#REF!", cell.getCellFormatText());
}

@Test
public void testZSS502_NonExistingSheet2007(){
Book book = Util.loadBook(this,"book/blank.xlsx");
Sheet sheet = book.getSheetAt(0);
Range cell = Ranges.range(sheet, "A1");
cell.setCellEditText("=nonExisted!B1");
assertEquals("=nonExisted!B1", cell.getCellEditText());
assertEquals("#REF!", cell.getCellFormatText());
}
}
Binary file not shown.
Binary file not shown.

0 comments on commit b706bdb

Please sign in to comment.