Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / libc / test / include / stdckdint_test.cpp
blob1180a6de9efe2e90ff209e4c4ca00c053c469705
1 //===-- Unittests for stdckdint -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "test/UnitTest/Test.h"
11 #include "include/llvm-libc-macros/stdckdint-macros.h"
13 TEST(LlvmLibcStdCkdIntTest, Add) {
14 int result;
15 ASSERT_FALSE(ckd_add(&result, 1, 2));
16 ASSERT_EQ(result, 3);
17 ASSERT_TRUE(ckd_add(&result, INT_MAX, 1));
20 TEST(LlvmLibcStdCkdIntTest, Sub) {
21 int result;
22 ASSERT_FALSE(ckd_sub(&result, 3, 2));
23 ASSERT_EQ(result, 1);
24 ASSERT_TRUE(ckd_sub(&result, INT_MIN, 1));
27 TEST(LlvmLibcStdCkdIntTest, Mul) {
28 int result;
29 ASSERT_FALSE(ckd_mul(&result, 2, 3));
30 ASSERT_EQ(result, 6);
31 ASSERT_TRUE(ckd_mul(&result, INT_MAX, 2));