(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestEncodeNodeID(t *testing.T) { |
| 11 | tests := map[string]struct { |
| 12 | templateIndex int64 |
| 13 | id int64 |
| 14 | want string |
| 15 | }{ |
| 16 | "positive fixint max": {id: 127, want: "kgB_"}, |
| 17 | "uint8 min": {id: 128, want: "kgDMgA"}, |
| 18 | "uint8 max": {id: 255, want: "kgDM_w"}, |
| 19 | "uint16 min": {id: 256, want: "kgDNAQA"}, |
| 20 | "uint16 max": {id: 65535, want: "kgDN__8"}, |
| 21 | "uint32 min": {id: 65536, want: "kgDOAAEAAA"}, |
| 22 | "uint32 max": {id: math.MaxUint32, want: "kgDO_____w"}, |
| 23 | "uint64 min": {id: math.MaxUint32 + 1, want: "kgDPAAAAAQAAAAA"}, |
| 24 | "nonzero template": {templateIndex: 1, id: 127, want: "kgF_"}, |
| 25 | } |
| 26 | for name, tt := range tests { |
| 27 | t.Run(name, func(t *testing.T) { |
| 28 | // Given a template index, database ID, and expected payload |
| 29 | templateIndex, id := tt.templateIndex, tt.id |
| 30 | |
| 31 | // When the node ID encoder receives the explicit template index |
| 32 | got := EncodeNodeID(templateIndex, id) |
| 33 | |
| 34 | // Then it preserves the payload, including the template index |
| 35 | assert.Equal(t, tt.want, got) |
| 36 | }) |
| 37 | } |
| 38 | } |
nothing calls this directly
no test coverage detected