~ubuntu-branches/ubuntu/wily/libjna-java/wily-proposed

« back to all changes in this revision

Viewing changes to test/com/sun/jna/DirectReturnTypesTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-11-02 14:14:51 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20091102141451-j5hdwzzq5zwxrp4n
* New upstream release.
* Fixed debian/repack-source.sh to correctly use mktemp.
* Make libjna-java Depends on *-headless packages.
* Moved package under pkg-java control.
* Added debian/README.source to describe quilt.
* Added myself as Uploader.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2009 Timothy Wall, All Rights Reserved
 
2
 *
 
3
 * This library is free software; you can redistribute it and/or
 
4
 * modify it under the terms of the GNU Lesser General Public
 
5
 * License as published by the Free Software Foundation; either
 
6
 * version 2.1 of the License, or (at your option) any later version.
 
7
 * <p/>
 
8
 * This library is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.  
 
12
 */
 
13
package com.sun.jna;
 
14
 
 
15
import java.util.HashMap;
 
16
import java.util.Map;
 
17
 
 
18
import junit.framework.TestCase;
 
19
 
 
20
import com.sun.jna.ReturnTypesTest.TestLibrary.SimpleStructure;
 
21
import com.sun.jna.ReturnTypesTest.TestLibrary.TestStructure;
 
22
import com.sun.jna.ReturnTypesTest.TestLibrary.TestSmallStructure;
 
23
 
 
24
/** Exercise a range of native methods.
 
25
 *
 
26
 * @author twall@users.sf.net
 
27
 */
 
28
public class DirectReturnTypesTest extends ReturnTypesTest {
 
29
 
 
30
    public static class DirectTestLibrary implements TestLibrary {
 
31
        
 
32
        public Object returnObjectArgument(Object s) {
 
33
            throw new IllegalArgumentException(s.getClass().getName());
 
34
        }
 
35
        public TestObject returnObjectArgument(TestObject s) {
 
36
            throw new IllegalArgumentException(s.getClass().getName());
 
37
        }
 
38
        public native boolean returnFalse();
 
39
        public native boolean returnTrue();
 
40
        public native int returnInt32Zero();
 
41
        public native int returnInt32Magic();
 
42
        public native long returnInt64Zero();
 
43
        public native long returnInt64Magic();
 
44
        public native NativeLong returnLongZero();
 
45
        public native NativeLong returnLongMagic();
 
46
        public native float returnFloatZero();
 
47
        public native float returnFloatMagic();
 
48
        public native double returnDoubleZero();
 
49
        public native double returnDoubleMagic();
 
50
        public native String returnStringMagic();
 
51
        public native WString returnWStringMagic();
 
52
        public native SimpleStructure returnStaticTestStructure();
 
53
        public native SimpleStructure returnNullTestStructure();
 
54
        public native TestSmallStructure.ByValue returnSmallStructureByValue();
 
55
        public native TestStructure.ByValue returnStructureByValue();
 
56
 
 
57
        public Pointer[] returnPointerArgument(Pointer[] arg) {throw new UnsupportedOperationException();}
 
58
        public String[] returnPointerArgument(String[] arg) {throw new UnsupportedOperationException();}
 
59
        public WString[] returnPointerArgument(WString[] arg) {throw new UnsupportedOperationException();}
 
60
 
 
61
        static {
 
62
            Native.register("testlib");
 
63
        }
 
64
    }
 
65
 
 
66
    protected void setUp() {
 
67
        lib = new DirectTestLibrary();
 
68
    }
 
69
    
 
70
    public static class DirectObjectTestLibrary extends DirectTestLibrary {
 
71
        public DirectObjectTestLibrary(Map options) {
 
72
            Native.register(getClass(), NativeLibrary.getInstance("testlib", options));
 
73
        }
 
74
    }
 
75
 
 
76
    public static class DirectNativeMappedLibrary implements NativeMappedLibrary {
 
77
        public native Custom returnInt32Argument(int arg);
 
78
        static {
 
79
            Native.register("testlib");
 
80
        }
 
81
    }
 
82
    protected NativeMappedLibrary loadNativeMappedLibrary() {
 
83
        return new DirectNativeMappedLibrary();
 
84
    }
 
85
 
 
86
    // Override not-yet-supported tests
 
87
    public void testReturnObject() { }
 
88
    public void testReturnPointerArray() { }
 
89
    public void testReturnStringArray() { }
 
90
    public void testReturnWStringArray() { }
 
91
 
 
92
    public static void main(java.lang.String[] argList) {
 
93
        junit.textui.TestRunner.run(DirectReturnTypesTest.class);
 
94
    }
 
95
}