예제 #1
0
    def test_exists(self):
        distributedHT = LocalMemoryDHT(8, 10)
        self.__insert(distributedHT)

        for case in self.__cases:
            self.assertTrue(distributedHT.exists(case.hashValue))

        for case in self.__nonExistingCases:
            self.assertFalse(distributedHT.exists(case.hashValue))
예제 #2
0
    def test_countCollision(self):
        distributedHT = LocalMemoryDHT(8, 10)
        self.__insert(distributedHT)

        expectedHashCount = 2
        expectedValueCount = 4
        expectedTotalCount = 9
        hashCount, valueCount, totalCount = distributedHT.countCollision()
        self.assertEqual(hashCount, expectedHashCount)
        self.assertEqual(valueCount, expectedValueCount)
        self.assertEqual(totalCount, expectedTotalCount)
예제 #3
0
    def test_calculateCollision(self):
        distributedHT = LocalMemoryDHT(8, 10)
        self.__insert(distributedHT)

        expected_collision = 4 / 9.0
        self.assertEqual(distributedHT.calculateCollision(), expected_collision)
예제 #4
0
 def test_read(self):
     distributedHT = LocalMemoryDHT(8, 10)
     
     for case in self.__cases:
         distributedHT.insert(case.hashValue)        
         self.assertEqual(distributedHT.read(case.hashValue), case.counter)
예제 #5
0
    def test_calculateHTId(self):
        distributedHT = LocalMemoryDHT(8, 10)

        for case in self.__cases:
            self.assertEqual(distributedHT._calculateHTId(
                case.hashValue), case.htId)