Skip to content

Commit 05e19e0

Browse files
dfa1claude
andcommitted
test(cli): cover remaining extension + decimal render branches
GridRender: vortex.time (I32 ms), vortex.timestamp (I64 ms) and vortex.uuid (FixedSizeList(U8,16)) extension rendering via the decoder dtype factories. InspectorRender: GenericArray-backed decimal (single-buffer LE mantissa) and the bad-shape fallback path through tryDecimal. Leaves only the DecimalByteParts "null cell" branch uncovered — it needs a masked byte-parts fixture not worth the weight for one return. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a9bda35 commit 05e19e0

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

cli/src/test/java/io/github/dfa1/vortex/cli/tui/GridRenderTest.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
import io.github.dfa1.vortex.core.DType;
44
import io.github.dfa1.vortex.core.PType;
5+
import io.github.dfa1.vortex.encoding.TimeUnit;
56
import io.github.dfa1.vortex.reader.array.Array;
7+
import io.github.dfa1.vortex.reader.array.ByteArray;
8+
import io.github.dfa1.vortex.reader.array.FixedSizeListArray;
69
import io.github.dfa1.vortex.reader.array.IntArray;
710
import io.github.dfa1.vortex.reader.array.LazyConstantDecimalArray;
811
import io.github.dfa1.vortex.reader.array.LongArray;
912
import io.github.dfa1.vortex.reader.array.MaskedArray;
1013
import io.github.dfa1.vortex.reader.array.StructArray;
14+
import io.github.dfa1.vortex.reader.extension.TimeExtensionDecoder;
15+
import io.github.dfa1.vortex.reader.extension.TimestampExtensionDecoder;
16+
import io.github.dfa1.vortex.reader.extension.UuidExtensionDecoder;
1117
import org.junit.jupiter.api.Test;
1218

1319
import java.lang.foreign.Arena;
@@ -80,6 +86,45 @@ void rendersDateExtensionFromIntStorage() {
8086
}
8187
}
8288

89+
@Test
90+
void rendersTimeExtensionFromIntStorage() {
91+
try (Arena arena = Arena.ofConfined()) {
92+
// Given — vortex.time (ms unit) over I32 storage; 0 ms-of-day = midnight
93+
DType timeExt = TimeExtensionDecoder.INSTANCE.dtype(TimeUnit.Milliseconds, false);
94+
IntArray storage = ArrayFixtures.ints(arena, 0);
95+
96+
// When / Then
97+
assertThat(GridRender.formatCell(storage, 0, timeExt)).isEqualTo("00:00");
98+
}
99+
}
100+
101+
@Test
102+
void rendersTimestampExtensionFromLongStorage() {
103+
try (Arena arena = Arena.ofConfined()) {
104+
// Given — vortex.timestamp (ms unit, no tz) over I64 storage; 0 ms = the epoch
105+
DType tsExt = TimestampExtensionDecoder.INSTANCE.dtype(TimeUnit.Milliseconds, null, false);
106+
LongArray storage = ArrayFixtures.longs(arena, 0L);
107+
108+
// When / Then
109+
assertThat(GridRender.formatCell(storage, 0, tsExt)).isEqualTo("1970-01-01T00:00:00Z");
110+
}
111+
}
112+
113+
@Test
114+
void rendersUuidExtensionFromFixedSizeListStorage() {
115+
try (Arena arena = Arena.ofConfined()) {
116+
// Given — vortex.uuid over FixedSizeList(U8,16); all-zero bytes = the nil UUID
117+
DType uuidExt = UuidExtensionDecoder.INSTANCE.dtype(false);
118+
ByteArray elems = ArrayFixtures.bytes(arena, new byte[16]);
119+
FixedSizeListArray storage = new FixedSizeListArray(
120+
new DType.FixedSizeList(new DType.Primitive(PType.U8, false), 16, false), 1, elems);
121+
122+
// When / Then
123+
assertThat(GridRender.formatCell(storage, 0, uuidExt))
124+
.isEqualTo("00000000-0000-0000-0000-000000000000");
125+
}
126+
}
127+
83128
@Test
84129
void maskedNullCellRendersEmpty() {
85130
try (Arena arena = Arena.ofConfined()) {

cli/src/test/java/io/github/dfa1/vortex/cli/tui/InspectorRenderTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.github.dfa1.vortex.core.DType;
44
import io.github.dfa1.vortex.core.PType;
55
import io.github.dfa1.vortex.reader.array.Array;
6+
import io.github.dfa1.vortex.reader.array.GenericArray;
67
import io.github.dfa1.vortex.reader.array.IntArray;
78
import io.github.dfa1.vortex.reader.array.LazyConstantDecimalArray;
89
import io.github.dfa1.vortex.reader.array.MaskedArray;
@@ -11,6 +12,8 @@
1112
import org.junit.jupiter.api.Test;
1213

1314
import java.lang.foreign.Arena;
15+
import java.lang.foreign.MemorySegment;
16+
import java.lang.foreign.ValueLayout;
1417
import java.math.BigDecimal;
1518
import java.util.List;
1619

@@ -57,6 +60,33 @@ void rendersDecimal() {
5760
assertThat(InspectorRender.formatValue(sut, 0, decimal)).isEqualTo("3.14");
5861
}
5962

63+
@Test
64+
void rendersGenericArrayDecimal() {
65+
try (Arena arena = Arena.ofConfined()) {
66+
// Given — GenericArray over an 8-byte LE mantissa 123 at scale 2 → 1.23
67+
DType decimal = new DType.Decimal((byte) 10, (byte) 2, false);
68+
MemorySegment buf = arena.allocate(8, 8);
69+
buf.setAtIndex(ValueLayout.JAVA_LONG, 0, 123L);
70+
Array sut = new GenericArray(decimal, 1, buf.asReadOnly());
71+
72+
// When / Then
73+
assertThat(InspectorRender.formatValue(sut, 0, decimal)).isEqualTo("1.23");
74+
}
75+
}
76+
77+
@Test
78+
void genericArrayDecimalBadShapeRendersFallback() {
79+
try (Arena arena = Arena.ofConfined()) {
80+
// Given — two buffers: getDecimal rejects the shape with a non-"null cell" error
81+
DType decimal = new DType.Decimal((byte) 10, (byte) 2, false);
82+
MemorySegment buf = arena.allocate(8, 8);
83+
Array sut = new GenericArray(decimal, 1, new MemorySegment[]{buf, buf}, new Array[0]);
84+
85+
// When / Then — tryDecimal swallows it into the <ClassName dtype> fallback
86+
assertThat(InspectorRender.formatValue(sut, 0, decimal)).startsWith("<GenericArray");
87+
}
88+
}
89+
6090
@Test
6191
void rendersDateExtension() {
6292
try (Arena arena = Arena.ofConfined()) {

0 commit comments

Comments
 (0)