Пример #1
0
  @Test
  public void testSizes() {
    int clong = isWindows() || !is64Bits() ? 4 : 8;
    int sizet = is64Bits() ? 8 : 4, ptr = sizet;
    int wchar = isUnix() ? 4 : 2;

    assertEquals(clong, Platform.CLONG_SIZE);
    assertEquals(sizet, Platform.SIZE_T_SIZE);
    assertTrue(Platform.TIME_T_SIZE > 0);
    assertEquals(wchar, Platform.WCHAR_T_SIZE);
    assertEquals(ptr, Platform.POINTER_SIZE);

    assertEquals(ptr, Pointer.SIZE);
    assertEquals(sizet, SizeT.SIZE);
    assertTrue(TimeT.SIZE > 0);
    assertEquals(clong, CLong.SIZE);
  }
Пример #2
0
  @Test
  public void testMachine() throws Exception {
    if (!isUnix()) return;

    Process p = Runtime.getRuntime().exec(new String[] {"uname", "-m"});
    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));

    String uname = r.readLine().trim();
    String m = uname;
    assertTrue(m.length() > 0);

    if (m.matches("i\\d86")) m = "i386";
    else if (m.matches("i86pc")) m = "x86";

    if (m.equals("i386") && Platform.is64Bits()) m = "x86_64";

    assertEquals(
        "uname = " + uname + ", Platform.getMachine = " + Platform.getMachine(),
        m,
        Platform.getMachine());
  }