瀏覽代碼

add some unit test for property type inference

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@871 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/jackcess-2.0.5
James Ahlborn 9 年之前
父節點
當前提交
7d4abaafe2

+ 3
- 0
TODO.txt 查看文件

- numeric data has embedded precision/scale, something else? only last 8 - numeric data has embedded precision/scale, something else? only last 8
bytes is data? implicit precision of 18 for "pure" numeric? implicit bytes is data? implicit precision of 18 for "pure" numeric? implicit
precision of 15 for double-ish numeric? precision of 15 for double-ish numeric?
- ***add unit tests
- ***ability to create calculated columns!


- add properties on table/column creation - add properties on table/column creation
- add unit tests


- calculated fields in queries? (2003+), w/ aliases? - calculated fields in queries? (2003+), w/ aliases?



+ 3
- 2
src/main/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java 查看文件

Object value) { Object value) {
if(type == null) { if(type == null) {
// attempt to figure out the type
type = DEFAULT_TYPES.get(type);
// attempt to get the default type for this property
type = DEFAULT_TYPES.get(name);


if(type == null) { if(type == null) {
// choose the type based on the value
if(value instanceof String) { if(value instanceof String) {
type = DataType.TEXT; type = DataType.TEXT;
} else if(value instanceof Boolean) { } else if(value instanceof Boolean) {

+ 18
- 0
src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java 查看文件

colMap.get("buzz")), props); colMap.get("buzz")), props);
} }


public void testInferTypes() throws Exception
{
PropertyMaps maps = new PropertyMaps(10, null, null);
PropertyMap defMap = maps.getDefault();

assertEquals(DataType.TEXT,
defMap.put(PropertyMap.FORMAT_PROP, null).getType());
assertEquals(DataType.BOOLEAN,
defMap.put(PropertyMap.REQUIRED_PROP, null).getType());

assertEquals(DataType.TEXT,
defMap.put("strprop", "this is a string").getType());
assertEquals(DataType.BOOLEAN,
defMap.put("boolprop", true).getType());
assertEquals(DataType.LONG,
defMap.put("intprop", 37).getType());
}

public void testReadProperties() throws Exception public void testReadProperties() throws Exception
{ {
byte[] nameMapBytes = null; byte[] nameMapBytes = null;

Loading…
取消
儲存