Source file src/simd/archsimd/_gen/specgen/specexpr/num_test.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package specexpr
     6  
     7  import "testing"
     8  
     9  func TestMkWidth(t *testing.T) {
    10  	tests := []struct {
    11  		num, denom int
    12  		want       ScalableWidth
    13  	}{
    14  		{4, 8, ScalableWidth{1, 2}},
    15  		{3, 9, ScalableWidth{1, 3}},
    16  		{12, 18, ScalableWidth{2, 3}},
    17  		{0, 5, ScalableWidth{0, 1}},
    18  		// We should never have a negative scalable width, but test GCD on them just in case.
    19  		{-4, 8, ScalableWidth{-1, 2}},
    20  		{4, -8, ScalableWidth{-1, 2}},
    21  		{-4, -8, ScalableWidth{1, 2}},
    22  	}
    23  	for _, tc := range tests {
    24  		got := mkWidth(tc.num, tc.denom)
    25  		if got != tc.want {
    26  			t.Errorf("mkWidth(%d, %d) = %v; want %v", tc.num, tc.denom, got, tc.want)
    27  		}
    28  	}
    29  }
    30  

View as plain text