[cffi-objects-cvs] r14 -
rklochkov at common-lisp.net
rklochkov at common-lisp.net
Sun Dec 23 06:59:28 UTC 2012
Author: rklochkov
Date: Sat Dec 22 22:59:28 2012
New Revision: 14
Log:
Added tests
Added:
cffi-objects.tests.asd
tests.lisp
Modified:
cffi-objects.asd
Modified: cffi-objects.asd
==============================================================================
--- cffi-objects.asd Sat Dec 22 11:24:45 2012 (r13)
+++ cffi-objects.asd Sat Dec 22 22:59:28 2012 (r14)
@@ -24,11 +24,3 @@
(:file setters :depends-on (package))
(:file array :depends-on (struct))
(:file struct :depends-on (object setters))))
-
-(defsystem cffi-objects.tests
- :author "Roman Klochkov <monk at slavsoft.surgut.ru>"
- :version "0.9"
- :license "BSD"
- :depends-on (cffi-objects hu.dwim.stefil)
- :components
- ((:file tests)))
\ No newline at end of file
Added: cffi-objects.tests.asd
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cffi-objects.tests.asd Sat Dec 22 22:59:28 2012 (r14)
@@ -0,0 +1,7 @@
+(defsystem cffi-objects.tests
+ :author "Roman Klochkov <monk at slavsoft.surgut.ru>"
+ :version "0.9"
+ :license "BSD"
+ :depends-on (cffi-objects hu.dwim.stefil)
+ :components
+ ((:file tests)))
\ No newline at end of file
Added: tests.lisp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ tests.lisp Sat Dec 22 22:59:28 2012 (r14)
@@ -0,0 +1,27 @@
+(defpackage #:cffi-objects.tests
+ (:use #:cl #:cffi-objects #:hu.dwim.stefil))
+
+(in-package #:cffi-objects.tests)
+
+(defsuite* (test-suite
+ :in root-suite
+ :documentation "Testing CFFI-objects"))
+
+(defcstruct* test
+ (x :int))
+
+(deftest test.carray ()
+ (is (= (let ((obj (make-instance 'test)))
+ (setf (x obj) 1)
+ (x obj)) 1))
+ (let ((obj (make-array 10)))
+ (dotimes (i 10)
+ (setf (aref obj i)
+ (let ((struct (make-instance 'test)))
+ (setf (x struct) i)
+ struct)))
+ (is (every (lambda (a b) (= (x a) (x b)))
+ obj
+ (convert-from-foreign
+ (convert-to-foreign obj '(carray (struct test)))
+ '(carray (struct test)))))))
\ No newline at end of file
More information about the cffi-objects-cvs
mailing list