Skip to content

Commit

Permalink
add union type to all_types test
Browse files Browse the repository at this point in the history
  • Loading branch information
jraymakers committed Dec 23, 2023
1 parent 22de5b3 commit b4b574d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/duckdb-wasm/test/all_types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const FULLY_IMPLEMENTED_ANSWER_MAP: AnswerObjectType = {
// Note that we multiply by thousand (and add 999 for the max) because the value returned by DuckDB is in microseconds,
// whereas the Date object is in milliseconds.
time: [BigInt(0), BigInt(new Date('1970-01-01T23:59:59.999+00:00').valueOf()) * BigInt(1000) + BigInt(999), null],
interval: [new Int32Array([0,0]), new Int32Array([0,0]), null],
interval: [new Int32Array([0, 0]), new Int32Array([0, 0]), null],

float: [-3.4028234663852886e38, 3.4028234663852886e38, null],
double: [-1.7976931348623157e308, 1.7976931348623157e308, null],
Expand Down Expand Up @@ -112,6 +112,8 @@ const FULLY_IMPLEMENTED_ANSWER_MAP: AnswerObjectType = {
Uint8Array.from([0, 0, 0, 97]),
null,
],

union: ['Frank', 5, null],
};

// Replacements for the values we knowingly don't support from the test_all_types query
Expand Down Expand Up @@ -215,22 +217,19 @@ export function testAllTypes(db: () => duckdb.DuckDBBindings): void {
}
for (let i = 0; i < results.numCols; i++) {
const name = results.schema.fields[i].name;
if (name == "bit")
continue;
if (name == 'bit') continue;
const col = results.getChildAt(i);
if (skip.get(name)) continue;
expect(col).not.toBeNull();
expect(col?.length).not.toEqual(0);

expect(unpack(getValue(col!.get(0))))
.withContext(name)
.toEqual(test.answerMap[name][0]); // Min
.withContext(name)
.toEqual(test.answerMap[name][0]); // Min
expect(unpack(getValue(col!.get(1))))
.withContext(name)
.toEqual(test.answerMap[name][1]); // Max
expect(col!.get(2))
.withContext(name)
.toEqual(test.answerMap[name][2]); // Null
.withContext(name)
.toEqual(test.answerMap[name][1]); // Max
expect(col!.get(2)).withContext(name).toEqual(test.answerMap[name][2]); // Null
}
});
}
Expand Down Expand Up @@ -267,8 +266,7 @@ export function testAllTypesAsync(db: () => duckdb.AsyncDuckDB): void {
}
for (let i = 0; i < results.numCols; i++) {
const name = results.schema.fields[i].name;
if (name == "bit")
continue;
if (name == 'bit') continue;
const col = results.getChildAt(i);
if (skip.get(name)) continue;
expect(col).not.toBeNull();
Expand Down

0 comments on commit b4b574d

Please sign in to comment.