(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func TestEncodeInt4(t *testing.T) { |
| 254 | tests := []struct { |
| 255 | name string |
| 256 | input interface{} |
| 257 | expected int32 |
| 258 | }{ |
| 259 | {"int 42", int(42), 42}, |
| 260 | {"int -1", int(-1), -1}, |
| 261 | {"int32 max", int32(2147483647), 2147483647}, |
| 262 | {"int32 min", int32(-2147483648), -2147483648}, |
| 263 | {"int64 1000000", int64(1000000), 1000000}, |
| 264 | {"uint32 100000", uint32(100000), 100000}, |
| 265 | {"float64 3.14", float64(3.14), 3}, |
| 266 | } |
| 267 | |
| 268 | for _, tt := range tests { |
| 269 | t.Run(tt.name, func(t *testing.T) { |
| 270 | result := encodeInt4(tt.input) |
| 271 | if result == nil { |
| 272 | t.Fatalf("encodeInt4(%v) returned nil", tt.input) |
| 273 | } |
| 274 | if len(result) != 4 { |
| 275 | t.Fatalf("encodeInt4(%v) length = %d, want 4", tt.input, len(result)) |
| 276 | } |
| 277 | got := int32(binary.BigEndian.Uint32(result)) |
| 278 | if got != tt.expected { |
| 279 | t.Errorf("encodeInt4(%v) = %d, want %d", tt.input, got, tt.expected) |
| 280 | } |
| 281 | }) |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | func TestEncodeInt8(t *testing.T) { |
| 286 | tests := []struct { |
nothing calls this directly
no test coverage detected