diff --git a/include/tests/test.h b/include/tests/test.h index 73675e9c..e1786f1a 100644 --- a/include/tests/test.h +++ b/include/tests/test.h @@ -7,10 +7,16 @@ #include +/* + * Compares two strings, and frees lhs before returning. + * NOTE: We store lhs in a temporary string so that "lhs" only gets + * evaluated once in the case that it is a function. + */ #define g_assert_cmpstr_free(lhs, cmp, rhs) \ do { \ - g_assert_cmpstr(lhs, cmp, rhs); \ - g_free(lhs); \ + gchar *__tmp_str = lhs; \ + g_assert_cmpstr(__tmp_str, cmp, rhs); \ + g_free(__tmp_str); \ } while (0) #endif /* OCARINA_TESTS_TEST_H */