Remove old CVS $Id$ keyword
[uffi.git] / tests / casts.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICAION
4 ;;;;
5 ;;;; Name:          casts.lisp
6 ;;;; Purpose:       Tests of with-cast-pointer
7 ;;;; Programmer:    Kevin M. Rosenberg / Edi Weitz
8 ;;;; Date Started:  Aug 2003
9 ;;;;
10 ;;;; This file, part of UFFI, is Copyright (c) 2003-2010 by Kevin M. Rosenberg
11 ;;;;
12 ;;;; *************************************************************************
13
14 (in-package #:uffi-tests)
15
16 (uffi:def-function ("cast_test_int" cast-test-int)
17     ()
18   :module "uffi_tests"
19   :returning :pointer-void)
20
21 (uffi:def-function ("cast_test_float" cast-test-float)
22     ()
23   :module "uffi_tests"
24   :returning :pointer-void)
25
26 (deftest :cast.1
27   (progn
28     (uffi:with-cast-pointer (temp (cast-test-int) :int)
29       (assert (= (uffi:deref-pointer temp :int) 23)))
30     (let ((result (cast-test-int)))
31       (uffi:with-cast-pointer (result2 result :int)
32         (assert (= (uffi:deref-pointer result2 :int) 23)))
33       (uffi:with-cast-pointer (temp result :int)
34         (assert (= (uffi:deref-pointer temp :int) 23))))
35     t)
36   t)
37
38 (deftest :cast.2
39     (progn
40       (uffi:with-cast-pointer (temp (cast-test-float) :double)
41         (assert (= (uffi:deref-pointer temp :double) 3.21d0)))
42       (let ((result (cast-test-float)))
43         (uffi:with-cast-pointer (result2 result :double)
44           (assert (= (uffi:deref-pointer result2 :double) 3.21d0)))
45         (uffi:with-cast-pointer (temp result :double)
46           (assert (= (uffi:deref-pointer temp :double) 3.21d0))))
47       t)
48   t)
49