You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TableTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2004 Health Market Science, Inc.
  2. package com.healthmarketscience.jackcess;
  3. import java.nio.ByteBuffer;
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import com.healthmarketscience.jackcess.Column;
  7. import com.healthmarketscience.jackcess.DataTypes;
  8. import com.healthmarketscience.jackcess.Table;
  9. import junit.framework.TestCase;
  10. /**
  11. * @author Tim McCune
  12. */
  13. public class TableTest extends TestCase {
  14. public TableTest(String name) {
  15. super(name);
  16. }
  17. public void testCreateRow() throws Exception {
  18. Table table = new Table();
  19. List columns = new ArrayList();
  20. Column col = new Column();
  21. col.setType(DataTypes.INT);
  22. columns.add(col);
  23. col = new Column();
  24. col.setType(DataTypes.TEXT);
  25. columns.add(col);
  26. columns.add(col);
  27. table.setColumns(columns);
  28. int colCount = 3;
  29. Object[] row = new Object[colCount];
  30. row[0] = new Short((short) 9);
  31. row[1] = "Tim";
  32. row[2] = "McCune";
  33. ByteBuffer buffer = table.createRow(row);
  34. assertEquals((short) colCount, buffer.getShort());
  35. assertEquals((short) 9, buffer.getShort());
  36. assertEquals((byte) 'T', buffer.get());
  37. assertEquals((short) 22, buffer.getShort(22));
  38. assertEquals((short) 10, buffer.getShort(24));
  39. assertEquals((short) 4, buffer.getShort(26));
  40. assertEquals((short) 2, buffer.getShort(28));
  41. assertEquals((byte) 7, buffer.get(30));
  42. }
  43. }