File: primitive_ref_runme.java

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (64 lines) | stat: -rw-r--r-- 2,223 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Check that C++ primitive types that are passed by const reference work when
// passed by value from Java

import primitive_ref.*;
import java.math.*;

public class primitive_ref_runme {

  static {
    try {
	System.loadLibrary("primitive_ref");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[]) {

    if (primitive_ref.ref_int(3) != 3) {
        throw new RuntimeException( "ref_int failed!" );
    }
    if (primitive_ref.ref_uint(3) != 3) {
        throw new RuntimeException( "ref_uint failed!" );
    }
    if (primitive_ref.ref_short((short)3) != 3) {
        throw new RuntimeException( "ref_short failed!" );
    }
    if (primitive_ref.ref_ushort(3) != 3) {
        throw new RuntimeException( "ref_ushort failed!" );
    }
    if (primitive_ref.ref_long(3) != 3) {
        throw new RuntimeException( "ref_long failed!" );
    }
    if (primitive_ref.ref_ulong(3) != 3) {
        throw new RuntimeException( "ref_ulong failed!" );
    }
    if (primitive_ref.ref_schar((byte)3) != 3) {
        throw new RuntimeException( "ref_schar failed!" );
    }
    if (primitive_ref.ref_uchar((short)3) != 3) {
        throw new RuntimeException( "ref_uchar failed!" );
    }
    if (primitive_ref.ref_bool(true) != true) {
        throw new RuntimeException( "ref_bool failed!" );
    }
    if (primitive_ref.ref_float((float)3.5) != 3.5) {
        throw new RuntimeException( "ref_float failed!" );
    }
    if (primitive_ref.ref_double(3.5) != 3.5) {
        throw new RuntimeException( "ref_double failed!" );
    }
    if (primitive_ref.ref_char('x') != 'x') {
        throw new RuntimeException( "ref_char failed!" );
    }
    if (primitive_ref.ref_longlong(0x123456789ABCDEF0L) != 0x123456789ABCDEF0L) {
        throw new RuntimeException( "ref_longlong failed!" );
    }
    BigInteger bi = new BigInteger("18446744073709551615"); //0xFFFFFFFFFFFFFFFFL
    if (bi.compareTo(primitive_ref.ref_ulonglong(bi)) != 0) {
        throw new RuntimeException( "ref_ulonglong failed!" );
    }
  }
}