Skip to content

Commit fbcf49e

Browse files
author
yew005
committed
Add {isize, usize}::unchecked_add harnesses
1 parent d99844d commit fbcf49e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

library/core/src/num/mod.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,11 +1593,10 @@ mod verify {
15931593
// `unchecked_add` proofs
15941594
//
15951595
// Target types:
1596-
// i{8,16,32,64,128} and u{8,16,32,64,128} -- 10 types in total
1596+
// i{8,16,32,64,128, size} and u{8,16,32,64,128, size} -- 12 types in total
15971597
//
15981598
// Target contracts:
15991599
// #[requires(!self.overflowing_add(rhs).1)]
1600-
// #[ensures(|ret| *ret >= $SelfT::MIN && *ret <= $SelfT::MAX)]
16011600
//
16021601
// Target function:
16031602
// pub const unsafe fn unchecked_add(self, rhs: Self) -> Self
@@ -1651,6 +1650,16 @@ mod verify {
16511650
}
16521651
}
16531652

1653+
#[kani::proof_for_contract(isize::unchecked_add)]
1654+
pub fn check_unchecked_add_isize() {
1655+
let num1: isize = kani::any::<isize>();
1656+
let num2: isize = kani::any::<isize>();
1657+
1658+
unsafe {
1659+
num1.unchecked_add(num2);
1660+
}
1661+
}
1662+
16541663
#[kani::proof_for_contract(u8::unchecked_add)]
16551664
pub fn check_unchecked_add_u8() {
16561665
let num1: u8 = kani::any::<u8>();
@@ -1700,4 +1709,14 @@ mod verify {
17001709
num1.unchecked_add(num2);
17011710
}
17021711
}
1712+
1713+
#[kani::proof_for_contract(usize::unchecked_add)]
1714+
pub fn check_unchecked_add_usize() {
1715+
let num1: usize = kani::any::<usize>();
1716+
let num2: usize = kani::any::<usize>();
1717+
1718+
unsafe {
1719+
num1.unchecked_add(num2);
1720+
}
1721+
}
17031722
}

0 commit comments

Comments
 (0)