[PATCH 1/2] Add sreal to selftests
Jeff Law
law@redhat.com
Tue Jul 19 16:14:00 GMT 2016
On 07/11/2016 08:34 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2016-07-12 Martin Liska <mliska@suse.cz>
>
> * selftest-run-tests.c (selftest::run_tests): New function.
> * selftest.h (sreal_c_tests): Declare.
> * sreal.c (sreal_verify_basics): New function.
> (verify_aritmetics): Likewise.
> (sreal_verify_arithmetics): Likewise.
> (verify_shifting): Likewise.
> (sreal_verify_shifting): Likewise.
> (void sreal_c_tests): Likewise.
>
> gcc/testsuite/ChangeLog:
>
> 2016-07-12 Martin Liska <mliska@suse.cz>
>
> * gcc.dg/plugin/plugin.exp: Remove sreal test.
> * gcc.dg/plugin/sreal-test-1.c: Remove.
> * gcc.dg/plugin/sreal_plugin.c: Remove.
> ---
> gcc/selftest-run-tests.c | 1 +
> gcc/selftest.h | 1 +
> gcc/sreal.c | 112 +++++++++++++++++++
> gcc/testsuite/gcc.dg/plugin/plugin.exp | 1 -
> gcc/testsuite/gcc.dg/plugin/sreal-test-1.c | 8 --
> gcc/testsuite/gcc.dg/plugin/sreal_plugin.c | 170 -----------------------------
> 6 files changed, 114 insertions(+), 179 deletions(-)
> delete mode 100644 gcc/testsuite/gcc.dg/plugin/sreal-test-1.c
> delete mode 100644 gcc/testsuite/gcc.dg/plugin/sreal_plugin.c
>
> diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c
> index bddf0b2..bb004cc 100644
> --- a/gcc/selftest-run-tests.c
> +++ b/gcc/selftest-run-tests.c
> @@ -49,6 +49,7 @@ selftest::run_tests ()
> pretty_print_c_tests ();
> wide_int_cc_tests ();
> ggc_tests_c_tests ();
> + sreal_c_tests ();
>
> /* Mid-level data structures. */
> input_c_tests ();
> diff --git a/gcc/selftest.h b/gcc/selftest.h
> index 967e76b..c805386 100644
> --- a/gcc/selftest.h
> +++ b/gcc/selftest.h
> @@ -86,6 +86,7 @@ extern void pretty_print_c_tests ();
> extern void rtl_tests_c_tests ();
> extern void spellcheck_c_tests ();
> extern void spellcheck_tree_c_tests ();
> +extern void sreal_c_tests ();
> extern void tree_c_tests ();
> extern void tree_cfg_c_tests ();
> extern void vec_c_tests ();
> diff --git a/gcc/sreal.c b/gcc/sreal.c
> index a7c9c12..9c43b4e 100644
> --- a/gcc/sreal.c
> +++ b/gcc/sreal.c
> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see
> #include <math.h>
> #include "coretypes.h"
> #include "sreal.h"
> +#include "selftest.h"
>
> /* Print the content of struct sreal. */
>
> @@ -233,3 +234,114 @@ sreal::operator/ (const sreal &other) const
> r.normalize ();
> return r;
> }
> +
> +#if CHECKING_P
> +
> +namespace selftest {
> +
> +/* Selftests for sreals. */
> +
> +/* Verify basic sreal operations. */
> +
> +static void
> +sreal_verify_basics (void)
> +{
> + sreal minimum = INT_MIN;
> + sreal maximum = INT_MAX;
> +
> + sreal seven = 7;
> + sreal minus_two = -2;
> + sreal minus_nine = -9;
> +
> + ASSERT_EQ (INT_MIN, minimum.to_int ());
> + ASSERT_EQ (INT_MAX, maximum.to_int ());
> +
> + ASSERT_FALSE (minus_two < minus_two);
> + ASSERT_FALSE (seven < seven);
> + ASSERT_TRUE (seven > minus_two);
> + ASSERT_TRUE (minus_two < seven);
> + ASSERT_TRUE (minus_two != seven);
> + ASSERT_EQ (minus_two, -2);
> + ASSERT_EQ (seven, 7);
> + ASSERT_EQ ((seven << 10) >> 10, 7);
> + ASSERT_EQ (seven + minus_nine, -2);
> +}
> +
> +/* Helper function that performs basic arithmetics and comparison
> + of given arguments A and B. */
> +
> +static void
> +verify_aritmetics (int64_t a, int64_t b)
arithmetics rather than aritmetics?
OK with that change.
jeff
More information about the Gcc-patches
mailing list