예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPutGroupsOnlyWithinPreparedRange()
        public virtual void ShouldPutGroupsOnlyWithinPreparedRange()
        {
            // GIVEN
            int nodeCount = 1000;
            RelationshipGroupCache cache = new RelationshipGroupCache(HEAP, ByteUnit.kibiBytes(4), nodeCount);

            int[] counts = new int[nodeCount];
            for (int nodeId = 0; nodeId < Counts.Length; nodeId++)
            {
                counts[nodeId] = Random.Next(10);
                SetCount(cache, nodeId, counts[nodeId]);
            }

            long toNodeId = cache.Prepare(0);

            assertTrue(toNodeId < nodeCount);

            // WHEN
            bool thereAreMoreGroups = true;
            int  cachedCount        = 0;

            while (thereAreMoreGroups)
            {
                thereAreMoreGroups = false;
                for (int nodeId = 0; nodeId < nodeCount; nodeId++)
                {
                    if (counts[nodeId] > 0)
                    {
                        thereAreMoreGroups = true;
                        int typeId = counts[nodeId]--;
                        if (cache.Put((new RelationshipGroupRecord(nodeId)).initialize(true, typeId, -1, -1, -1, nodeId, -1)))
                        {
                            cachedCount++;
                        }
                    }
                }
            }
            assertTrue(cachedCount >= toNodeId);

            // THEN the relationship groups we get back are only for those we prepared for
            int readCount = 0;

            foreach (RelationshipGroupRecord cachedGroup in cache)
            {
                assertTrue(cachedGroup.OwningNode >= 0 && cachedGroup.OwningNode < toNodeId);
                readCount++;
            }
            assertEquals(cachedCount, readCount);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void randomizedTest()
        internal virtual void RandomizedTest()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int count = 10000 + rnd.nextInt(1000);
            int count = 10000 + _rnd.Next(1000);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet uniqueValues = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet();
            MutableLongSet uniqueValues = new LongHashSet();

            while (uniqueValues.size() < count)
            {
                uniqueValues.add(_rnd.nextLong());
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long[] values = uniqueValues.toArray();
            long[] values = uniqueValues.toArray();

            foreach (long v in values)
            {
                assertTrue(_set.add(v));
            }
            shuffle(values);
            foreach (long v in values)
            {
                assertTrue(_set.contains(v));
                assertFalse(_set.add(v));
            }
            assertTrue(_set.containsAll(values));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long[] toRemove = uniqueValues.select(v -> rnd.nextInt(100) < 75).toArray();
            long[] toRemove = uniqueValues.select(v => _rnd.Next(100) < 75).toArray();
            shuffle(toRemove);

            foreach (long v in toRemove)
            {
                assertTrue(_set.remove(v));
                assertFalse(_set.contains(v));
            }

            assertEquals(count - toRemove.Length, _set.size());
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAlwaysResultInFullyCompleted()
        internal virtual void ShouldAlwaysResultInFullyCompleted()
        {
            // given
            int partCount = Random.Next(5, 10);
            PopulationProgress_MultiBuilder builder = multiple();

            for (int i = 0; i < partCount; i++)
            {
                long total = Random.nextLong(10_000_000);
                builder.Add(single(total, total), Random.nextFloat() * Random.Next(1, 10));
            }
            PopulationProgress populationProgress = builder.Build();

            // when
            float progress = populationProgress.Progress;

            // then
            assertEquals(1f, progress);
        }
예제 #4
0
        private void VerifyBehaviour(LongArray array)
        {
            // insert
            for (int i = 0; i < COUNT; i++)
            {
                array.Set(i, i);
            }

            // verify inserted data
            for (int i = 0; i < COUNT; i++)
            {
                assertEquals(i, array.Get(i));
            }

            // verify inserted data with random access patterns
            int stride = 12_345_678;
            int next   = _random.Next(COUNT);

            for (int i = 0; i < COUNT; i++)
            {
                assertEquals(next, array.Get(next));
                next = (next + stride) % COUNT;
            }
        }