b.addCol("area");
b.addRow(new HVal[] { HRef.make("a"), HStr.make("Alpha"), HNum.make(1200) });
b.addRow(new HVal[] { HRef.make("b"), HStr.make("Beta"), null });
// meta
HGrid g = b.toGrid();
verifyEq(g.meta().size(), 0);
// cols
verifyEq(g.numCols(), 3);
verifyCol(g, 0, "id");
verifyCol(g, 1, "dis");
verifyCol(g, 2, "area");
// rows
verifyEq(g.numRows(), 2);
verifyEq(g.isEmpty(), false);
HRow r;
r = g.row(0);
verifyEq(r.get("id"), HRef.make("a"));
verifyEq(r.get("dis"), HStr.make("Alpha"));
verifyEq(r.get("area"), HNum.make(1200));
r = g.row(1);
verifyEq(r.get("id"), HRef.make("b"));
verifyEq(r.get("dis"), HStr.make("Beta"));
verifyEq(r.get("area", false), null);
try {
r.get("area");
fail();
}
catch (UnknownNameException e) {
verifyException(e);
}
verifyEq(r.get("fooBar", false), null);
try {
r.get("fooBar");
fail();
}
catch (UnknownNameException e) {
verifyException(e);
}
// HRow.iterator no-nulls
Iterator<Entry<String, HVal>> it = g.row(0).iterator();
verifyRowIterator(it, "id", HRef.make("a"));
verifyRowIterator(it, "dis", HStr.make("Alpha"));
verifyRowIterator(it, "area", HNum.make(1200));
verifyEq(it.hasNext(), false);
// HRow.iterator with nulls
it = g.row(1).iterator();
verifyRowIterator(it, "id", HRef.make("b"));
verifyRowIterator(it, "dis", HStr.make("Beta"));
verifyEq(it.hasNext(), false);
// iterator