summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorreger <reger18@arcor.de>2016-11-06 03:34:24 +0100
committerreger <reger18@arcor.de>2016-11-06 03:34:24 +0100
commitc9e81d2fa074f58d4ed1d511bfa71e091d7bca70 (patch)
treea212e1631e39b2049a885cfa5f45260610e0905c /test
parente0816ef2e5dfe812fa076baa10e0d84912a69922 (diff)
fix Column parsing from celldefinition string, without cellwidth def.
(outofbound exception)
Diffstat (limited to 'test')
-rw-r--r--test/java/net/yacy/kelondro/index/ColumnTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/java/net/yacy/kelondro/index/ColumnTest.java b/test/java/net/yacy/kelondro/index/ColumnTest.java
new file mode 100644
index 000000000..e0cedcfb5
--- /dev/null
+++ b/test/java/net/yacy/kelondro/index/ColumnTest.java
@@ -0,0 +1,55 @@
+/**
+ * ColumnTest.java
+ * part of YaCy
+ * Copyright 2016 by reger24; https://github.com/reger24
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.yacy.kelondro.index;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Unit tests for ColumnTest class.
+ */
+public class ColumnTest {
+
+
+ /**
+ * Test of cell definition parsing and cellwidth assignment, of class Column.
+ */
+ @Test
+ public void testCellWidth() {
+ // test cell definition
+ // key=definition string, value= expected cellwidth
+ Map<String, Integer> testcelldefs = new HashMap<String, Integer>();
+ testcelldefs.put("long countA {b256}", 8); // simple
+ testcelldefs.put("long countB-8 {b256}",8); // redundant cellwidth
+ testcelldefs.put("long countC {b256}", 8); // spaces between definition
+ testcelldefs.put("long countD {b256} \"Description\"", 8);
+ testcelldefs.put("<long countE {b256} \"Description\">", 8);
+ testcelldefs.put("int icountA {b256}", 4);
+
+ for (String celldef:testcelldefs.keySet()) {
+ Column col = new Column(celldef);
+ Integer expectedCellWidth = testcelldefs.get(celldef);
+ assertEquals (celldef,expectedCellWidth.intValue(), col.cellwidth);
+ }
+ }
+
+}