Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 0ab2663

Browse files
committed
Revert tests for string and vec
1 parent 708a298 commit 0ab2663

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

tests/string.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
use alloc_wg::{
2-
alloc::Global,
3-
borrow::Cow,
4-
collections::CollectionAllocErr::*,
5-
string::String,
6-
vec,
7-
vec::Vec,
8-
};
1+
use alloc_wg::{borrow::Cow, collections::CollectionAllocErr::*, string::String, vec, vec::Vec};
92
use core::{isize, mem::size_of, usize};
103

114
pub trait IntoCow<'a, B: ?Sized>
@@ -583,7 +576,7 @@ fn test_try_reserve() {
583576

584577
{
585578
// Note: basic stuff is checked by test_reserve
586-
let mut empty_string = String::new_in(Global);
579+
let mut empty_string = String::new();
587580

588581
// Check isize::MAX doesn't count as an overflow
589582
if let Err(CapacityOverflow) = empty_string.try_reserve(MAX_CAP) {
@@ -623,10 +616,7 @@ fn test_try_reserve() {
623616

624617
{
625618
// Same basic idea, but with non-zero len
626-
let mut ten_bytes = String::new_in(Global);
627-
ten_bytes
628-
.try_push_str("0123456789")
629-
.expect("Could not create string with 10 bytes");
619+
let mut ten_bytes = String::from("0123456789");
630620

631621
if let Err(CapacityOverflow) = ten_bytes.try_reserve(MAX_CAP - 10) {
632622
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -665,7 +655,7 @@ fn test_try_reserve_exact() {
665655
let guards_against_isize = size_of::<usize>() < 8;
666656

667657
{
668-
let mut empty_string = String::new_in(Global);
658+
let mut empty_string = String::new();
669659

670660
if let Err(CapacityOverflow) = empty_string.try_reserve_exact(MAX_CAP) {
671661
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -698,10 +688,7 @@ fn test_try_reserve_exact() {
698688
}
699689

700690
{
701-
let mut ten_bytes = String::new_in(Global);
702-
ten_bytes
703-
.try_push_str("0123456789")
704-
.expect("Could not create string with 10 bytes");
691+
let mut ten_bytes = String::from("0123456789");
705692

706693
if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_CAP - 10) {
707694
panic!("isize::MAX shouldn't trigger an overflow!");

tests/vec.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use alloc_wg::{
2-
alloc::Global,
32
boxed::Box,
43
collections::CollectionAllocErr::*,
54
vec,
@@ -1127,7 +1126,7 @@ fn test_try_reserve() {
11271126

11281127
{
11291128
// Note: basic stuff is checked by test_reserve
1130-
let mut empty_bytes: Vec<u8, _> = Vec::new_in(Global);
1129+
let mut empty_bytes: Vec<u8, _> = Vec::new();
11311130

11321131
// Check isize::MAX doesn't count as an overflow
11331132
if let Err(CapacityOverflow) = empty_bytes.try_reserve(MAX_CAP) {
@@ -1165,8 +1164,7 @@ fn test_try_reserve() {
11651164

11661165
{
11671166
// Same basic idea, but with non-zero len
1168-
let mut ten_bytes: Vec<u8, _> = vec![try in Global; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1169-
.expect("Unable to allocate ten bytes");
1167+
let mut ten_bytes: Vec<u8> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
11701168

11711169
if let Err(CapacityOverflow) = ten_bytes.try_reserve(MAX_CAP - 10) {
11721170
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -1191,8 +1189,7 @@ fn test_try_reserve() {
11911189

11921190
{
11931191
// Same basic idea, but with interesting type size
1194-
let mut ten_u32s: Vec<u32, _> = vec![try in Global; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1195-
.expect("Unable to allocate 40 bytes");
1192+
let mut ten_u32s: Vec<u32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
11961193

11971194
if let Err(CapacityOverflow) = ten_u32s.try_reserve(MAX_CAP / 4 - 10) {
11981195
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -1229,7 +1226,7 @@ fn test_try_reserve_exact() {
12291226
let guards_against_isize = size_of::<usize>() < 8;
12301227

12311228
{
1232-
let mut empty_bytes: Vec<u8, _> = Vec::new_in(Global);
1229+
let mut empty_bytes: Vec<u8> = Vec::new();
12331230

12341231
if let Err(CapacityOverflow) = empty_bytes.try_reserve_exact(MAX_CAP) {
12351232
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -1260,8 +1257,7 @@ fn test_try_reserve_exact() {
12601257
}
12611258

12621259
{
1263-
let mut ten_bytes: Vec<u8, _> = vec![try in Global; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1264-
.expect("Unable to allocate ten bytes");
1260+
let mut ten_bytes: Vec<u8> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
12651261

12661262
if let Err(CapacityOverflow) = ten_bytes.try_reserve_exact(MAX_CAP - 10) {
12671263
panic!("isize::MAX shouldn't trigger an overflow!");
@@ -1284,8 +1280,7 @@ fn test_try_reserve_exact() {
12841280
}
12851281

12861282
{
1287-
let mut ten_u32s: Vec<u32, _> = vec![try in Global; 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1288-
.expect("Unable to allocate 40 bytes");
1283+
let mut ten_u32s: Vec<u32> = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
12891284

12901285
if let Err(CapacityOverflow) = ten_u32s.try_reserve_exact(MAX_CAP / 4 - 10) {
12911286
panic!("isize::MAX shouldn't trigger an overflow!");

0 commit comments

Comments
 (0)