X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Fstrtol.cl;h=32c5c42e1bfd836a54595db210d5e7b9d7337c6f;hb=bb58879f51d870e04e6f01b3ba2c4906703079e0;hp=63aea44fb8546fa1a627f193fb44f78e62c78f37;hpb=fb93b1923db347f01bdebc7226e5e1eaacacc9f9;p=uffi.git diff --git a/tests/strtol.cl b/tests/strtol.cl index 63aea44..32c5c42 100644 --- a/tests/strtol.cl +++ b/tests/strtol.cl @@ -1,4 +1,4 @@ -;;;; -*- Mode: ANSI-Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: strtol.cl,v 1.9 2002/03/17 17:33:30 kevin Exp $ +;;;; $Id: strtol.cl,v 1.15 2002/04/02 23:27:05 kevin Exp $ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -36,10 +36,9 @@ Condition flag is T if all of string parses as a long, NIL if their was no string at all, or an integer indicating position in string of first non-valid character" (let* ((str-native (uffi:convert-to-foreign-string str)) - (endptr (uffi:allocate-foreign-object char-ptr)) + (endptr (uffi:allocate-foreign-object 'char-ptr)) (value (c-strtol str-native endptr base)) - (endptr-value (uffi:deref-pointer endptr 'char-ptr)) - next-char-value chars-parsed) + (endptr-value (uffi:deref-pointer endptr 'char-ptr))) (unwind-protect (if (uffi:null-pointer-p endptr-value) @@ -60,7 +59,7 @@ of first non-valid character" -#+test-uffi +#+examples-uffi (progn (flet ((print-results (str) (multiple-value-bind (result flag) (strtol str) @@ -69,3 +68,16 @@ of first non-valid character" (print-results "55.3") (print-results "a"))) +#+test-uffi +(progn + (flet ((test-strtol (str results) + (util.test:test (multiple-value-list (strtol str)) results + :test #'equal + :fail-info "Error testing strtol"))) + (test-strtol "123" '(123 t)) + (test-strtol "0" '(0 t)) + (test-strtol "55a" '(55 2)) + (test-strtol "a" '(nil nil)))) + + +