Skip to content

test: fully cover NativeObject via a test subclass#31

Merged
dfa1 merged 1 commit into
mainfrom
test/native-object
Jun 27, 2026
Merged

test: fully cover NativeObject via a test subclass#31
dfa1 merged 1 commit into
mainfrom
test/native-object

Conversation

@dfa1

@dfa1 dfa1 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

What

NativeObject (the AutoCloseable base for native-pointer wrappers) had no direct unit test. Since it is abstract, a minimal concrete TestObject subclass exercises every branch:

  • ptr() returns the owned pointer while open
  • close() calls tryClose exactly once, with the owned pointer
  • repeated close() is idempotent (released once)
  • ptr() after close() throws IllegalStateException
  • a throwing tryClose is swallowed (destructors must not throw) yet the object is still marked closed
  • constructing with MemorySegment.NULL never calls tryClose
  • 32 concurrent close() calls release exactly once (latch-gated, no sleep)

7 tests, checkstyle clean.

🤖 Generated with Claude Code

NativeObject is abstract, so a minimal concrete TestObject exercises every
branch: ptr() while open, close() runs tryClose exactly once with the owned
pointer, repeated close is idempotent, ptr() after close throws, a throwing
tryClose is swallowed (destructors must not throw) yet still marks the object
closed, constructing with NULL never calls tryClose, and 32 concurrent close()
calls release exactly once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 751ead5 into main Jun 27, 2026
1 check passed
@dfa1 dfa1 deleted the test/native-object branch June 27, 2026 15:44
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.

1 participant