Add a C++ test for common macros

Make sure that there is no problem with using these macros
in C++ context, since typeof is defined differently there.
This commit is contained in:
Matthias Clasen
2025-03-22 12:50:52 -04:00
parent ecfb143bbf
commit 1d9c85185e

View File

@@ -580,6 +580,15 @@ test_clear_com (void)
}
#endif
static void
test_common_macros (void)
{
g_assert_true (MAX (1, 2) == 2);
g_assert_true (MIN (1.5, 2) == 1.5);
g_assert_true (CLAMP (1, 2, 3) == 2);
g_assert_true (ABS (-3.5) == 3.5);
}
int
main (int argc, char *argv[])
{
@@ -613,6 +622,7 @@ main (int argc, char *argv[])
g_test_add_func ("/C++/str-has-suffix/macro", test_str_has_suffix_macro);
g_test_add_func ("/C++/string-append", test_string_append);
g_test_add_func ("/C++/string-free", test_string_free);
g_test_add_func ("/C++/common-macros", test_common_macros);
#if G_CXX_STD_CHECK_VERSION(14)
g_test_add_func ("/C++/constexpr-var-init", test_constexpr_var_init);