github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/utils/humannumbers/columnletter_test.go (about)

     1  package humannumbers_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/test/count"
     7  	"github.com/lmorg/murex/utils/humannumbers"
     8  )
     9  
    10  func TestExcelColumnLetter(t *testing.T) {
    11  	tests := map[int]string{
    12  		0:  "A",
    13  		1:  "B",
    14  		2:  "C",
    15  		3:  "D",
    16  		4:  "E",
    17  		5:  "F",
    18  		6:  "G",
    19  		7:  "H",
    20  		8:  "I",
    21  		9:  "J",
    22  		10: "K",
    23  		11: "L",
    24  		12: "M",
    25  		// ...
    26  		20: "U",
    27  		21: "V",
    28  		22: "W",
    29  		23: "X",
    30  		24: "Y",
    31  		25: "Z",
    32  		26: "AA",
    33  		27: "AB",
    34  		28: "AC",
    35  		29: "AD",
    36  		30: "AE",
    37  		// ...
    38  		595: "VX",
    39  		596: "VY",
    40  		597: "VZ",
    41  		598: "WA",
    42  		599: "WB",
    43  		600: "WC",
    44  		// ...
    45  		700: "ZY",
    46  		701: "ZZ",
    47  		702: "AAA",
    48  		703: "AAB",
    49  		704: "AAC",
    50  		705: "AAD",
    51  		// ...
    52  		725: "AAX",
    53  		726: "AAY",
    54  		727: "AAZ",
    55  		728: "ABA",
    56  		729: "ABB",
    57  		730: "ABC",
    58  	}
    59  
    60  	count.Tests(t, len(tests))
    61  
    62  	for i, expected := range tests {
    63  		actual := humannumbers.ColumnLetter(i)
    64  
    65  		if expected != actual {
    66  			t.Error("Expected != Actual")
    67  			t.Logf("  Integer:  %d", i)
    68  			t.Logf("  Expected: %s", expected)
    69  			t.Logf("  Actual:   %s", actual)
    70  		}
    71  	}
    72  }