llvm-project
32 строки · 945.0 Байт
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//===----------------------------------------------------------------------===//
8
9#include "test/UnitTest/Test.h"
10
11#include "include/llvm-libc-macros/stdckdint-macros.h"
12
13TEST(LlvmLibcStdCkdIntTest, Add) {
14int result;
15ASSERT_FALSE(ckd_add(&result, 1, 2));
16ASSERT_EQ(result, 3);
17ASSERT_TRUE(ckd_add(&result, INT_MAX, 1));
18}
19
20TEST(LlvmLibcStdCkdIntTest, Sub) {
21int result;
22ASSERT_FALSE(ckd_sub(&result, 3, 2));
23ASSERT_EQ(result, 1);
24ASSERT_TRUE(ckd_sub(&result, INT_MIN, 1));
25}
26
27TEST(LlvmLibcStdCkdIntTest, Mul) {
28int result;
29ASSERT_FALSE(ckd_mul(&result, 2, 3));
30ASSERT_EQ(result, 6);
31ASSERT_TRUE(ckd_mul(&result, INT_MAX, 2));
32}
33