static void test_saturating_int(void) { TEST(saturating_add(0, 0) == 0); TEST(saturating_add(INT_MAX, INT_MAX) == INT_MAX); TEST(saturating_add(INT_MIN, INT_MIN) == INT_MIN); TEST(saturating_add(INT_MAX, INT_MIN) == (INT_MAX + INT_MIN)); TEST(saturating_add(-1, 1) == 0); TEST(saturating_add(-1, 0) == -1); TEST(saturating_add(0, -1) == -1); TEST(saturating_add(-1, -1) == -2); }
int main(){ printf("saturating_add(0x7fffffff,0x7fffffff)=%x\n",saturating_add(0x7fffff00,0x7fffff00)); printf("saturating_add(0x80000000,0x80000000)=%x\n",saturating_add(0x800000ff,0x800000ff)); printf("saturating_add(0x12005600,0x00340078)=%x\n",saturating_add(0x12005600,0x00340078)); return 0; }