Skip to content

Commit bcc41a9

Browse files
committed
Autogenerate the add/sub tests
1 parent ed89a17 commit bcc41a9

11 files changed

+548
-106
lines changed

build.rs

+484
Large diffs are not rendered by default.

src/int/add.rs

-53
Original file line numberDiff line numberDiff line change
@@ -65,56 +65,3 @@ pub fn rust_u128_addo(a: u128, b: u128) -> (u128, bool) {
6565
let r = a.addo(b, &mut oflow);
6666
(r, oflow != 0)
6767
}
68-
69-
#[test]
70-
fn test_add() {
71-
assert_eq!(rust_u128_add(1, 2), 3);
72-
assert_eq!(rust_u128_add(!0, 3), 2);
73-
assert_eq!(rust_u128_add(1 << 63, 1 << 63), 1 << 64);
74-
assert_eq!(rust_u128_add(
75-
0x54009B79B43145A0_B781BF1FD491296E_u128,
76-
0x6019CEECA5354210_839AB51D155FF7F3_u128),
77-
0xB41A6A66596687B1_3B1C743CE9F12161_u128);
78-
assert_eq!(rust_u128_add(
79-
0x3AE89C3AACEE47CD_8721275248B38DDB_u128,
80-
0xEFDD73C41D344744_B0842900C3352A63_u128),
81-
0x2AC60FFECA228F12_37A550530BE8B83E_u128);
82-
83-
assert_eq!(rust_i128_add(1, 2), 3);
84-
assert_eq!(rust_i128_add(-1, 3), 2);
85-
}
86-
87-
#[test]
88-
fn test_addo() {
89-
assert_eq!(rust_u128_addo(1, 2), (3, false));
90-
assert_eq!(rust_u128_addo(!0, 3), (2, true));
91-
assert_eq!(rust_u128_addo(1 << 63, 1 << 63), (1 << 64, false));
92-
assert_eq!(rust_u128_addo(
93-
0x54009B79B43145A0_B781BF1FD491296E_u128,
94-
0x6019CEECA5354210_839AB51D155FF7F3_u128),
95-
(0xB41A6A66596687B1_3B1C743CE9F12161_u128, false));
96-
assert_eq!(rust_u128_addo(
97-
0x3AE89C3AACEE47CD_8721275248B38DDB_u128,
98-
0xEFDD73C41D344744_B0842900C3352A63_u128),
99-
(0x2AC60FFECA228F12_37A550530BE8B83E_u128, true));
100-
101-
assert_eq!(rust_i128_addo(1, 2), (3, false));
102-
assert_eq!(rust_i128_addo(-1, 3), (2, false));
103-
assert_eq!(rust_i128_addo(1 << 63, 1 << 63), (1 << 64, false));
104-
assert_eq!(rust_i128_addo(
105-
0x54009B79B43145A0_B781BF1FD491296E_i128,
106-
0x6019CEECA5354210_839AB51D155FF7F3_i128),
107-
(-0x4BE59599A699784E_C4E38BC3160EDE9F_i128, true));
108-
assert_eq!(rust_i128_addo(
109-
0x3AE89C3AACEE47CD_8721275248B38DDB_i128,
110-
-0x10228C3BE2CBB8BB_4F7BD6FF3CCAD59D_i128),
111-
(0x2AC60FFECA228F12_37A550530BE8B83E_i128, false));
112-
assert_eq!(rust_i128_addo(
113-
-0x54009B79B43145A0_B781BF1FD491296E_i128,
114-
-0x6019CEECA5354210_839AB51D155FF7F3_i128),
115-
(0x4BE59599A699784E_C4E38BC3160EDE9F_i128, true));
116-
assert_eq!(rust_i128_addo(
117-
-0x3AE89C3AACEE47CD_8721275248B38DDB_i128,
118-
0x10228C3BE2CBB8BB_4F7BD6FF3CCAD59D_i128),
119-
(-0x2AC60FFECA228F12_37A550530BE8B83E_i128, false));
120-
}

src/int/sub.rs

