[PR #8692] [MERGED] Refactor Byte Formatting Logic and Add Its Tests #59448

Closed
opened 2026-04-29 14:23:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/8692
Author: @fyvri
Created: 1/30/2025
Status: Merged
Merged: 2/5/2025
Merged by: @BruceMacD

Base: mainHead: test/add-byte-format-test


📝 Commits (5)

  • 3e85b97 refactor(format/byte): simplify byte formatting logic
  • 053730d test: add tests for HumanBytes and HumanBytes2
  • 4bb88b1 Merge branch 'ollama:main' into test/add-byte-format-test
  • 0c713a7 Merge branch 'ollama:main' into test/add-byte-format-test
  • ea454cf Merge branch 'ollama:main' into test/add-byte-format-test

📊 Changes

2 files changed (+91 additions, -2 deletions)

View changed files

format/byte_test.go (+91 -0)
📝 format/bytes.go (+0 -2)

📄 Description

This PR ensures that the HumanBytes and HumanBytes2 functions are reliable, easy to understand, and thoroughly tested. It also resolves any discrepancies between the implementation and test expectations, making the codebase more robust and maintainable. The changes include:

  1. Refactoring:
    • Removed redundant checks and streamlined the switch-case structure.
  2. Testing:
    • Added test cases for both HumanBytes and HumanBytes2 to cover a wide range of scenarios.
    • Validated outputs for edge cases and ensured consistency between expected and actual results.

🔄 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/8692 **Author:** [@fyvri](https://github.com/fyvri) **Created:** 1/30/2025 **Status:** ✅ Merged **Merged:** 2/5/2025 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `test/add-byte-format-test` --- ### 📝 Commits (5) - [`3e85b97`](https://github.com/ollama/ollama/commit/3e85b97ab32a872d6a8cebe11c3ea73cdcc57cd2) refactor(format/byte): simplify byte formatting logic - [`053730d`](https://github.com/ollama/ollama/commit/053730de60fcfeb6a50fc44b0930da00761683ac) test: add tests for HumanBytes and HumanBytes2 - [`4bb88b1`](https://github.com/ollama/ollama/commit/4bb88b1bc7f7f4adf89bbb5a900a3e3a6c47a0d1) Merge branch 'ollama:main' into test/add-byte-format-test - [`0c713a7`](https://github.com/ollama/ollama/commit/0c713a759e273fa72e88ab1b4c8a57b42526dbb1) Merge branch 'ollama:main' into test/add-byte-format-test - [`ea454cf`](https://github.com/ollama/ollama/commit/ea454cfddc99559f793f9016cfcb8420e3065fd7) Merge branch 'ollama:main' into test/add-byte-format-test ### 📊 Changes **2 files changed** (+91 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `format/byte_test.go` (+91 -0) 📝 `format/bytes.go` (+0 -2) </details> ### 📄 Description This PR ensures that the `HumanBytes` and `HumanBytes2` functions are reliable, easy to understand, and thoroughly tested. It also resolves any discrepancies between the implementation and test expectations, making the codebase more robust and maintainable. The changes include: 1. **Refactoring**: - Removed redundant checks and streamlined the switch-case structure. 2. **Testing**: - Added test cases for both `HumanBytes` and `HumanBytes2` to cover a wide range of scenarios. - Validated outputs for edge cases and ensured consistency between expected and actual results. --- <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-29 14:23:06 -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#59448