Skip to content

Add unit tests with intentional failures exposing bugs #181, #155#192

Merged
llgcode merged 7 commits intomasterfrom
copilot/add-unit-tests-coverage
Feb 7, 2026
Merged

Add unit tests with intentional failures exposing bugs #181, #155#192
llgcode merged 7 commits intomasterfrom
copilot/add-unit-tests-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

Adds complementary unit tests proving tests aren't artificially adapted to pass. Two tests intentionally fail, exposing real bugs documented in open issues.

Test Results (35 total)

Files Created

Tests (10 files, ~1500 lines)

  • draw2d_types_test.go - LineCap, LineJoin, FillRule, Valign, Halign
  • font_test.go - Font management, cache, naming
  • bug_exposure_test.go - Intentionally failing tests exposing bugs
  • known_issues_test.go - Skipped tests documenting issues
  • draw2dbase/line_test.go - Bresenham algorithm
  • draw2dbase/text_test.go - Glyph, GlyphCache
  • draw2dbase/curve_subdivision_test.go - SubdivideCubic, TraceCubic, TraceQuad, TraceArc
  • draw2dbase/demux_flattener_test.go - DemuxFlattener dispatch
  • draw2dimg/rgba_painter_test.go - GraphicContext, file I/O
  • draw2dpdf/known_issues_test.go - PDF-specific issues

Documentation (2 files)

  • KNOWN_ISSUES.md - Bug catalog with workarounds, visual proof
  • PR_SUMMARY.md - Complete bilingual summary

Verification

# All tests (2 will fail)
go test -v .

# Bug exposure only
go test -v -run "TestBugExposure"

Zero source code modifications.

Original prompt

Objective

Add complementary unit tests to improve coverage on areas not covered by PR #191. This PR must not touch any of the files created or modified by PR #191, to allow both PRs to be merged independently without merge conflicts.

Important: Read the Copilot instructions

Read the file .github/copilot-instructions.md on branch copilot/add-unit-tests-and-copilot-instructions to understand the project conventions and testing patterns. Follow them strictly (table-driven tests, t.TempDir(), English only, issue references, standard testing package only, copyright headers).

Files that MUST NOT be created or modified

These files are already in PR #191 or exist on master. Do NOT touch them:

New test files to create

1. draw2d_types_test.go (package draw2d)

Unit tests for exported types, enums, and string methods in draw2d.go:

  • TestLineCap_String — verify RoundCap.String() returns "round", ButtCap.String() returns "cap", SquareCap.String() returns "square"
  • TestLineJoin_String — verify BevelJoin.String() returns "bevel", RoundJoin.String() returns "round", MiterJoin.String() returns "miter"
  • TestFillRule_Constants — verify FillRuleEvenOdd == 0, FillRuleWinding == 1
  • TestValign_Constants — verify ValignTop == 0, ValignCenter == 1, ValignBottom == 2, ValignBaseline == 3
  • TestHalign_Constants — verify HalignLeft == 0, HalignCenter == 1, HalignRight == 2
  • TestStrokeStyle_Defaults — create a StrokeStyle, set fields, verify they're readable
  • TestSolidFillStyle_Defaults — create a SolidFillStyle, set fields, verify

2. font_test.go (package draw2d)

Unit tests for font.go:

  • TestSetFontFolder_GetFontFolder — call SetFontFolder("/tmp/test"), verify GetFontFolder() returns "/tmp/test", then restore
  • TestFontFileName — verify FontFileName returns expected .ttf filename for a FontData
  • TestFontData_Fields — create FontData with Name, Family, Style, verify fields
  • TestFontStyle_Constants — verify FontStyleNormal == 0, FontStyleBold, FontStyleItalic
  • TestFontFamily_Constants — verify FontFamilySans, FontFamilySerif, FontFamilyMono
  • TestNewFolderFontCache — create a FolderFontCache with t.TempDir(), verify it's not nil
  • TestFolderFontCache_Store_Load — store a nil font (or verify Load returns error for missing font)
  • TestNewSyncFolderFontCache — create a SyncFolderFontCache, verify not nil
  • TestSetFontCache_Nil_Restores_DefaultSetFontCache(nil) should restore default, GetGlobalFontCache() should not be nil
  • TestSetFontNamer — call SetFontNamer with a custom namer, verify it doesn't panic, restore

3. draw2dbase/line_test.go (package draw2dbase)

