1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2011 Tomas Gavenciak <gavento@ucw.cz> *
21 *****************************************************************************/
25 #include <GP_Common.h>
28 * Demo ("testing" ;-) tests for GP_Common.h
35 fail_unless(GP_MIN(-1.5, 2) == -1.5);
36 fail_unless(GP_MAX(4294967295ULL, 1ULL) == 4294967295ULL);
38 fail_unless(GP_MAX(x
++, ++y
) == 1);
39 fail_unless(x
== 1 && y
== 1);
45 fail_unless(GP_GET_BITS(15, 7, 0x12345678ULL
) == 0x68);
46 fail_unless(GP_GET_BITS(0, 0, 0x12345678ULL
) == 0);
47 fail_unless(GP_GET_BITS(16, 16, 0x1234) == 0);
48 fail_unless(GP_GET_BITS(1, 32, 0x12345678ULL
) == 0x091A2B3CULL
);
55 uint16_t *y
= (uint16_t*) &x
;
56 GP_CLEAR_BITS(3, 4, x
);
57 fail_unless(x
== 0x89A84);
58 GP_SET_BITS_OR(10, x
, 0x0000000);
59 fail_unless(x
== 0x89A84);
60 GP_SET_BITS(24, 18, x
, 0x42F1);
61 fail_unless(x
== 0xF1089A84);
62 /* Check that only uint16_t is affected */
63 GP_SET_BITS(0, 24, *y
, 0x100F000LL
);
64 fail_unless(x
== 0xF108F000);
68 GP_TEST(abort_check_assert
, "loop_start=0, loop_end=9, expect_exit=1")
70 if (_i
==0) GP_ABORT();
71 if (_i
==1) GP_ABORT("MSG");
72 if (_i
==2) GP_ABORT("FORMAT %d", _i
);
73 if (_i
==3) GP_ASSERT(1==0);
74 if (_i
==4) GP_ASSERT(1==0, "MSG");
75 if (_i
==5) GP_ASSERT(1==0, "FORMAT %d", _i
);
76 if (_i
==6) GP_CHECK(1==0);
77 if (_i
==7) GP_CHECK(1==0, "MSG");
78 if (_i
==8) GP_CHECK(1==0, "FORMAT %d", _i
);
82 GP_TEST(assert_check_nop
)
84 /* Also tests % in conditon */
85 GP_ASSERT(7 % 3 == 1);
86 GP_ASSERT(7 % 3 == 1, "MSG");
88 GP_CHECK(7 % 3 == 1, "MSG");