[PR #11918] test: Add comprehensive edge case tests for bytes formatting functions #13657

Closed
opened 2026-04-13 00:32:09 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/ollama/ollama/pull/11918

State: closed
Merged: No


Overview

This PR adds comprehensive test coverage for the and functions in the format package, significantly improving test coverage for these utility functions.

Test Coverage Added

  • 397 lines of new test code covering edge cases and boundary conditions
  • Negative values - Testing how functions handle negative inputs
  • Boundary conditions - Testing exact unit boundaries (1000, 1024, etc.)
  • Large values - Testing behavior with MaxInt64 and MaxUint64
  • Precision edge cases - Testing decimal rounding and formatting
  • Binary vs decimal units - Testing both KB/MB/GB and KiB/MiB/GiB
  • Consistency tests - Ensuring deterministic output
  • Performance benchmarks - Measuring function performance

Key Findings

  • treats negative values as bytes (doesn't convert to larger units)
  • Both functions handle very large values correctly
  • Proper rounding behavior for fractional values
  • Good performance characteristics (1500ns/op average)

Benefits

  • Improves test coverage for critical utility functions
  • Helps prevent regressions in byte formatting
  • Documents expected behavior for edge cases
  • Provides performance baselines for future optimizations

Testing

All tests pass successfully:

The tests follow Go testing best practices and integrate seamlessly with the existing test suite.

**Original Pull Request:** https://github.com/ollama/ollama/pull/11918 **State:** closed **Merged:** No --- ## Overview This PR adds comprehensive test coverage for the and functions in the format package, significantly improving test coverage for these utility functions. ## Test Coverage Added - **397 lines of new test code** covering edge cases and boundary conditions - **Negative values** - Testing how functions handle negative inputs - **Boundary conditions** - Testing exact unit boundaries (1000, 1024, etc.) - **Large values** - Testing behavior with MaxInt64 and MaxUint64 - **Precision edge cases** - Testing decimal rounding and formatting - **Binary vs decimal units** - Testing both KB/MB/GB and KiB/MiB/GiB - **Consistency tests** - Ensuring deterministic output - **Performance benchmarks** - Measuring function performance ## Key Findings - treats negative values as bytes (doesn't convert to larger units) - Both functions handle very large values correctly - Proper rounding behavior for fractional values - Good performance characteristics (1500ns/op average) ## Benefits - Improves test coverage for critical utility functions - Helps prevent regressions in byte formatting - Documents expected behavior for edge cases - Provides performance baselines for future optimizations ## Testing All tests pass successfully: The tests follow Go testing best practices and integrate seamlessly with the existing test suite.
GiteaMirror added the pull-request label 2026-04-13 00:32:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#13657