Add comprehensive unit tests and project documentation#191
Merged
Conversation
- Created .github/copilot-instructions.md with project guidelines - Added matrix_test.go with 26 Matrix tests (82% coverage) - Added path_test.go with 19 Path tests - Added draw2dbase/stack_gc_test.go with 30 StackGraphicContext tests - Added draw2dkit/draw2dkit_extended_test.go with 10 additional tests (100% coverage) - Added draw2dimg/gc_test.go with 17 image backend tests - Added draw2dbase/dasher_test.go with 6 DashVertexConverter tests - Added draw2dbase/flattener_test.go with 10 flattener tests - Added draw2dbase/stroker_test.go with 4 LineStroker tests - All tests pass with go test ./... (except draw2dgl which requires OpenGL) Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add comprehensive unit tests and copilot instructions file
Add comprehensive unit tests and Copilot instructions
Feb 7, 2026
- Added known_issues_test.go with tests for GitHub issues #155, #139, #171, #181 - Added draw2dimg/known_issues_test.go for backend-specific issues - Added performance_bench_test.go for performance benchmarking (issue #147) - Added KNOWN_ISSUES_TESTS.md documenting all failing tests and their purpose FAILING TESTS (demonstrating real bugs): - TestIssue155_SetLineCapButtCap: Line caps don't render differently - TestIssue155_SetLineCapSquareCap: Line caps don't render differently - TestIssue139_PDFVerticalFlip: Y-axis flip doesn't work in PDF backend - draw2dimg/TestIssue155_LineCapVisualDifference: Line caps identical These tests intentionally FAIL to show current implementation limitations as requested. They document known bugs from open GitHub issues. Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot
AI
changed the title
Add comprehensive unit tests and Copilot instructions
Add failing tests for known bugs to expose implementation limits
Feb 7, 2026
Copilot
AI
changed the title
Add failing tests for known bugs to expose implementation limits
Remove failing test commits - handled by separate PR
Feb 7, 2026
Copilot
AI
changed the title
Remove failing test commits - handled by separate PR
Add comprehensive unit tests and project documentation
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds 117 unit tests and project documentation to establish baseline test coverage across core packages.
Test Coverage Added
Core (
draw2d) - 82.0% coveragematrix_test.go(26 tests): affine transformations, composition, inversionpath_test.go(19 tests): path construction, curves, arcs, subpathsBase (
draw2dbase) - 76.6% coveragestack_gc_test.go(27 tests): GraphicContext state, transforms, save/restoredasher_test.go(6 tests): dash patterns, state preservationflattener_test.go(9 tests): path flattening, transformsstroker_test.go(4 tests): line stroking, width handlingBackends
draw2dkit(10 tests): shapes, stroke/fill operations - 100% coveragedraw2dimg(16 tests): RGBA rendering, DPI, clear operations - 58.8% coverageDocumentation
.github/copilot-instructions.mddocuments:All tests use standard
testingpackage, no external dependencies.Original prompt
Objective
Add comprehensive unit tests and a
.github/copilot-instructions.mdfile to the draw2d project.Part 1: Copilot Instructions File
Create
.github/copilot-instructions.mdwith the following content exactly:New files should follow the same pattern with the current date and author name.
Comments
doc.gofile.Naming
draw2d<backend>(e.g.,draw2dimg,draw2dpdf).GraphicContextstruct in each backend embeds*draw2dbase.StackGraphicContext.Error Handling
erroras the last return value.Testing
Structure
matrix_test.gotestsmatrix.go).samples_test.go,draw2dpdf/samples_test.go, etc.output/directory (generated, not committed).Writing Tests
testingpackage only — no external test frameworks.image.NewRGBA(image.Rect(0, 0, w, h))as the canvas.t.TempDir()for any file output in tests.// Test related to issue #95: DashVertexConverter state preservationRunning Tests
Test Coverage Goals
Matrix,Path,StackGraphicContext) should have thorough coverage.Stroke,Fill,FillStroke,Clear) should verify pixel output where possible.Documentation
README.mdor package READMEs, update them.samples/directory serves as living documentation — keep samples working after changes.Architecture Notes
draw2d.GraphicContextinterface defined ingc.go.draw2dbase.StackGraphicContextprovides the common state management (colors, transforms, font, path). Backends embed it and override rendering methods (Stroke,Fill,FillStroke, string drawing, etc.).draw2dkithelpers operate ondraw2d.PathBuilder, notGraphicContext, making them backend-agnostic.Matrixis a[6]float64affine transformation matrix. Coordinate system follows the HTML Canvas 2D Context conventions.