bandwidth

package
v0.1.0-alpha.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MulanPSL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package bandwidth 解析 README 约定的带宽字符串为 bps(比特每秒)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatActualMbps

func FormatActualMbps(bps float64) string

FormatActualMbps 将实际 bps 格式化为三位小数 Mbps(与 README 示例 actual=0.999 对齐)。

func Parse

func Parse(s string) (float64, error)

Parse 将形如 1Mbps、500Kbps、1m、1024000 的字符串解析为比特每秒。

func RoundMbps

func RoundMbps(bps float64) string

RoundMbps 将 bps 格式化为 README 风格的目标带宽(两位小数 Mbps)。

func TestFormatActualMbps

func TestFormatActualMbps(t *testing.T)

测试 FormatActualMbps 函数

func TestFormatActualMbps_BoundaryCases

func TestFormatActualMbps_BoundaryCases(t *testing.T)

测试 FormatActualMbps 函数的边界情况

func TestParse_BoundaryCases

func TestParse_BoundaryCases(t *testing.T)

测试 Parse 函数的边界情况

func TestParse_UnitFormats

func TestParse_UnitFormats(t *testing.T)

测试 Parse 函数的各种单位格式

func TestRoundMbps

func TestRoundMbps(t *testing.T)

测试 RoundMbps 函数

func TestRoundMbps_BoundaryCases

func TestRoundMbps_BoundaryCases(t *testing.T)

测试 RoundMbps 函数的边界情况

Types

This section is empty.

Source Files

  • bandwidth.go
  • bandwidth_test_comprehensive.go
  • bandwidth_test_extended.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL