Skip to content

Commit 7b90111

Browse files
authored
Merge pull request #286 from tedd/fix-table-heavy-separators-3537628775893930386
Fix Table BoxStyle.Heavy body separators and add validator tests
2 parents ca7524e + 0ac25c0 commit 7b90111

4 files changed

Lines changed: 74 additions & 5 deletions

File tree

.jules/validator.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
## 2024-05-24 - Exhaustive Spatial and Hierarchical Validation of Table Component
22
**Observation:** Auditing the `Table` component revealed requirements for robust testing against extreme constraints and explicit character verifications, especially when `BoxStyle.Heavy` is enabled. Traditional tests do not adequately cover the absolute positional accuracy of characters under dynamic grid-based hierarchical structures, nor do they isolate rendering behaviors when constrained to extremely tight boundaries (e.g., `Size(0,0)`). The control encapsulates complex subcomponents such as `ScrollViewer`, `TableRow`, and internal layout logic.
33
**Strategic Action:** Developed an exhaustive validation suite (`ValidatorTableTests.cs`) under the xUnit framework. The matrix enforces: 1) Hierarchical Composition and Dynamic Mutation validation by embedding the `Table` alongside a `Border` within a proportionally-sized `Grid` and verifying structural integrity upon parent resize. 2) Coordinate-Precise Assertion evaluating the exact mapped placement of Unicode Box Drawing (`Heavy` style) symbols (e.g., `\u250F`, `\u2523`) against a `VirtualBuffer`. 3) Boundary verification enforcing correct behavior at `0x0` and `1x1` dimensions.
4+
## 2024-05-24 - Exhaustive Spatial and Hierarchical Validation of Table Component Body Separation
5+
**Observation:** Auditing the `Table` component revealed requirements for robust testing against extreme constraints and explicit character verifications, especially when `BoxStyle.Heavy` is enabled. Traditional tests do not adequately cover the absolute positional accuracy of characters under dynamic grid-based hierarchical structures. During this validation, an issue with `BoxStyle.Heavy` was identified: it was incorrectly utilizing mixed light/heavy characters for body separators (`\u2520` and `\u2542` instead of `\u2523` and `\u254B`).
6+
**Strategic Action:** Developed an exhaustive validation suite (`Table_CoordinatePreciseCharacterAssertion_HeavyBodySeparation`) under the xUnit framework inside `ValidatorTableTests.cs`. The matrix enforces: 1) Hierarchical Composition and Dynamic Mutation validation by embedding the `Table` alongside a `Border` within a `Grid` and verifying structural integrity upon parent resize. 2) Coordinate-Precise Assertion evaluating the exact mapped placement of Unicode Box Drawing (`Heavy` style) symbols (e.g., `\u2523`, `\u252B`, `\u254B`, `\u2501`) against a `VirtualBuffer`. Also updated the `Table.cs` struct values for Heavy table rendering.

src/Tedd.TUI.Tests/TableCoverageTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,11 @@ public void Table_Separator_Rendering()
370370
// X=8: Right Junction (u2528 ┨)
371371

372372
// Verify Row 4
373-
Assert.Equal('\u2520', buffer.GetPixel(0, 4).Character);
373+
Assert.Equal('\u2523', buffer.GetPixel(0, 4).Character);
374374
Assert.Equal('\u2501', buffer.GetPixel(1, 4).Character);
375375
Assert.Equal('\u254B', buffer.GetPixel(4, 4).Character); // Cross
376376
Assert.Equal('\u2501', buffer.GetPixel(5, 4).Character);
377-
Assert.Equal('\u2528', buffer.GetPixel(8, 4).Character);
377+
Assert.Equal('\u252B', buffer.GetPixel(8, 4).Character);
378378
}
379379

380380
[Fact]

src/Tedd.TUI.Tests/ValidatorTableTests.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,71 @@ public void Table_CoordinatePreciseCharacterAssertion_DoubleStyle()
373373
Assert.Equal('\u2562', buffer.GetPixel(11, 4).Character); // BodySepTRight
374374
}
375375

