[PR #170] [MERGED] test: add unit tests for Bool and Int64 custom JSON types #211

Closed
opened 2026-06-06 22:09:43 -04:00 by yindo · 0 comments
Owner

📋 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_releaseHead: test/args-custom-json-types


📝 Commits (2)

  • 5b195ac test: add unit tests for Bool and Int64 custom JSON types in args.go
  • e08c00c test: 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 Bool and Int64 types in backend/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

  • New tests (no production code changes)

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 false
  • TestBoolBool - accessor method with nil safety
  • TestBoolString - string conversion with nil returns empty
  • TestBoolJSONRoundTrip - marshal/unmarshal round-trip via struct embedding

Int64 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 0
  • TestInt64Int - int accessor with nil safety
  • TestInt64Int64Method - int64 accessor with nil safety
  • TestInt64PtrInt64 - pointer conversion with nil returns nil
  • TestInt64String - string conversion with nil returns empty
  • TestInt64JSONRoundTrip - marshal/unmarshal round-trip via struct embedding

Security Considerations

No security impact - test-only changes.

Checklist

  • My code follows the existing code style of this project
  • I have performed a self-review of my own code
  • New tests added for the changes
  • Tests follow project conventions (table-driven, t.Parallel(), same package)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/170 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/2/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `test/args-custom-json-types` --- ### 📝 Commits (2) - [`5b195ac`](https://github.com/vxcontrol/pentagi/commit/5b195ac2ef9d287b19dbc98fa689b3c324d45202) test: add unit tests for Bool and Int64 custom JSON types in args.go - [`e08c00c`](https://github.com/vxcontrol/pentagi/commit/e08c00c466c0d308e38e7dca871c970282a43aeb) test: add edge case coverage for null, overflow, and whitespace trimming ### 📊 Changes **1 file changed** (+420 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/pkg/tools/args_test.go` (+420 -0) </details> ### 📄 Description ## Description Add comprehensive unit tests for the custom `Bool` and `Int64` types in `backend/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 - [x] New tests (no production code changes) ## 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 false - `TestBoolBool` - accessor method with nil safety - `TestBoolString` - string conversion with nil returns empty - `TestBoolJSONRoundTrip` - marshal/unmarshal round-trip via struct embedding **Int64 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 0 - `TestInt64Int` - int accessor with nil safety - `TestInt64Int64Method` - int64 accessor with nil safety - `TestInt64PtrInt64` - pointer conversion with nil returns nil - `TestInt64String` - string conversion with nil returns empty - `TestInt64JSONRoundTrip` - marshal/unmarshal round-trip via struct embedding ## Security Considerations No security impact - test-only changes. ## Checklist - [x] My code follows the existing code style of this project - [x] I have performed a self-review of my own code - [x] New tests added for the changes - [x] Tests follow project conventions (table-driven, t.Parallel(), same package) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:43 -04:00
yindo closed this issue 2026-06-06 22:09:43 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#211