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

Closed
opened 2026-04-16 06:52:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/11918
Author: @cybersmeashish
Created: 8/15/2025
Status: Closed

Base: mainHead: add-bytes-formatting-edge-case-tests


📝 Commits (1)

  • a832192 test: Add comprehensive edge case tests for bytes formatting functions

📊 Changes

1 file changed (+397 additions, -0 deletions)

View changed files

format/bytes_edge_cases_test.go (+397 -0)

📄 Description

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.


🔄 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/ollama/ollama/pull/11918 **Author:** [@cybersmeashish](https://github.com/cybersmeashish) **Created:** 8/15/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `add-bytes-formatting-edge-case-tests` --- ### 📝 Commits (1) - [`a832192`](https://github.com/ollama/ollama/commit/a832192d1613218dbf6e223dd8a7660461248d33) test: Add comprehensive edge case tests for bytes formatting functions ### 📊 Changes **1 file changed** (+397 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `format/bytes_edge_cases_test.go` (+397 -0) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 06:52:03 -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#18928