Files
tensor/internal/core/data_test.go
T
petrbalvin af4ee19703
Release / gates (push) Successful in 4m38s
Test / test (push) Successful in 5m16s
Release / release (push) Successful in 35s
feat: initial release
Assisted-by: GLM 5.3 Flash
2026-09-03 10:00:00 +02:00

43 lines
1.0 KiB
Go

// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
package core
import (
"testing"
)
func TestAllAnyCountNonzero(t *testing.T) {
z, _ := FromInts([]int64{0, 0, 0}, 3)
a, err := All(z)
if err != nil || a {
t.Errorf("All zeros: %v %v", a, err)
}
any, err := Any(z)
if err != nil || any {
t.Errorf("Any zeros: %v %v", any, err)
}
m, _ := FromInts([]int64{0, 5, 0, 7}, 2, 2)
all, err := All(m)
if err != nil || all {
t.Errorf("All mixed: %v %v", all, err)
}
anyM, err := Any(m)
if err != nil || !anyM {
t.Errorf("Any mixed: %v %v", anyM, err)
}
cnt, err := CountNonzero(m)
if err != nil || cnt != 2 {
t.Errorf("CountNonzero: %d %v, want 2", cnt, err)
}
allOnes, _ := FromInts([]int64{1, 2, 3}, 3)
allT, err := All(allOnes)
if err != nil || !allT {
t.Errorf("All non-zero: %v %v", allT, err)
}
c, _ := FromComplexes([]complex128{1 + 2i}, 1)
if _, err := All(c); err == nil {
t.Error("All complex: expected error")
}
}