//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWorkOnSingleChunk() public virtual void ShouldWorkOnSingleChunk() { // GIVEN long defaultValue = 0; LongArray array = NumberArrayFactory_Fields.AutoWithoutPagecache.newDynamicLongArray(10, defaultValue); array.Set(4, 5); // WHEN assertEquals(5L, array.Get(4)); assertEquals(defaultValue, array.Get(12)); array.Set(7, 1324); assertEquals(1324L, array.Get(7)); }
private static void UpdateRadix(LongArray values, Radix radix, long highestSetIndex) { for (long dataIndex = 0; dataIndex <= highestSetIndex; dataIndex++) { radix.RegisterRadixOf(values.Get(dataIndex)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPickFirstAvailableCandidateLongArray() public virtual void ShouldPickFirstAvailableCandidateLongArray() { // GIVEN NumberArrayFactory factory = new NumberArrayFactory_Auto(NO_MONITOR, NumberArrayFactory.HEAP); // WHEN LongArray array = factory.NewLongArray(KILO, -1); array.Set(KILO - 10, 12345); // THEN assertTrue(array is HeapLongArray); assertEquals(12345, array.Get(KILO - 10)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldChunksAsNeeded() public virtual void ShouldChunksAsNeeded() { // GIVEN LongArray array = NumberArrayFactory_Fields.AutoWithoutPagecache.newDynamicLongArray(10, 0); // WHEN long index = 243; long value = 5485748; array.Set(index, value); // THEN assertEquals(value, array.Get(index)); }
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; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPickFirstAvailableCandidateLongArrayWhenSomeDontHaveEnoughMemory() public virtual void ShouldPickFirstAvailableCandidateLongArrayWhenSomeDontHaveEnoughMemory() { // GIVEN NumberArrayFactory lowMemoryFactory = mock(typeof(NumberArrayFactory)); doThrow(typeof(System.OutOfMemoryException)).when(lowMemoryFactory).newLongArray(anyLong(), anyLong(), anyLong()); NumberArrayFactory factory = new NumberArrayFactory_Auto(NO_MONITOR, lowMemoryFactory, NumberArrayFactory.HEAP); // WHEN LongArray array = factory.NewLongArray(KILO, -1); array.Set(KILO - 10, 12345); // THEN verify(lowMemoryFactory, times(1)).newLongArray(KILO, -1, 0); assertTrue(array is HeapLongArray); assertEquals(12345, array.Get(KILO - 10)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldHandleSomeRandomSetAndGet() internal virtual Stream <DynamicTest> ShouldHandleSomeRandomSetAndGet() { ThrowingConsumer <NumberArrayFactory> arrayFactoryConsumer = factory => { int length = _random.Next(100_000) + 100; long defaultValue = _random.Next(2) - 1; // 0 or -1 using (LongArray array = factory.newLongArray(length, defaultValue)) { long[] expected = new long[length]; Arrays.Fill(expected, defaultValue); // WHEN int operations = _random.Next(1_000) + 10; for (int i = 0; i < operations; i++) { // THEN int index = _random.Next(length); long value = _random.nextLong(); switch (_random.Next(3)) { case 0: // set array.Set(index, value); expected[index] = value; break; case 1: // get assertEquals(expected[index], array.Get(index), "Seed:" + _seed); break; default: // swap int toIndex = _random.Next(length); array.Swap(index, toIndex); Swap(expected, index, toIndex); break; } } } }; return(stream(ArrayFactories(), NumberArrayFactoryName, arrayFactoryConsumer)); }