23 lines
444 B
Plaintext
23 lines
444 B
Plaintext
[code]
|
|
fn truncate_i32_to_i8(x: i32) -> i8 {
|
|
return x as i8;
|
|
}
|
|
|
|
fn extend_u8_to_i32(x: u8) -> i32 {
|
|
return x as i32;
|
|
}
|
|
|
|
[harness]
|
|
#include <stdint.h>
|
|
|
|
extern int8_t truncate_i32_to_i8(int32_t x);
|
|
extern int32_t extend_u8_to_i32(uint8_t x);
|
|
|
|
int main() {
|
|
if (truncate_i32_to_i8(257) != 1) return 1; // 257 = 0x0101, truncated to 8 bits is 0x01
|
|
if (extend_u8_to_i32(255) != 255) return 2;
|
|
return 0;
|
|
}
|
|
|
|
[expected_return_code]
|
|
0 |