376+
[Fact]
377+
public void Table_CoordinatePreciseCharacterAssertion_HeavyBodySeparation()
378+
{
379+
var table = new Table
380+
{
381+
ShowBorder = true,
382+
ShowHeader = true,
383+
ShowVerticalLines = true,
384+
ShowHorizontalLines = true,
385+
BorderStyle = BoxStyle.Heavy,
386+
HorizontalAlignment = HorizontalAlignment.Left,
387+
VerticalAlignment = VerticalAlignment.Top,
388+
Width = 12,
389+
Height = 10
390+
};
391+
392+
var col1 = new TableColumn { Header = "ID", Width = new GridLength(3, GridUnitType.Pixel) };
393+
var col2 = new TableColumn { Header = "Name", Width = new GridLength(4, GridUnitType.Pixel) };
394+
table.Columns.Add(col1);
395+
table.Columns.Add(col2);
396+
397+
// Add 2 rows to trigger row separators
398+
table.AddRow("1", "Bob");
399+
table.AddRow("2", "Alice");
400+
401+
// Use a grid to test hierarchical structure
402+
var parentGrid = new Grid();
403+
parentGrid.Children.Add(table);
404+
405+
var sv = table.GetVisualChild(0) as ScrollViewer;
406+
if (sv != null)
407+
{
408+
sv.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
409+
sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
410+
}
411+
412+
// Initial Layout
413+
parentGrid.Measure(new Size(12, 10));
414+
parentGrid.Arrange(new Rect(0, 0, 12, 10));
415+
416+
var buffer = new VirtualBuffer(12, 10);
417+
parentGrid.Render(buffer, 0, 0);
418+
419+
// Header separator is at y=2
420+
// Row 1 is at y=3
421+
// Body separator is at y=4
422+
Assert.Equal('\u2523', buffer.GetPixel(0, 4).Character); // BodySepTLeft (Heavy TLeft)
423+
Assert.Equal('\u252B', buffer.GetPixel(11, 4).Character); // BodySepTRight (Heavy TRight)
424+
Assert.Equal('\u254B', buffer.GetPixel(4, 4).Character); // BodySepCross (Heavy Cross)
425+
Assert.Equal('\u2501', buffer.GetPixel(1, 4).Character); // BodySepH (Heavy Horizontal)
426+
427+
// Dynamic State Mutation
428+
parentGrid.Measure(new Size(14, 12));
429+
parentGrid.Arrange(new Rect(0, 0, 14, 12));
430+
431+
var newBuffer = new VirtualBuffer(14, 12);
432+
parentGrid.Render(newBuffer, 0, 0);
433+
434+
// Verify again at the new resolution, since it is Top/Left aligned, positions remain the same
435+
Assert.Equal('\u2523', newBuffer.GetPixel(0, 4).Character); // BodySepTLeft (Heavy TLeft)
436+
Assert.Equal('\u252B', newBuffer.GetPixel(11, 4).Character); // BodySepTRight (Heavy TRight)
437+
Assert.Equal('\u254B', newBuffer.GetPixel(4, 4).Character); // BodySepCross (Heavy Cross)
438+
Assert.Equal('\u2501', newBuffer.GetPixel(1, 4).Character); // BodySepH (Heavy Horizontal)
439+
}
440+
376441
[Fact]
377442
public void Table_HierarchicalCompositionAndDynamicStateMutation_NestedGrids()
378443
{

src/Tedd.TUI/Table.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,10 @@ public static TableBoxChars Get(BoxStyle style)
409409
c.TLeft = '\u2523';
410410
c.TRight = '\u252B';
411411
c.HeaderCross = '\u254B';
412-
c.BodySepTLeft = '\u2520';
413-
c.BodySepTRight = '\u2528';
414-
c.BodySepCross = '\u2542'; // ╂ (Heavy Vert, Light Horz)
412+
c.BodySepTLeft = '\u2523';
413+
c.BodySepTRight = '\u252B';
414+
c.BodySepCross = '\u254B'; // ╋ (Heavy Vert, Heavy Horz)
415+
c.BodySepH = '\u2501'; // ━ (Heavy Horz)
415416
break;
416417
case BoxStyle.Double:
417418
c.TDown = '\u2566';

0 commit comments

Comments
 (0)