r10563: add module keyword to def-function
[uffi.git] / tests / atoifl.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          atoifl.lisp
6 ;;;; Purpose:       UFFI Example file to atoi/atof/atol
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Mar 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of UFFI, is Copyright (c) 2002-2003 by Kevin M. Rosenberg
13 ;;;;
14 ;;;; *************************************************************************
15
16 (in-package #:uffi-tests)
17
18 (uffi:def-function ("atoi" c-atoi) 
19     ((str :cstring))
20   :module "c"
21   :returning :int)
22
23 (uffi:def-function ("atol" c-atol) 
24     ((str :cstring))
25   :module "c"
26   :returning :long)
27
28 (uffi:def-function ("atof" c-atof) 
29     ((str :cstring))
30   :module "c"
31   :returning :double)
32
33 (defun atoi (str)
34   "Returns a int from a string."
35   (uffi:with-cstring (str-cstring str)
36     (c-atoi str-cstring)))
37
38 (defun atof (str)
39   "Returns a double float from a string."
40   (uffi:with-cstring (str-cstring str)
41     (c-atof str-cstring)))
42   
43 (deftest atoi.1 (atoi "123") 123)
44 (deftest atoi.2 (atoi "") 0)
45 (deftest atof.3 (atof "2.23") 2.23d0)