Ejemplo n.º 1
0
  @Test
  public void setNumber() {
    float targetVal = 0.5f;
    String name = "test";

    ssclib.ssc_data_set_number(data, name, targetVal);
    FloatByReference out = new FloatByReference();
    boolean status = ssclib.ssc_data_get_number(data, name, out);

    assertThat(status).isTrue();
    assertThat(out.getValue()).isWithin(EPSILON).of(targetVal);
  }
Ejemplo n.º 2
0
  /**
   * Private helper to make sure that the data created by the simulation was set as expected.
   * Assumes that we used the "layoutarea" module
   */
  private static void checkSimulationData(Ssc ssclib, Pointer data) {
    FloatByReference val = new FloatByReference();
    boolean status = ssclib.ssc_data_get_number(data, "area", val);
    assertThat(status).isTrue();
    assertThat(val.getValue()).isAtLeast(0f);

    IntByReference rows = new IntByReference();
    IntByReference cols = new IntByReference();
    Pointer mtx = ssclib.ssc_data_get_matrix(data, "convex_hull", rows, cols);
    assertThat(mtx).isNotNull();
    assertThat(rows.getValue()).isGreaterThan(0);
    assertThat(cols.getValue()).isGreaterThan(0);
  }
Ejemplo n.º 3
0
  @Test
  public void testModuleLog() {
    Pointer module = ssclib.ssc_module_create("layoutarea");
    boolean result = ssclib.ssc_module_exec(module, data);

    assertThat(result).isFalse();

    int i = 0;
    IntByReference itemType = new IntByReference();
    FloatByReference time = new FloatByReference();
    String logMsg = ssclib.ssc_module_log(module, i, itemType, time);
    do {
      assertThat(logMsg).isNotNull();

      assertThat(itemType.getValue()).isGreaterThan(0);
      assertThat(time.getValue()).isNotWithin(EPSILON).of(0f);

      i++;
      logMsg = ssclib.ssc_module_log(module, i, itemType, time);
    } while (logMsg != null);
  }