Commit graph

9 commits

Author SHA1 Message Date
98bcb37c50
Refactor error messages to use constants in tests
Added a new constant ErrExpectedJSONString for uniformity in error messages. Updated all relevant test cases to utilize this new constant instead of hardcoding the error message, enhancing code maintainability and readability.
2024-09-11 10:30:02 +02:00
296050ca70
Define error constants for JSON marshaling/unmarshaling tests
Introduced `ErrUnmarshalFailed` and `ErrMarshalFailed` constants to standardize error messages in JSON tests. This enhances code readability and maintainability by avoiding repeated strings directly in the test cases.
2024-09-11 10:27:55 +02:00
05d806adff
Add JSON marshaling support for Variable types
Introduced a NewVariable function for creating generics-based Variable types. Added MarshalJSON methods to support JSON encoding for various Nil types, ensuring proper handling of nil values. Updated tests and examples to verify the new marshaling functionality.
2024-09-02 12:13:54 +02:00
1150734ab0
Remove redundant Get() method
The Get() method was simply an alias for the Value() method and did not add any functionality. This simplification makes the code cleaner and reduces unnecessary duplication, improving maintainability.
2024-09-01 21:14:46 +02:00
89d0a3f00e
Add comprehensive nil type JSON unmarshal tests
This commit restructures and extends the JSON unmarshal tests for nil types to cover more data types, including boolean, byte slice, float32, float64, int, int64, string, and various unsigned integers. Each test ensures proper handling of value retrieval, nil checks, and reset behavior, enhancing the robustness of the unmarshal functionality.
2024-09-01 19:48:57 +02:00
ab747282c8
Add example for Nil value JSON unmarshaling
Introduced ExampleVariable_UnmarshalJSON to demonstrate unmarshaling of JSON with nil and non-nil fields. This includes handling for multiple custom types and provides a sample output. Added necessary imports and error handling for clarity.
2024-09-01 17:04:55 +02:00
80f2ea15a5
Add additional nil checks in niljson_test.go
Enhanced the test coverage by adding nil checks for ByteSlice and Float32 types after reset. This ensures that more types are adequately handled and validated for nil values in the tests. Additionally, included a check for the string using the Get method.
2024-09-01 16:51:10 +02:00
4224968915
Add support for additional types in niljson
Enhanced the niljson package to include support for byte slices and float32 types. Updated the test cases to validate these new types and modified method names to be more consistent.
2024-09-01 16:41:53 +02:00
03f6fd14d1
Initial checkin 2024-09-01 16:01:58 +02:00