MCPcopy Create free account
hub / github.com/apple/foundationdb / testCompressedInt

Function testCompressedInt

flow/CompressedInt.actor.cpp:55–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54template <typename IntType>
55void testCompressedInt(IntType n, StringRef rep = StringRef()) {
56 BinaryWriter w(AssumeVersion(g_network->protocolVersion()));
57 CompressedInt<IntType> cn(n);
58
59 w << cn;
60 if (rep.size() != 0 && w.toValue() != rep) {
61 printf("WRONG ENCODING:\n");
62 printf(" test value (BigE): ");
63 printBitsLittle(sizeof(IntType), &n);
64 printf(" encoded: ");
65 printBitsBig(w.toValue().size(), w.toValue().begin());
66 printf(" expected: ");
67 printBitsBig(rep.size(), rep.begin());
68 puts("");
69 } else
70 rep = w.toValue();
71
72 cn.value = 0;
73 BinaryReader r(rep, AssumeVersion(g_network->protocolVersion()));
74 r >> cn;
75
76 if (cn.value != n) {
77 printf("FAILURE:\n");
78 printf(" test value: (Big): ");
79 printBitsLittle(sizeof(IntType), &n);
80 printf(" encoded: ");
81 printBitsBig(rep.size(), rep.begin());
82 printf(" decoded value: ");
83 printBitsLittle(sizeof(IntType), &cn.value);
84 puts("");
85 }
86}
87
88TEST_CASE("/flow/compressed_ints") {
89 testCompressedInt<int>(-2, LiteralStringRef("\x7e"));

Callers

nothing calls this directly

Calls 9

AssumeVersionFunction · 0.85
printfFunction · 0.85
printBitsLittleFunction · 0.85
printBitsBigFunction · 0.85
StringRefClass · 0.50
protocolVersionMethod · 0.45
sizeMethod · 0.45
toValueMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected