aboutsummaryrefslogtreecommitdiffstats
path: root/libccnx-common/ccnx/common/codec/schema_v1/test/testrig_packetwrapper.c
blob: 9a213b139d30dc01f103c588a5d0f97069039d3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * This test rig sets up test data to wrap a packet and prepare it for use in a decoder
 *
 * A hand-encoded packet, such as from the testdata directory can be passed to commonSetup and then
 * run automated tests against it based on its manifest.
 *
 * Example:
 * @code
 *
 * static uint8_t object_nameC_keyid3_protoinfo[] = {
 *      0x00, 0x02, 0x00,  110,     // ver = 0, type = object, length = 110
 *      0x00, 0x00, 0x00,    5,     // reserved = 0, header length = 5
 *      // ---------------------------
 *      // snip middle of packet
 *      // ------------------------
 *      // byte offset 76
 *      0x00, 0x03, 0x00,   26,      // Protocol Information, length = 26
 *      0x00, 0x0B, 0x00,   17,     // Object Metadata, length = 17
 *      0x00, 0x0C, 0x00, 0x01,     // Object Type, length = 1
 *      0x04,                       // LINK
 *      0x00, 0x0D, 0x00,    8,     // Creation Time
 *      0x00, 0x00, 0x01, 0x43,     // 1,388,534,400,000 msec
 *      0x4B, 0x19, 0x84, 0x00,
 *      0x00, 0x19, 0x00, 0x01,     // EndSegment, length = 1
 *      42,
 *      // ---------------------------
 *      // snip to end of packet
 *      // ---------------------------
 * };
 *
 * static TruthTableEntry TRUTHTABLENAME(object_nameC_keyid3_protoinfo)[] = {
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_METADATA,      .bodyManifest=true,  .extent = { 80, 17} },
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_OBJ_TYPE,      .bodyManifest=true,  .extent = { 84,  1} },
 *    { .wellKnownType = false, .indexOrKey = T_INVALID,  .extent = { 0,  0} },
 * };
 *
 * LONGBOW_TEST_FIXTURE_SETUP(Global)
 * {
 *    commonSetup(testCase, object_nameC_keyid3_protoinfo, sizeof(object_nameC_keyid3_protoinfo), object_nameC_keyid3_protoinfo_truthTableEntries, MANIFEST_OBJ_METADATA);
 *    return LONGBOW_STATUS_SUCCEEDED;
 * }
 *
 * LONGBOW_TEST_CASE(Global, ccnxCodecSchemaV0ProtoInfo_GetEndSegmentNumber)
 * {
 *    testInt32Getter(testCase, MANIFEST_OBJ_OBJ_TYPE, ccnxCodecSchemaV0Metadata_Decode, ccnxCodecSchemaV0Metadata_GetContentType);
 * }
 *
 * @endcode
 *
 */

#include <inttypes.h>
#include <stdio.h>

#include <ccnx/common/codec/ccnxCodec_TlvUtilities.h>
#include <ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_NameCodec.h>
#include <ccnx/common/codec/schema_v1/ccnxCodecSchemaV1_HashCodec.h>
#include <ccnx/common/codec/schema_v1/testdata/v1_testrig_truthTable.h>

/**
 * Finds a row in the truthtable where bodyManifest is TRUE and the
 * indexOrKey equals 'key'.
 */
TlvExtent
getTruthTableExtent(TruthTableEntry *ttentry, int key)
{
    for (int i = 0; ttentry[i].indexOrKey != T_INVALID; i++) {
        if (ttentry[i].bodyManifest && ttentry[i].indexOrKey == key) {
            return ttentry[i].extent;
        }
    }
    return (TlvExtent) { 0, 0 };
}

/**
 * Finds a row in the truthtable where bodyManifest is FALSE and the
 * indexOrKey equals 'key'.
 */
TlvExtent
getTruthTableHeaderExtent(TruthTableEntry *ttentry, int key)
{
    for (int i = 0; ttentry[i].indexOrKey != T_INVALID; i++) {
        if (!ttentry[i].bodyManifest && ttentry[i].indexOrKey == key) {
            return ttentry[i].extent;
        }
    }
    return (TlvExtent) { 0, 0 };
}

typedef struct test_data {
    PARCBuffer *interest;
    CCNxCodecTlvDecoder *decoder;
    CCNxTlvDictionary *dictionary;

    uint8_t *packet;
    size_t packetLength;
    TruthTableEntry *truthTable;
} TestData;

