Ejemplo n.º 1
0
  @Test
  public void setArray() {
    float value = 0.5f;
    float[] array = {value, value, value, value};
    String name = "test";

    ssclib.ssc_data_set_array(data, name, array, array.length);
    IntByReference length = new IntByReference();
    Pointer result = ssclib.ssc_data_get_array(data, name, length);

    assertThat(length.getValue()).isEqualTo(array.length);
    for (int i = 0; i < length.getValue(); i++) {
      // Offset is by byte (float = 4 bytes)
      assertThat(result.getFloat(i * 4)).isWithin(EPSILON).of(value);
    }
  }
Ejemplo n.º 2
0
  @Test
  public void setMatrix() {
    float value = 0.5f;
    int n = 2;
    float[] array = {value, value, value, value};
    String name = "test";

    ssclib.ssc_data_set_matrix(data, name, array, n, n);
    IntByReference rows = new IntByReference();
    IntByReference cols = new IntByReference();
    Pointer result = ssclib.ssc_data_get_matrix(data, name, rows, cols);

    assertThat(rows.getValue()).isEqualTo(n);
    assertThat(cols.getValue()).isEqualTo(n);
    for (int i = 0; i < rows.getValue(); i++) {
      for (int j = 0; j < cols.getValue(); j++) {
        // Offset is by byte (float = 4 bytes)
        assertThat(result.getFloat((i * j + j) * 4)).isWithin(EPSILON).of(value);
      }
    }
  }
Ejemplo n.º 3
0
 public final float getFloat(long offset) {
   checkBounds(offset, 4);
   return ptr.getFloat(offset);
 }