aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-10-14 10:11:23 +0000
committerJaven O'Neal <onealj@apache.org>2016-10-14 10:11:23 +0000
commit5216731bfda6979378a2da12ae4dd698790720e1 (patch)
tree5145c59a422fcb446cd92bab31981c998b4b1db0 /src/testcases/org/apache/poi/ss
parentb6e6b8c922694a86cebe9843bfe6873d312b2065 (diff)
downloadpoi-5216731bfda6979378a2da12ae4dd698790720e1.tar.gz
poi-5216731bfda6979378a2da12ae4dd698790720e1.zip
bug 56781,60246: fix named range validation to match valid name rules per Excel docs
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1764854 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
index 92e362df57..1bb73f9f5e 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestNamedRange.java
@@ -673,22 +673,33 @@ public abstract class BaseTestNamedRange {
wb.close();
}
+ // bug 56781: name validation only checks for first character's validity and presence of spaces
+ // bug 60246: validate name does not allow DOT in named ranges
@Test
- public void test56781() throws IOException {
+ public void testValid() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Name name = wb.createName();
for (String valid : Arrays.asList(
"Hello",
"number1",
- "_underscore"
- //"p.e.r.o.i.d.s",
- //"\\Backslash",
- //"Backslash\\"
+ "_underscore",
+ "underscore_",
+ "p.e.r.o.i.d.s",
+ "\\Backslash",
+ "Backslash\\"
)) {
name.setNameName(valid);
}
+ wb.close();
+ }
+
+ @Test
+ public void testInvalid() throws IOException {
+ Workbook wb = _testDataProvider.createWorkbook();
+
+ Name name = wb.createName();
try {
name.setNameName("");
fail("expected exception: (blank)");
@@ -704,7 +715,18 @@ public abstract class BaseTestNamedRange {
"Colon:",
"A-Minus",
"A+Plus",
- "Dollar$")) {
+ "Dollar$",
+ ".periodAtBeginning",
+ "R", //special shorthand
+ "C", //special shorthand
+ "A1", // A1-style cell reference
+ "R1C1", // R1C1-style cell reference
+ "NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters..."+
+ "NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters..."+
+ "NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters..."+
+ "NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters..."+
+ "NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters.NameThatIsLongerThan255Characters"
+ )) {
try {
name.setNameName(invalid);
fail("expected exception: " + invalid);