forked from alex-eg/sex
add static-assert to sex
Expands to C11 _Static_assert keyword
This commit is contained in:
@@ -259,4 +259,15 @@ compiles."
|
||||
"/* A 2D point. */"))
|
||||
(test-assert "and an enum docstring too"
|
||||
(emits? "(enum color \"RGB.\" (red green blue))"
|
||||
"/* RGB. */"))))
|
||||
"/* RGB. */")))
|
||||
|
||||
;; `static-assert' is the keyword rather than the <assert.h> macro, so
|
||||
;; a static assertion costs no include. Mapped in `atom-to-fmt-c'
|
||||
;; because `unkebabify' alone would spell it `static_assert'.
|
||||
(test-group "static-assert"
|
||||
(test-assert "emits the C11 keyword"
|
||||
(emits? (in-fn "(static-assert (== (sizeof int) 4) \"int is four bytes\")")
|
||||
"_Static_assert(sizeof(int) == 4, \"int is four bytes\")"))
|
||||
(test-assert "and not the header macro"
|
||||
(not (emits? (in-fn "(static-assert (== (sizeof int) 4) \"x\")")
|
||||
"static_assert(")))))
|
||||
|
||||
Reference in New Issue
Block a user