private void testSetFloat(Buffer buff) throws Exception { for (int i = 0; i < numSets; i++) { buff.setFloat(i * 4, (float) i); } for (int i = 0; i < numSets; i++) { assertEquals((float) i, buff.getFloat(i * 4), 0); } }
@Test public void testGetFloat() throws Exception { int numFloats = 100; Buffer b = Buffer.buffer(numFloats * 4); for (int i = 0; i < numFloats; i++) { b.setFloat(i * 4, i); } for (int i = 0; i < numFloats; i++) { assertEquals((float) i, b.getFloat(i * 4), 0); } }
@Test public void testSetOutOfBounds() throws Exception { Buffer b = Buffer.buffer(numSets); assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0)); assertIndexOutOfBoundsException(() -> b.setInt(-1, 0)); assertIndexOutOfBoundsException(() -> b.setLong(-1, 0)); assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0)); assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0)); assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0)); assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b)); assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0)); assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1)); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1))); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0)); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1)); assertIndexOutOfBoundsException(() -> b.setString(-1, "")); assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8")); }
private void testSetFloat(Buffer buff) throws Exception { for (int i = 0; i < numSets; i++) { buff.setFloat(i * 4, (float) i); } for (int i = 0; i < numSets; i++) { assertEquals((float) i, buff.getFloat(i * 4), 0); } }
@Test public void testGetFloat() throws Exception { int numFloats = 100; Buffer b = Buffer.buffer(numFloats * 4); for (int i = 0; i < numFloats; i++) { b.setFloat(i * 4, i); } for (int i = 0; i < numFloats; i++) { assertEquals((float) i, b.getFloat(i * 4), 0); } }
/** * Sets the <code>float</code> at position <code>pos</code> in the Buffer to the value <code>f</code>.<p> * The buffer will expand as necessary to accommodate any value written. * @param pos * @param f * @return */ public io.vertx.rxjava.core.buffer.Buffer setFloat(int pos, float f) { delegate.setFloat(pos, f); return this; }
/** * Sets the <code>float</code> at position <code>pos</code> in the Buffer to the value <code>f</code>.<p> * The buffer will expand as necessary to accommodate any value written. * @param pos * @param f * @return */ public io.vertx.rxjava.core.buffer.Buffer setFloat(int pos, float f) { delegate.setFloat(pos, f); return this; }
@Test public void testSetOutOfBounds() throws Exception { Buffer b = Buffer.buffer(numSets); assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0)); assertIndexOutOfBoundsException(() -> b.setInt(-1, 0)); assertIndexOutOfBoundsException(() -> b.setLong(-1, 0)); assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0)); assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0)); assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0)); assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b)); assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0)); assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1)); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1))); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0)); assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1)); assertIndexOutOfBoundsException(() -> b.setString(-1, "")); assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8")); }
buf.setFloat(_pos, floatValue); _pos += 4; } else if (clazz == SDouble.class) {