summaryrefslogtreecommitdiff
path: root/Lisp/tests.lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-02-12 15:46:50 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-02-12 15:46:50 +0100
commitfc097fadb088e6c563f339d2b2090cee45295194 (patch)
tree03735dfd9e4ae6aee0563b4eed0397d3944b672b /Lisp/tests.lisp
parent310d9a8cfe1a7cc4240fe124fffe87bb4ff32cfb (diff)
Add unit tests for PRINT-TYPESPEC.
darcs-hash:d51f1a48ac8d7f957292cec440abff07b394f1f0
Diffstat (limited to 'Lisp/tests.lisp')
-rw-r--r--Lisp/tests.lisp85
1 files changed, 84 insertions, 1 deletions
diff --git a/Lisp/tests.lisp b/Lisp/tests.lisp
index b031200..7a6d6d8 100644
--- a/Lisp/tests.lisp
+++ b/Lisp/tests.lisp
@@ -23,7 +23,7 @@
#:struct #:union #:pointer #:oneway #:out #:in
#:inout #:const #:parse-typespec #:objective-c-class
#:bit-field #:opaque #:bycopy #:byref
- #:primitive-invoke))
+ #:primitive-invoke #:print-typespec-to-string))
(in-package #:mulk.objective-cl.tests)
@@ -236,6 +236,89 @@
(struct (opaque) "OpaqueStruct")))))))
+(deftestsuite printing-typespecs (objective-cl)
+ ()
+ (:equality-test #'equal)
+ (:tests
+ ((ensure-same (print-typespec-to-string '(id ()))
+ "@"))
+ ((ensure-same (print-typespec-to-string '(selector ()))
+ ":"))
+ ((ensure-same (print-typespec-to-string '(struct () "_NSRange"
+ (:unsigned-int ())
+ (:unsigned-int ())))
+ "{_NSRange=II}"))
+ ((ensure-same (print-typespec-to-string '(pointer (oneway out inout in const)
+ (array (oneway)
+ 10
+ (complex (const) (:double nil)))))
+ ;; Actually, the order of the qualifiers doesn't
+ ;; matter, which means that this test is dumber than
+ ;; it ought to be.
+ "VoNnr^V[10rjd]"))
+ ((ensure-same (print-typespec-to-string '(:int (bycopy byref)))
+ ;; Here, too, the order of the qualifiers is irrelevant.
+ "ORi"))
+ ((ensure-same (print-typespec-to-string '(union () "?"))
+ "(?=)"))
+ ((ensure-same (print-typespec-to-string
+ (if (eq objcl::+runtime-type+ :gnu)
+ '(struct () "?"
+ (bit-field (const) 123 456
+ (complex (const) (:float ())))
+ (:int ())
+ (:int ())
+ (:int ()))
+ '(struct () "?"
+ (bit-field (const) nil 123 nil)
+ (complex (const) (:float ()))
+ (:unrecognised ((:type-specifier #\4)))
+ (:unrecognised ((:type-specifier #\5)))
+ (:unrecognised ((:type-specifier #\6)))
+ (:int ())
+ (:int ())
+ (:int ()))))
+ "{?=rb123rjf456iii}"))
+ ((ensure-same (print-typespec-to-string '(pointer ()
+ (array () 100
+ (struct () "?" (:int ()) (:int ())))))
+ "^[100{?=ii}]"))
+ ((ensure-same (print-typespec-to-string '(struct () "?"
+ (:boolean ())
+ (:int ())
+ (:unsigned-int ())
+ (:long ())
+ (:unsigned-long ())
+ (:long-long ())
+ (:unsigned-long-long ())
+ (:float ())
+ (:double ())
+ (id ()) (objective-c-class ()) (selector ())
+ (:string ())
+ (:unknown ())))
+ "{?=BiIlLqQfd@#:*?}"))
+ ((ensure-same (print-typespec-to-string '(struct () "?"
+ (:char ())
+ (:unsigned-char ())))
+ "{?=cC}"))
+ ((ensure-same (print-typespec-to-string '(struct () "?"
+ (:short ())
+ (:unsigned-short ())))
+ "{?=sS}"))
+ ((ensure-same (print-typespec-to-string
+ '(struct () "Mulk"
+ (:string ())
+ (struct () "Untermulk"
+ (struct () "Unteruntermulk"))
+ (:int ())))
+ "{Mulk=*{Untermulk={Unteruntermulk=}}i}"))
+ ((ensure-same (print-typespec-to-string
+ '(pointer ()
+ (pointer ()
+ (struct (opaque) "OpaqueStruct"))))
+ "^^{OpaqueStruct}"))))
+
+
(deftestsuite data-coercion (objective-cl)
()
(:equality-test #'objc-equal)