summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.jni/bytebuffer.c
blob: 146c6a8443e33619c3cfb01b855462b70bab2083 (plain)
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
#include "bytebuffer.h"

static void
test_buffer (JNIEnv *env, jobject buffer, const char *name)
{
  void *tmp = (*env)->GetDirectBufferAddress (env, buffer);

  if (tmp == NULL)
    printf ("PASS: address of %s\n", name);
  else
    printf ("FAIL: address of %s\n", name);

  int tmplen = (*env)->GetDirectBufferCapacity (env, buffer);

  if (tmplen == -1)
    printf ("PASS: length of %s\n", name);
  else
    printf ("FAIL: length of %s\n", name);
}

JNIEXPORT void JNICALL
Java_bytebuffer_testByteBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.ByteBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testCharBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.CharBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testDoubleBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.DoubleBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testFloatBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.FloatBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testIntBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.IntBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testLongBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.LongBuffer");
}

JNIEXPORT void JNICALL
Java_bytebuffer_testShortBuffer (JNIEnv *env, jclass k, jobject buffer)
{
  test_buffer (env, buffer, "java.nio.ShortBuffer");
}