diff --git a/test/crypto_kem/functest.c b/test/crypto_kem/functest.c index a2721e86..74cef3f6 100644 --- a/test/crypto_kem/functest.c +++ b/test/crypto_kem/functest.c @@ -50,8 +50,15 @@ static int check_canary(const uint8_t *d) { return -1; \ } -#define DEFER(x) x -#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H)) +// https://stackoverflow.com/a/55243651/248065 +#define MY_TRUTHY_VALUE_X 1 +#define CAT(x,y) CAT_(x,y) +#define CAT_(x,y) x##y +#define HAS_NAMESPACE(x) CAT(CAT(MY_TRUTHY_VALUE_,CAT(PQCLEAN_NAMESPACE,CAT(_,x))),X) + +#if !HAS_NAMESPACE(API_H) +#error "namespace not properly defined for header guard" +#endif static int test_keys(void) { /* @@ -200,9 +207,8 @@ static int test_invalid_ciphertext(void) { } int main(void) { - // these two will trigger compiler errors + // Check if CRYPTO_ALGNAME is printable puts(CRYPTO_ALGNAME); - NAMESPACE_CHECK; int result = 0; result += test_keys(); diff --git a/test/crypto_sign/functest.c b/test/crypto_sign/functest.c index 2eaf8f5c..57e9e0da 100644 --- a/test/crypto_sign/functest.c +++ b/test/crypto_sign/functest.c @@ -51,8 +51,16 @@ static int check_canary(const uint8_t *d) { return -1; \ } -#define DEFER(x) x -#define NAMESPACE_CHECK DEFER(NAMESPACE(API_H)) +// https://stackoverflow.com/a/55243651/248065 +#define MY_TRUTHY_VALUE_X 1 +#define CAT(x,y) CAT_(x,y) +#define CAT_(x,y) x##y +#define HAS_NAMESPACE(x) CAT(CAT(MY_TRUTHY_VALUE_,CAT(PQCLEAN_NAMESPACE,CAT(_,x))),X) + +#if !HAS_NAMESPACE(API_H) +#error "namespace not properly defined for header guard" +#endif + static int test_sign(void) { /* @@ -163,10 +171,8 @@ static int test_wrong_pk(void) { } int main(void) { - // these two will generate compile errors + // check if CRYPTO_ALGNAME is printable puts(CRYPTO_ALGNAME); - NAMESPACE_CHECK; - int result = 0; result += test_sign(); result += test_wrong_pk();