/**
 * Wraps the given (packet, length) in a PARCBuffer where the data->memoryRegion member will be set
 * to a given extent within that PARCBuffer.  The function will locate the truthTableKey in the truthTable and
 * use it's extent as the bounds for the wrapped packet.
 *
 * For example, if the key V1_INT_NAME has the extent {32, 12}, then the PARCBuffer will wrap the packet
 * memory and it will have and offset of 32, position 0, and a limit of 12.
 */
TestData *
commonSetup(uint8_t *packet, size_t length, TruthTableEntry *truthTable, int truthTableKey)
{
    TestData *data = parcMemory_AllocateAndClear(sizeof(TestData));
    assertNotNull(data, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(TestData));

    TlvExtent extent = getTruthTableExtent(truthTable, truthTableKey);

    data->interest = parcBuffer_Wrap(packet, length, extent.offset, extent.offset + extent.length);
    data->decoder = ccnxCodecTlvDecoder_Create(data->interest);

    // content objects have more fields than interests, so use that
    data->dictionary = ccnxTlvDictionary_Create(CCNxCodecSchemaV1TlvDictionary_MessageFastArray_END, CCNxCodecSchemaV1TlvDictionary_Lists_END);

    data->packet = packet;
    data->packetLength = length;
    data->truthTable = truthTable;
    return data;
}

void
commonSetupWholePacket(LongBowTestCase *testCase, uint8_t *packet, size_t length, TruthTableEntry *truthTable)
{
    TestData *data = parcMemory_AllocateAndClear(sizeof(TestData));
    assertNotNull(data, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(TestData));

    data->interest = parcBuffer_Wrap(packet, length, 0, length);
    data->decoder = ccnxCodecTlvDecoder_Create(data->interest);
    data->dictionary = ccnxTlvDictionary_Create(CCNxCodecSchemaV1TlvDictionary_MessageFastArray_END, CCNxCodecSchemaV1TlvDictionary_Lists_END);

    data->packet = packet;
    data->packetLength = length;
    data->truthTable = truthTable;

    longBowTestCase_SetClipBoardData(testCase, data);
}

void
commonTeardown(TestData *data)
{
    ccnxTlvDictionary_Release(&data->dictionary);
    ccnxCodecTlvDecoder_Destroy(&data->decoder);
    parcBuffer_Release(&data->interest);
    parcMemory_Deallocate((void **) &data);
}

/**
 * Tests that an int32_t getter returns the right value
 *
 * Given a packet byte array and a truth table (see transport/test_tools/testdata/testrig_truthTable.h),
 * check that the buffer the decoder parsed is the right buffer.
 *
 * The function will run the specified decoder on the TestData's packet and put the results in the
 * TestData's dictionary.  It will then call the specified getter and make sure its value is equal
 * to the truth table's value.
 *
 * The function will assert if the test fails.
 *
 * @param [in] testCase Used to get the clipboard data with the TestData member
 * @param [in] truthTableKey Used to match the .indexOrKey truth table member
 * @param [in] containerDecoder The decoder to use on the packet contained in TestData
 * @param [in] getter The function to call to fetch a decoded value
 *
 * Example:
 * @code
 *
 * static uint8_t object_nameC_keyid3_protoinfo[] = {
 *      0x00, 0x02, 0x00,  110,     // ver = 0, type = object, length = 110
 *      0x00, 0x00, 0x00,    5,     // reserved = 0, header length = 5
 *      // ---------------------------
 *      // snip middle of packet
 *      // ------------------------
 *      // byte offset 76
 *      0x00, 0x03, 0x00,   26,      // Protocol Information, length = 26
 *      0x00, 0x0B, 0x00,   17,     // Object Metadata, length = 17
 *      0x00, 0x0C, 0x00, 0x01,     // Object Type, length = 1
 *      0x04,                       // LINK
 *      0x00, 0x0D, 0x00,    8,     // Creation Time
 *      0x00, 0x00, 0x01, 0x43,     // 1,388,534,400,000 msec
 *      0x4B, 0x19, 0x84, 0x00,
 *      0x00, 0x19, 0x00, 0x01,     // EndSegment, length = 1
 *      42,
 *      // ---------------------------
 *      // snip to end of packet
 *      // ---------------------------
 * };
 *
 * static TruthTableEntry TRUTHTABLENAME(object_nameC_keyid3_protoinfo)[] = {
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_METADATA,      .bodyManifest=true,  .extent = { 80, 17} },
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_OBJ_TYPE,      .bodyManifest=true,  .extent = { 84,  1} },
 *    { .wellKnownType = false, .indexOrKey = T_INVALID,  .extent = { 0,  0} },
 * };
 *
 * LONGBOW_TEST_FIXTURE_SETUP(Global)
 * {
 *    commonSetup(testCase, object_nameC_keyid3_protoinfo, sizeof(object_nameC_keyid3_protoinfo), object_nameC_keyid3_protoinfo_truthTableEntries, MANIFEST_OBJ_METADATA);
 *    return LONGBOW_STATUS_SUCCEEDED;
 * }
 *
 * LONGBOW_TEST_CASE(Global, ccnxCodecSchemaV0ProtoInfo_GetEndSegmentNumber)
 * {
 *    testInt32Getter(testCase, MANIFEST_OBJ_OBJ_TYPE, ccnxCodecSchemaV0Metadata_Decode, ccnxCodecSchemaV0Metadata_GetContentType);
 * }
 * * @endcode
 */
