MCPcopy Create free account
hub / github.com/google/gapid / TestEncodeDecode

Function TestEncodeDecode

gapil/bapi/bapi_test.go:46–70  ·  view source on GitHub ↗

Encode the APIs, decode the APIs and check they are identical with the pre-encoded.

(t *testing.T)

Source from the content-addressed store, hash-verified

44// Encode the APIs, decode the APIs and check they are identical with the
45// pre-encoded.
46func TestEncodeDecode(t *testing.T) {
47 ctx := log.Testing(t)
48
49 apis, mappings := resolveAPIs(ctx)
50
51 data, err := bapi.Encode(apis, mappings)
52 assert.For(ctx, "err").ThatError(err).Succeeded()
53
54 decodedAPIs, decodedMappings, err := bapi.Decode(data)
55 assert.For(ctx, "err").ThatError(err).Succeeded()
56
57 if assert.For(ctx, "num apis").That(len(decodedAPIs)).Equals(len(apis)) {
58 for i := range apis {
59 assert.For(ctx, "apis").That(decodedAPIs[i]).DeepEquals(apis[i])
60 }
61 }
62
63 if false {
64 // These tests are disabled because they currently do not pass.
65 // Mappings are being serialized, but their order is non-deterministic
66 // though the iteration of maps.
67 // TODO: Fix and enable these tests.
68 checkMappings(ctx, decodedAPIs, apis, decodedMappings, mappings)
69 }
70}
71
72func checkMappings(ctx context.Context,
73 gotAPIs, expectAPIs []*semantic.API,

Callers

nothing calls this directly

Calls 10

resolveAPIsFunction · 0.85
checkMappingsFunction · 0.85
SucceededMethod · 0.80
ThatErrorMethod · 0.80
ForMethod · 0.80
ThatMethod · 0.80
EncodeMethod · 0.65
DecodeMethod · 0.65
EqualsMethod · 0.65
DeepEqualsMethod · 0.45

Tested by

no test coverage detected