Files
obitools4/autodoc/docmd/pkg/obiutils/bytes_test.md
T
Eric Coissac 8c7017a99d ⬆️ version bump to v4.5
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
2026-04-13 13:34:53 +02:00

1.1 KiB

obiutils Package Functional Overview

The obiutils package provides two core utility functions for low-level and numerical operations in Go:

  • InPlaceToLower([]byte) []byte
    Converts all ASCII uppercase letters in a byte slice to lowercase in-place, returning the modified slice.

    • Non-alphabetic bytes remain unchanged.
    • Memory-efficient: modifies input directly (no allocation of new slice).
  • Make2DNumericArray[T any](rows, cols int, zeroed bool) Matrix[T]
    Generates a generic 2D numeric array (Matrix) of type T, supporting any comparable/numeric Go type.

    • Parameters: number of rows, columns, and whether to initialize with zero values (true) or default T (e.g., 0 for int).
    • Uses Go generics ([T any]) for type safety and flexibility.

Both functions are thoroughly unit-tested in *_test.go, covering edge cases:

  • Empty/nil inputs (InPlaceToLower)
  • Various dimensions and zero-initialization modes (Make2DNumericArray)

Tests use reflect.DeepEqual for structural comparison and subtests via t.Run.
The package assumes a custom type alias: type Matrix[T any] [][]T.