return streq(str + strlen(str) - strlen(postfix), postfix);
}
+
+/**
+ * stringify - Turn expression into a string literal
+ * @expr: any C expression
+ *
+ * Example:
+ * #define PRINT_COND_IF_FALSE(cond) \
+ * ((cond) || printf("%s is false!", stringify(cond)))
+ */
+#define stringify(expr) stringify_1(expr)
+/* Double-indirection required to stringify expansions */
+#define stringify_1(expr) #expr
#endif /* CCAN_STR_H */
}
}
- plan_tests(n * n * 5);
+ plan_tests(n * n * 5 + 3);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
unsigned int k, identical = 0;
}
}
+ ok1(streq(stringify(NUM_SUBSTRINGS),
+ "((sizeof(substrings) / sizeof(substrings[0])) - 1)"));
+ ok1(streq(stringify(ARRAY_SIZE(substrings)),
+ "(sizeof(substrings) / sizeof(substrings[0]))"));
+ ok1(streq(stringify(i == 0), "i == 0"));
+
return exit_status();
}