MCPcopy Create free account
hub / github.com/oschwald/maxminddb-golang / TestComplexStructWithNestingAndPointer

Function TestComplexStructWithNestingAndPointer

reader_test.go:529–558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

527}
528
529func TestComplexStructWithNestingAndPointer(t *testing.T) {
530 reader, err := Open(testFile("MaxMind-DB-test-decoder.mmdb"))
531 require.NoError(t, err)
532
533 var result TestPointerType
534
535 err = reader.Lookup(netip.MustParseAddr("::1.1.1.0")).Decode(&result)
536 require.NoError(t, err)
537
538 assert.Equal(t, []uint{uint(1), uint(2), uint(3)}, *result.Array)
539 assert.True(t, *result.Boolean)
540 assert.Equal(t, []byte{0x00, 0x00, 0x00, 0x2a}, *result.Bytes)
541 assert.InEpsilon(t, 42.123456, *result.Double, 1e-10)
542 assert.InEpsilon(t, float32(1.1), *result.Float, 1e-5)
543 assert.Equal(t, int32(-268435456), *result.Int32)
544
545 assert.Equal(t, []int{7, 8, 9}, result.Map.MapX.ArrayX)
546
547 assert.Equal(t, "hello", result.Map.MapX.UTF8StringX)
548
549 assert.Equal(t, uint16(100), *result.Uint16)
550 assert.Equal(t, uint32(268435456), *result.Uint32)
551 assert.Equal(t, uint64(1152921504606846976), **result.Uint64)
552 assert.Equal(t, "unicode! ☯ - ♫", *result.Utf8String)
553 bigInt := new(big.Int)
554 bigInt.SetString("1329227995784915872903807060280344576", 10)
555 assert.Equal(t, bigInt, result.Uint128)
556
557 require.NoError(t, reader.Close())
558}
559
560// See GitHub #115.
561func TestNestedMapDecode(t *testing.T) {

Callers

nothing calls this directly

Calls 5

OpenFunction · 0.85
LookupMethod · 0.80
CloseMethod · 0.80
testFileFunction · 0.70
DecodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…