void
testInt32Getter(LongBowTestCase *testCase, int truthTableKey, bool containerDecoder(CCNxCodecTlvDecoder *, CCNxTlvDictionary *),
                int32_t (*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    containerDecoder(data->decoder, data->dictionary);
    int32_t testvalue = getter(data->dictionary);

    // look up the true name buffer from the truth table
    TlvExtent extent = getTruthTableExtent(data->truthTable, truthTableKey);
    PARCBuffer *truthbuffer = parcBuffer_Wrap(data->packet, data->packetLength, extent.offset, extent.offset + extent.length);
    uint64_t truthvalue = -2;
    ccnxCodecTlvUtilities_GetVarInt(truthbuffer, parcBuffer_Remaining(truthbuffer), &truthvalue);

    parcBuffer_Release(&truthbuffer);

    assertTrue(testvalue == (int32_t) truthvalue, "Wrong value, got %d expected %d", testvalue, (int32_t) truthvalue);
}

/**
 * Tests that an int64_t getter returns the right value
 *
 * Given a packet byte array and a truth table (see transport/test_tools/testdata/testrig_truthTable.h),
 * check that the buffer the decoder parsed is the right buffer.
 *
 * The function will run the specified decoder on the TestData's packet and put the results in the
 * TestData's dictionary.  It will then call the specified getter and make sure its value is equal
 * to the truth table's value.
 *
 * The function will assert if the test fails.
 *
 * @param [in] testCase Used to get the clipboard data with the TestData member
 * @param [in] truthTableKey Used to match the .indexOrKey truth table member
 * @param [in] containerDecoder The decoder to use on the packet contained in TestData
 * @param [in] getter The function to call to fetch a decoded value
 *
 * Example:
 * @code
 *
 * static uint8_t object_nameC_keyid3_protoinfo[] = {
 *      0x00, 0x02, 0x00,  110,     // ver = 0, type = object, length = 110
 *      0x00, 0x00, 0x00,    5,     // reserved = 0, header length = 5
 *      // ---------------------------
 *      // snip middle of packet
 *      // ------------------------
 *      // byte offset 76
 *      0x00, 0x03, 0x00,   26,      // Protocol Information, length = 26
 *      0x00, 0x0B, 0x00,   17,     // Object Metadata, length = 17
 *      0x00, 0x0C, 0x00, 0x01,     // Object Type, length = 1
 *      0x04,                       // LINK
 *      0x00, 0x0D, 0x00,    8,     // Creation Time
 *      0x00, 0x00, 0x01, 0x43,     // 1,388,534,400,000 msec
 *      0x4B, 0x19, 0x84, 0x00,
 *      0x00, 0x19, 0x00, 0x01,     // EndSegment, length = 1
 *      42,
 *      // ---------------------------
 *      // snip to end of packet
 *      // ---------------------------
 * };
 *
 * static TruthTableEntry TRUTHTABLENAME(object_nameC_keyid3_protoinfo)[] = {
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_PROTOINFO,     .bodyManifest=true,  .extent = { 76, 26} },
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_ENDSEGMENT,    .bodyManifest=true,  .extent = {101,  1} },
 *    { .wellKnownType = false, .indexOrKey = T_INVALID,  .extent = { 0,  0} },
 * };
 *
 * LONGBOW_TEST_FIXTURE_SETUP(Global)
 * {
 *    commonSetup(testCase, object_nameC_keyid3_protoinfo, sizeof(object_nameC_keyid3_protoinfo), object_nameC_keyid3_protoinfo_truthTableEntries, MANIFEST_OBJ_PROTOINFO);
 *    return LONGBOW_STATUS_SUCCEEDED;
 * }
 *
 * LONGBOW_TEST_CASE(Global, ccnxCodecSchemaV0ProtoInfo_GetEndSegmentNumber)
 * {
 *    testInt64Getter(testCase, MANIFEST_OBJ_ENDSEGMENT, ccnxCodecSchemaV0ProtoInfo_Decode, ccnxCodecSchemaV0ProtoInfo_GetEndSegmentNumber);
 * }
 *
 * @endcode
 */
void
testInt64Getter(TestData *data, int truthTableKey, bool containerDecoder(CCNxCodecTlvDecoder *, CCNxTlvDictionary *),
                int64_t (*getter)(CCNxTlvDictionary *))
{
    containerDecoder(data->decoder, data->dictionary);
    int64_t testvalue = getter(data->dictionary);

    // look up the true name buffer from the truth table
    TlvExtent extent = getTruthTableExtent(data->truthTable, truthTableKey);
    PARCBuffer *truthbuffer = parcBuffer_Wrap(data->packet, data->packetLength, extent.offset, extent.offset + extent.length);
    uint64_t truthvalue = -2;
    ccnxCodecTlvUtilities_GetVarInt(truthbuffer, parcBuffer_Remaining(truthbuffer), &truthvalue);

    parcBuffer_Release(&truthbuffer);

    assertTrue(testvalue == (int64_t) truthvalue, "Wrong value, got %" PRId64 " expected %" PRId64, testvalue, (int64_t) truthvalue);
}

/**
 * Tests that a buffer getter returns the right buffer
 *
 * Given a packet byte array and a truth table (see transport/test_tools/testdata/testrig_truthTable.h),
 * check that the buffer the decoder parsed is the right buffer.
 *
 * The function will run the specified decoder on the TestData's packet and put the results in the
 * TestData's dictionary.  It will then call the specified getter and make sure its value is equal
 * to the truth table's value.
 *
 * The function will assert if the test fails.
 *
 * @param [in] testCase Used to get the clipboard data with the TestData member
 * @param [in] truthTableKey Used to match the .indexOrKey truth table member
 * @param [in] containerDecoder The decoder to use on the packet contained in TestData
 * @param [in] getter The function to call to fetch a decoded value
 *
 * Example:
 * @code
 *
 * static uint8_t object_nameC_keyid3_protoinfo[] = {
 *      0x00, 0x02, 0x00,  110,     // ver = 0, type = object, length = 110
 *      0x00, 0x00, 0x00,    5,     // reserved = 0, header length = 5
 *      // ---------------------------
 *      // snip middle of packet
 *      // ------------------------
 *      // byte offset = 117
 *      0x00, 0x05, 0x00, 0x06,      // signature block, length = 6
 *      0x00, 0x0E, 0x00, 0x02,      // signature bits, length = 2
 *      0xBE, 0xEF                   // value = 0xBEEF
 * };
 *
 * static TruthTableEntry TRUTHTABLENAME(object_nameC_keyid3_protoinfo)[] = {
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_SIGBLOCK,      .bodyManifest=true,  .extent = {117,  6} },
 *    { .wellKnownType = true,  .indexOrKey = MANIFEST_OBJ_SIGBITS,       .bodyManifest=true,  .extent = {121,  2} },
 *    { .wellKnownType = false, .indexOrKey = T_INVALID,  .extent = { 0,  0} },
 * };
 *
 * LONGBOW_TEST_FIXTURE_SETUP(Global)
 * {
 *    commonSetup(testCase, object_nameC_keyid3_protoinfo, sizeof(object_nameC_keyid3_protoinfo), object_nameC_keyid3_protoinfo_truthTableEntries, MANIFEST_OBJ_SIGBLOCK);
 *    return LONGBOW_STATUS_SUCCEEDED;
 * }
 *
 * LONGBOW_TEST_CASE(Global, ccnxCodecSchemaV0SigBlock_GetSignatureBits)
 * {
 *    testBufferGetter(testCase, MANIFEST_OBJ_SIGBITS, ccnxCodecSchemaV0SigBlock_Decode, ccnxCodecSchemaV0SigBlock_GetSignatureBits);
 * }
 *
 * @endcode
 */
void
testBufferGetter(TestData *data, int truthTableKey, bool containerDecoder(CCNxCodecTlvDecoder *, CCNxTlvDictionary *),
                 PARCBuffer *(*getter)(const CCNxTlvDictionary *))
{
    containerDecoder(data->decoder, data->dictionary);
    PARCBuffer *test = getter(data->dictionary);

    // look up the true name buffer from the truth table
    TlvExtent extent = getTruthTableExtent(data->truthTable, truthTableKey);
    PARCBuffer *truth = parcBuffer_Wrap(data->packet, data->packetLength, extent.offset, extent.offset + extent.length);

    assertTrue(parcBuffer_Equals(test, truth), "Buffers not equal")
    {
        printf("Expected:\n");
        parcBuffer_Display(truth, 3);
        printf("Got:\n");
        parcBuffer_Display(test, 3);
    }

    parcBuffer_Release(&truth);
}

void
testHashGetter(TestData *data, int truthTableKey, bool containerDecoder(CCNxCodecTlvDecoder *, CCNxTlvDictionary *),
               PARCCryptoHash *(*getter)(CCNxTlvDictionary *))
{
    containerDecoder(data->decoder, data->dictionary);
    PARCCryptoHash *testHash = getter(data->dictionary);

    // look up the true hash buffer from the truth table
    TlvExtent extent = getTruthTableExtent(data->truthTable, truthTableKey);
    PARCBuffer *truthBuffer = parcBuffer_Wrap(data->packet, data->packetLength, extent.offset, extent.offset + extent.length);

    // decode the hash value
    CCNxCodecTlvDecoder *decoder = ccnxCodecTlvDecoder_Create(truthBuffer);
    PARCCryptoHash *truthHash = ccnxCodecSchemaV1HashCodec_DecodeValue(decoder, extent.length);
    ccnxCodecTlvDecoder_Destroy(&decoder);

    // compare the decoded value against the expected value
    assertTrue(parcCryptoHash_Equals(testHash, truthHash), "Hashes not equal")
    {
        printf("Expected:\n");
        printf("   %s\n", parcBuffer_ToHexString(parcCryptoHash_GetDigest(truthHash)));
        printf("Got:\n");
        printf("   %s\n", parcBuffer_ToHexString(parcCryptoHash_GetDigest(testHash)));
    }

    parcCryptoHash_Release(&truthHash);
    parcBuffer_Release(&truthBuffer);
}

void
testNameGetter(TestData *data, int truthTableKey, bool containerDecoder(CCNxCodecTlvDecoder *, CCNxTlvDictionary *),
               CCNxName *(*getter)(CCNxTlvDictionary *))
{
    containerDecoder(data->decoder, data->dictionary);
    CCNxName *test = getter(data->dictionary);

    // look up the true name buffer from the truth table
    TlvExtent extent = getTruthTableExtent(data->truthTable, truthTableKey);

    // we need to backup 4 bytes to get the TLV container
    PARCBuffer *truthBuffer =
        parcBuffer_Wrap(data->packet, data->packetLength, extent.offset - 4, extent.offset + extent.length);

    CCNxCodecTlvDecoder *decoder = ccnxCodecTlvDecoder_Create(truthBuffer);
    CCNxName *truthName = ccnxCodecSchemaV1NameCodec_Decode(decoder, CCNxCodecSchemaV1Types_CCNxMessage_Name);
    ccnxCodecTlvDecoder_Destroy(&decoder);

    assertTrue(ccnxName_Equals(test, truthName), "Names not equal")
    {
        printf("Expected:\n");
        ccnxName_Display(truthName, 3);
        printf("Got:\n");
        ccnxName_Display(test, 3);
    }

    ccnxName_Release(&truthName);
    parcBuffer_Release(&truthBuffer);
}

void
testMissingInt32Getter(LongBowTestCase *testCase, int32_t (*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    int32_t test = getter(data->dictionary);

    assertTrue(test == -1, "Wrong value, got %d expected %d", test, -1);
}

/**
 * Tried to retrieve execute the getter on the dictionary and ensures that
 * the field is missing.
 */
void
testMissingInt64Getter(LongBowTestCase *testCase, int64_t (*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    int64_t test = getter(data->dictionary);

    assertTrue(test == -1, "Wrong value, got %" PRId64 " expected %d", test, -1);
}

/**
 * Tried to retrieve execute the getter on the dictionary and ensures that
 * the field is missing.
 */
void
testMissingNameGetter(LongBowTestCase *testCase, CCNxName *(*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    CCNxName *test = getter(data->dictionary);

    assertNull(test, "Should have gotten null for missing field, got %p", (void *) test);
}

/**
 * Tried to retrieve execute the getter on the dictionary and ensures that
 * the field is missing.
 */
void
testMissingBufferGetter(LongBowTestCase *testCase, PARCBuffer *(*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    PARCBuffer *test = getter(data->dictionary);

    assertNull(test, "Should have gotten null for missing field, got %p", (void *) test);
}

/**
 * Tried to retrieve execute the getter on the dictionary and ensures that
 * the field is missing.
 */
void
testMissingDictionaryGetter(LongBowTestCase *testCase, CCNxTlvDictionary *(*getter)(CCNxTlvDictionary *))
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    CCNxTlvDictionary *test = getter(data->dictionary);

    assertNull(test, "Should have gotten null for missing field, got %p", (void *) test);
}