LONGBOW_TEST_CASE(Global, athenaFIB_RemoveLink) { TestData *data = longBowTestCase_GetClipBoardData(testCase); athenaFIB_AddRoute(data->testFIB, data->testName1, data->testVector1); athenaFIB_AddRoute(data->testFIB, data->testName2, data->testVector2); PARCBitVector *result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); result = athenaFIB_Lookup(data->testFIB, data->testName2, NULL); assertTrue(parcBitVector_Equals(result, data->testVector2), "Expected lookup to equal test vector"); parcBitVector_Release(&result); athenaFIB_RemoveLink(data->testFIB, data->testVector1); result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertNull(result, "Expecting a NULL result from Lookup after Delete Route"); result = athenaFIB_Lookup(data->testFIB, data->testName2, NULL); assertTrue(parcBitVector_Equals(result, data->testVector2), "Expected lookup to equal test vector"); parcBitVector_Release(&result); athenaFIB_AddRoute(data->testFIB, data->testName1, data->testVector12); athenaFIB_RemoveLink(data->testFIB, data->testVector2); result = athenaFIB_Lookup(data->testFIB, data->testName2, NULL); assertNull(result, "Expecting a NULL result from Lookup after Delete Route"); result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); }
LONGBOW_TEST_CASE(Global, athenaFIB_CreateEntryList) { TestData *data = longBowTestCase_GetClipBoardData(testCase); athenaFIB_AddRoute(data->testFIB, data->testName1, data->testVector12); PARCBitVector *result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertTrue(parcBitVector_Equals(result, data->testVector12), "Expected lookup to equal test vector"); parcBitVector_Release(&result); PARCList *entryList = athenaFIB_CreateEntryList(data->testFIB); assertTrue(parcList_Size(entryList) == 2, "Expected the EntryList to have 2 elements"); AthenaFIBListEntry *entry = parcList_GetAtIndex(entryList, 0); assertNotNull(entry, "Expect entry at 0 to be non-NULL"); assertTrue(ccnxName_Equals(data->testName1, entry->name), "Expect the name at 0 to be testName1"); assertTrue(entry->linkId == 0, "Expect the routeId at 0 to be 0"); entry = parcList_GetAtIndex(entryList, 1); assertNotNull(entry, "Expect entry at 1 to be non-NULL"); assertTrue(ccnxName_Equals(data->testName1, entry->name), "Expect the name at 1 to be testName1"); assertTrue(entry->linkId == 42, "Expect the routeId at 0 to be 42"); parcList_Release(&entryList); }
LONGBOW_TEST_CASE(Global, athenaFIB_Lookup_EmptyPath) { TestData *data = longBowTestCase_GetClipBoardData(testCase); athenaFIB_AddRoute(data->testFIB, data->testName3, data->testVector1); PARCBitVector *result = athenaFIB_Lookup(data->testFIB, data->testName3, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); result = athenaFIB_Lookup(data->testFIB, data->testName2, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); athenaFIB_AddRoute(data->testFIB, data->testName3, data->testVector2); result = athenaFIB_Lookup(data->testFIB, data->testName3, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector12), "Expected lookup to equal test vector"); parcBitVector_Release(&result); result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector12), "Expected lookup to equal test vector"); parcBitVector_Release(&result); result = athenaFIB_Lookup(data->testFIB, data->testName2, NULL); assertNotNull(result, "Expect non-null match to global path (\"/\")"); assertTrue(parcBitVector_Equals(result, data->testVector12), "Expected lookup to equal test vector"); parcBitVector_Release(&result); }
LONGBOW_TEST_CASE(Global, parcBitVector_Equals) { PARCBitVector *parcBitVector = parcBitVector_Create(); assertTrue(parcBitVector, "parcBitVector_Create returned a NULL pointer"); parcBitVector_Set(parcBitVector, 10); PARCBitVector *copy = parcBitVector_Copy(parcBitVector); assertTrue(parcBitVector_Equals(parcBitVector, copy), "Duplicate vector found unequal"); parcBitVector_Set(copy, 9); assertFalse(parcBitVector_Equals(parcBitVector, copy), "Unequal vector found equal"); parcBitVector_Clear(copy, 9); parcBitVector_Set(copy, 29); assertFalse(parcBitVector_Equals(parcBitVector, copy), "Unequal long vector found equal"); parcBitVector_Clear(copy, 29); assertTrue(parcBitVector_Equals(parcBitVector, copy), "Equal long vector found unequal"); assertTrue(parcBitVector_Equals(copy, parcBitVector), "Equal long vector found unequal"); parcBitVector_Release(©); parcBitVector_Release(&parcBitVector); }
LONGBOW_TEST_CASE(Global, athenaFIB_Lookup) { TestData *data = longBowTestCase_GetClipBoardData(testCase); athenaFIB_AddRoute(data->testFIB, data->testName1, data->testVector1); PARCBitVector *result = athenaFIB_Lookup(data->testFIB, data->testName1, NULL); assertTrue(parcBitVector_Equals(result, data->testVector1), "Expected lookup to equal test vector"); parcBitVector_Release(&result); // // Name3 (the default route) contains both vector1 and vector2. // Name1 (a/b/c) contains only vector 1. // Name4 (a/b/c/d) is what we're looking for. // Although Name1 is a match for Name4, it only contains the ingress vector1. // We must the search until we match the default route. Ingress vector1 // must be removed from the returned vector list from the default route. // // Make sure we see only vector2 in the result. // athenaFIB_AddRoute(data->testFIB, data->testName3, data->testVector12); result = athenaFIB_Lookup(data->testFIB, data->testName4, data->testVector1); assertTrue(parcBitVector_Equals(result, data->testVector2), "Expected lookup to equal test vector"); parcBitVector_Release(&result); }