Source file src/simd/_gen/simdgen/sort_test.go

     1  // Copyright 2025 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 main
     6  
     7  import "testing"
     8  
     9  func TestSort(t *testing.T) {
    10  	testCases := []struct {
    11  		s1, s2 string
    12  		want   int
    13  	}{
    14  		{"a1", "a2", -1},
    15  		{"a11a", "a11b", -1},
    16  		{"a01a1", "a1a01", -1},
    17  		{"a2", "a1", 1},
    18  		{"a10", "a2", 1},
    19  		{"a1", "a10", -1},
    20  		{"z11", "z2", 1},
    21  		{"z2", "z11", -1},
    22  		{"abc", "abd", -1},
    23  		{"123", "45", 1},
    24  		{"file1", "file1", 0},
    25  		{"file", "file1", -1},
    26  		{"file1", "file", 1},
    27  		{"a01", "a1", -1},
    28  		{"a1a", "a1b", -1},
    29  	}
    30  
    31  	for _, tc := range testCases {
    32  		got := compareNatural(tc.s1, tc.s2)
    33  		result := "✅"
    34  		if got != tc.want {
    35  			result = "❌"
    36  			t.Errorf("%s CompareNatural(\"%s\", \"%s\") -> got %2d, want %2d\n", result, tc.s1, tc.s2, got, tc.want)
    37  		} else {
    38  			t.Logf("%s CompareNatural(\"%s\", \"%s\") -> got %2d, want %2d\n", result, tc.s1, tc.s2, got, tc.want)
    39  		}
    40  	}
    41  }
    42  

View as plain text