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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 junit.framework.TestCase;
  7. /**
  8. * @author Tim McCune
  9. */
  10. public class TableTest extends TestCase {
  11. public TableTest(String name) {
  12. super(name);
  13. }
  14. public void testCreateRow() throws Exception {
  15. Table table = new Table();
  16. List<Column> columns = new ArrayList<Column>();
  17. Column col = new Column();
  18. col.setType(DataType.INT);
  19. columns.add(col);
  20. col = new Column();
  21. col.setType(DataType.TEXT);
  22. columns.add(col);
  23. columns.add(col);
  24. table.setColumns(columns);
  25. int colCount = 3;
  26. Object[] row = new Object[colCount];
  27. row[0] = new Short((short) 9);
  28. row[1] = "Tim";
  29. row[2] = "McCune";
  30. ByteBuffer buffer = table.createRow(row);
  31. assertEquals((short) colCount, buffer.getShort());
  32. assertEquals((short) 9, buffer.getShort());
  33. assertEquals((byte) 'T', buffer.get());
  34. assertEquals((short) 22, buffer.getShort(22));
  35. assertEquals((short) 10, buffer.getShort(24));
  36. assertEquals((short) 4, buffer.getShort(26));
  37. assertEquals((short) 2, buffer.getShort(28));
  38. assertEquals((byte) 7, buffer.get(30));
  39. }
  40. }