/[cffi-objects]/tests.lisp
ViewVC logotype

Contents of /tests.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations)
Tue Dec 25 01:10:43 2012 UTC (15 months, 4 weeks ago) by rklochkov
File size: 884 byte(s)
Added initargs
1 (defpackage #:cffi-objects.tests
2 (:use #:cl #:cffi-objects #:hu.dwim.stefil))
3
4 (in-package #:cffi-objects.tests)
5
6 (defsuite* (test-suite
7 :in root-suite
8 :documentation "Testing CFFI-objects"))
9
10 (defcstruct* test
11 (x :int))
12
13 (deftest test.struct ()
14 (is (= (let ((obj (make-instance 'test)))
15 (setf (x obj) 1)
16 (x obj)) 1))
17 (is (= 1 (x (make-instance 'test :x 1)))))
18
19 (deftest test.carray ()
20 (let ((obj (make-array 10)))
21 (dotimes (i 10)
22 (setf (aref obj i)
23 (let ((struct (make-instance 'test)))
24 (setf (x struct) i)
25 struct)))
26 (setf (mem-ref *array-length* :int) 10)
27 (is (every (lambda (a b) (= (x a) (x b)))
28 obj
29 (convert-from-foreign
30 (convert-to-foreign obj '(carray (struct test)))
31 '(carray (struct test)))))))

  ViewVC Help
Powered by ViewVC 1.1.5