-53
Original file line numberDiff line numberDiff line change
@@ -50,56 +50,3 @@ pub fn rust_u128_subo(a: u128, b: u128) -> (u128, bool) {
5050
let r = a.subo(b, &mut oflow);
5151
(r, oflow != 0)
5252
}
53-
54-
#[test]
55-
fn test_sub() {
56-
assert_eq!(rust_u128_sub(3, 2), 1);
57-
assert_eq!(rust_u128_sub(2, 3), !0);
58-
assert_eq!(rust_u128_sub(1 << 64, 1 << 63), 1 << 63);
59-
assert_eq!(rust_u128_sub(
60-
0xB41A6A66596687B1_3B1C743CE9F12161_u128,
61-
0x6019CEECA5354210_839AB51D155FF7F3_u128),
62-
0x54009B79B43145A0_B781BF1FD491296E_u128);
63-
assert_eq!(rust_u128_sub(
64-
0x2AC60FFECA228F12_37A550530BE8B83E_u128,
65-
0xEFDD73C41D344744_B0842900C3352A63_u128),
66-
0x3AE89C3AACEE47CD_8721275248B38DDB_u128);
67-
68-
assert_eq!(rust_i128_sub(3, 2), 1);
69-
assert_eq!(rust_i128_sub(2, 3), -1);
70-
}
71-
72-
#[test]
73-
fn test_subo() {
74-
assert_eq!(rust_u128_subo(3, 2), (1, false));
75-
assert_eq!(rust_u128_subo(2, 3), (!0, true));
76-
assert_eq!(rust_u128_subo(1 << 64, 1 << 63), (1 << 63, false));
77-
assert_eq!(rust_u128_subo(
78-
0xB41A6A66596687B1_3B1C743CE9F12161_u128,
79-
0x6019CEECA5354210_839AB51D155FF7F3_u128),
80-
(0x54009B79B43145A0_B781BF1FD491296E_u128, false));
81-
assert_eq!(rust_u128_subo(
82-
0x2AC60FFECA228F12_37A550530BE8B83E_u128,
83-
0xEFDD73C41D344744_B0842900C3352A63_u128),
84-
(0x3AE89C3AACEE47CD_8721275248B38DDB_u128, true));
85-
86-
assert_eq!(rust_i128_subo(3, 2), (1, false));
87-
assert_eq!(rust_i128_subo(2, 3), (-1, false));
88-
assert_eq!(rust_i128_subo(1 << 64, 1 << 63), (1 << 63, false));
89-
assert_eq!(rust_i128_subo(
90-
-0x4BE59599A699784E_C4E38BC3160EDE9F_i128,
91-
0x6019CEECA5354210_839AB51D155FF7F3_i128),
92-
(0x54009B79B43145A0_B781BF1FD491296E_i128, true));
93-
assert_eq!(rust_i128_subo(
94-
0x2AC60FFECA228F12_37A550530BE8B83E_i128,
95-
-0x10228C3BE2CBB8BB_4F7BD6FF3CCAD59D_i128),
96-
(0x3AE89C3AACEE47CD_8721275248B38DDB_i128, false));
97-
assert_eq!(rust_i128_subo(
98-
0x4BE59599A699784E_C4E38BC3160EDE9F_i128,
99-
-0x6019CEECA5354210_839AB51D155FF7F3_i128),
100-
(-0x54009B79B43145A0_B781BF1FD491296E_i128, true));
101-
assert_eq!(rust_i128_subo(
102-
-0x2AC60FFECA228F12_37A550530BE8B83E_i128,
103-
0x10228C3BE2CBB8BB_4F7BD6FF3CCAD59D_i128),
104-
(-0x3AE89C3AACEE47CD_8721275248B38DDB_i128, false));
105-
}

tests/i128_add.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/i128_add.rs"));

tests/i128_addo.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/i128_addo.rs"));

tests/i128_sub.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/i128_sub.rs"));

tests/i128_subo.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/i128_subo.rs"));

tests/u128_add.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/u128_add.rs"));

tests/u128_addo.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/u128_addo.rs"));

tests/u128_sub.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/u128_sub.rs"));

tests/u128_subo.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(compiler_builtins_lib)]
2+
#![feature(i128_type)]
3+
#![cfg_attr(all(target_arch = "arm",
4+
not(any(target_env = "gnu", target_env = "musl")),
5+
target_os = "linux",
6+
test), no_std)]
7+
8+
include!(concat!(env!("OUT_DIR"), "/u128_subo.rs"));

0 commit comments

Comments
 (0)