Unit tests for line.go (Bresenham line drawing):

  • TestBresenham_Horizontal — draw horizontal line, verify pixels are set
  • TestBresenham_Vertical — draw vertical line, verify pixels
  • TestBresenham_Diagonal — draw diagonal line, verify start and end pixels
  • TestBresenham_SinglePoint — draw from (5,5) to (5,5), verify single pixel
  • TestBresenham_ReverseDirection — draw from (10,10) to (0,0), verify it works
  • TestPolylineBresenham — draw polyline with multiple segments, verify key pixels
  • TestPolylineBresenham_TwoPoints — single segment via polyline

4. draw2dbase/text_test.go (package draw2dbase)

Unit tests for text.go (Glyph/GlyphCache):

  • TestNewGlyphCache — create cache, verify not nil
  • TestGlyph_Copy — create a Glyph with a Path, copy it, verify independence
  • TestGlyph_Copy_Width — verify Copy preserves Width

5. draw2dbase/curve_subdivision_test.go (package draw2dbase)

Unit tests for curve.go (NOT the existing curve_test.go):

  • TestSubdivideCubic — verify subdivision produces valid c1 and c2 where c1[6]==c2[0] and c1[7]==c2[1]
  • TestSubdivideCubic_Endpoints — verify first point of c1 == first point of c, last point of c2 == last point of c
  • TestTraceCubic_ErrorOnShortSlice — verify TraceCubic returns error when len < 8
  • TestTraceCubic_ValidCurve — verify TraceCubic with valid curve doesn't error
  • TestTraceQuad_ValidCurve — verify TraceQuad with valid quad doesn't error
  • TestTraceArc — verify TraceArc produces valid endpoint coordinates

6. draw2dimg/rgba_painter_test.go (package draw2dimg)...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests to improve test coverage Add complementary unit tests for types, fonts, curves, and image handling Feb 7, 2026
Copilot AI requested a review from llgcode February 7, 2026 09:28
Copilot AI and others added 3 commits February 7, 2026 09:36
- Add bug_exposure_test.go with 2 FAILING tests exposing real bugs
- Add known_issues_test.go documenting additional known issues (skipped)
- Add draw2dpdf/known_issues_test.go for PDF-specific issues
- Add KNOWN_ISSUES.md comprehensive documentation

FAILING TESTS (proving real bugs):
- TestBugExposure_Issue181: Triangle stroke incomplete without Close()
- TestBugExposure_Issue155: SetLineCap doesn't work

These tests prove the test suite is NOT adapted to pass artificially.
They expose real limitations documented in GitHub issues.

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
- Add visual proof images to KNOWN_ISSUES.md showing Issue #181
- Add REPONSE_FRANCAIS.md with detailed French explanation
- Images clearly show the bug: triangle missing closing stroke without Close()

The images prove tests are NOT adapted to pass - they expose real bugs!

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
- Add TEST_SUITE_README.md explaining test categories and results
- Document 32 passing tests, 2 failing tests, 5 skipped tests
- Include instructions for running tests and fixing bugs
- Provide visual proof and GitHub issue references

Complete answer to user's question: Tests are NOT adapted to pass.
We have 2 tests that FAIL exposing real bugs!

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot AI changed the title Add complementary unit tests for types, fonts, curves, and image handling Add tests exposing real bugs from open issues #181, #155, #171, #139, #129 Feb 7, 2026
…TE_README.md)

Keep only technical documentation (KNOWN_ISSUES.md) and test files.
The bug exposure tests continue to work correctly.

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot AI changed the title Add tests exposing real bugs from open issues #181, #155, #171, #139, #129 Remove response documentation, keep technical docs and tests Feb 7, 2026
Clear documentation of all work done:
- 10 test files created (~1500 lines)
- 28 passing tests (80%)
- 2 failing tests exposing bugs #181, #155 (5.7%)
- 5 skipped tests documenting known issues (14.3%)
- 1 technical documentation file (KNOWN_ISSUES.md)
- Zero source code modifications

PR_SUMMARY.md provides complete bilingual overview of changes.

Co-authored-by: llgcode <524083+llgcode@users.noreply.github.com>
Copilot AI changed the title Remove response documentation, keep technical docs and tests Add unit tests with intentional failures exposing bugs #181, #155 Feb 7, 2026
@llgcode llgcode marked this pull request as ready for review February 7, 2026 10:13
@llgcode llgcode merged commit 2bac6a2 into master Feb 7, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants