mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #170] [MERGED] test: add unit tests for Bool and Int64 custom JSON types #211
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/170
Author: @mason5052
Created: 3/2/2026
Status: ✅ Merged
Merged: 3/2/2026
Merged by: @asdek
Base:
feature/next_release← Head:test/args-custom-json-types📝 Commits (2)
5b195actest: add unit tests for Bool and Int64 custom JSON types in args.goe08c00ctest: add edge case coverage for null, overflow, and whitespace trimming📊 Changes
1 file changed (+420 additions, -0 deletions)
View changed files
➕
backend/pkg/tools/args_test.go(+420 -0)📄 Description
Description
Add comprehensive unit tests for the custom
BoolandInt64types inbackend/pkg/tools/args.go. These types are used throughout the tool argument system to handle LLM-produced JSON that may represent booleans and integers as quoted strings.Type of Change
Areas Affected
backend/pkg/tools/args_test.go(new file)Testing
All tests are self-contained, table-driven, and use
t.Parallel(). Test coverage includes:Bool type (6 test functions):
TestBoolUnmarshalJSON- bare values, quoted strings, case-insensitive parsing, single-quoted wrappers, whitespace/tab trimming, invalid inputs (yes, 1, 0, empty string, arbitrary words)TestBoolMarshalJSON- true/false values, nil pointer returns falseTestBoolBool- accessor method with nil safetyTestBoolString- string conversion with nil returns emptyTestBoolJSONRoundTrip- marshal/unmarshal round-trip via struct embeddingInt64 type (7 test functions):
TestInt64UnmarshalJSON- bare integers, quoted strings, single-quoted wrappers, whitespace trimming, min/max int64 boundary values, invalid inputs (float, string, empty, bool)TestInt64MarshalJSON- positive/negative/zero values, nil pointer returns 0TestInt64Int- int accessor with nil safetyTestInt64Int64Method- int64 accessor with nil safetyTestInt64PtrInt64- pointer conversion with nil returns nilTestInt64String- string conversion with nil returns emptyTestInt64JSONRoundTrip- marshal/unmarshal round-trip via struct embeddingSecurity Considerations
No security impact - test-only changes.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.