From fc097fadb088e6c563f339d2b2090cee45295194 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Tue, 12 Feb 2008 15:46:50 +0100 Subject: Add unit tests for PRINT-TYPESPEC. darcs-hash:d51f1a48ac8d7f957292cec440abff07b394f1f0 --- Lisp/tests.lisp | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3