feat: add as type casting
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
[code]
|
||||
fn cast_i32_to_f32(x: i32) -> f32 {
|
||||
return x as f32;
|
||||
}
|
||||
|
||||
fn cast_u64_to_f64(x: u64) -> f64 {
|
||||
return x as f64;
|
||||
}
|
||||
|
||||
[harness]
|
||||
#include <stdint.h>
|
||||
|
||||
extern float cast_i32_to_f32(int32_t x);
|
||||
extern double cast_u64_to_f64(uint64_t x);
|
||||
|
||||
int main() {
|
||||
if (cast_i32_to_f32(42) != 42.0f) return 1;
|
||||
if (cast_i32_to_f32(-10) != -10.0f) return 2;
|
||||
if (cast_u64_to_f64(1337) != 1337.0) return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
[expected_return_code]
|
||||
0
|
||||
Reference in New Issue
Block a user