Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cca1cf61
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cca1cf61
编写于
2月 12, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #21895 - alfie:libcoretest, r=pnkfelix
上级
c34421e4
bffbcb57
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
112 addition
and
112 deletion
+112
-112
src/libcoretest/any.rs
src/libcoretest/any.rs
+11
-11
src/libcoretest/cell.rs
src/libcoretest/cell.rs
+12
-12
src/libcoretest/char.rs
src/libcoretest/char.rs
+12
-12
src/libcoretest/iter.rs
src/libcoretest/iter.rs
+45
-45
src/libcoretest/mem.rs
src/libcoretest/mem.rs
+19
-19
src/libcoretest/num/uint_macros.rs
src/libcoretest/num/uint_macros.rs
+4
-4
src/libcoretest/ops.rs
src/libcoretest/ops.rs
+7
-7
src/libcoretest/ptr.rs
src/libcoretest/ptr.rs
+1
-1
src/libcoretest/tuple.rs
src/libcoretest/tuple.rs
+1
-1
未找到文件。
src/libcoretest/any.rs
浏览文件 @
cca1cf61
...
...
@@ -18,11 +18,11 @@
#[test]
fn
any_referenced
()
{
let
(
a
,
b
,
c
)
=
(
&
5
u
as
&
Any
,
&
TEST
as
&
Any
,
&
Test
as
&
Any
);
let
(
a
,
b
,
c
)
=
(
&
5
as
&
Any
,
&
TEST
as
&
Any
,
&
Test
as
&
Any
);
assert
!
(
a
.is
::
<
uint
>
());
assert
!
(
!
b
.is
::
<
uint
>
());
assert
!
(
!
c
.is
::
<
uint
>
());
assert
!
(
a
.is
::
<
i32
>
());
assert
!
(
!
b
.is
::
<
i32
>
());
assert
!
(
!
c
.is
::
<
i32
>
());
assert
!
(
!
a
.is
::
<&
'static
str
>
());
assert
!
(
b
.is
::
<&
'static
str
>
());
...
...
@@ -35,7 +35,7 @@ fn any_referenced() {
#[test]
fn
any_owning
()
{
let
(
a
,
b
,
c
)
=
(
box
5u
as
Box
<
Any
>
,
box
TEST
as
Box
<
Any
>
,
box
Test
as
Box
<
Any
>
);
let
(
a
,
b
,
c
)
=
(
box
5u
s
as
Box
<
Any
>
,
box
TEST
as
Box
<
Any
>
,
box
Test
as
Box
<
Any
>
);
assert
!
(
a
.is
::
<
uint
>
());
assert
!
(
!
b
.is
::
<
uint
>
());
...
...
@@ -52,7 +52,7 @@ fn any_owning() {
#[test]
fn
any_downcast_ref
()
{
let
a
=
&
5u
as
&
Any
;
let
a
=
&
5u
s
as
&
Any
;
match
a
.downcast_ref
::
<
uint
>
()
{
Some
(
&
5
)
=>
{}
...
...
@@ -67,8 +67,8 @@ fn any_downcast_ref() {
#[test]
fn
any_downcast_mut
()
{
let
mut
a
=
5u
;
let
mut
b
=
box
7u
;
let
mut
a
=
5u
s
;
let
mut
b
=
box
7u
s
;
let
a_r
=
&
mut
a
as
&
mut
Any
;
let
tmp
:
&
mut
uint
=
&
mut
*
b
;
...
...
@@ -76,7 +76,7 @@ fn any_downcast_mut() {
match
a_r
.downcast_mut
::
<
uint
>
()
{
Some
(
x
)
=>
{
assert_eq!
(
*
x
,
5
u
);
assert_eq!
(
*
x
,
5
);
*
x
=
612
;
}
x
=>
panic!
(
"Unexpected value {:?}"
,
x
)
...
...
@@ -84,7 +84,7 @@ fn any_downcast_mut() {
match
b_r
.downcast_mut
::
<
uint
>
()
{
Some
(
x
)
=>
{
assert_eq!
(
*
x
,
7
u
);
assert_eq!
(
*
x
,
7
);
*
x
=
413
;
}
x
=>
panic!
(
"Unexpected value {:?}"
,
x
)
...
...
@@ -113,7 +113,7 @@ fn any_downcast_mut() {
#[test]
fn
any_fixed_vec
()
{
let
test
=
[
0u
;
8
];
let
test
=
[
0u
s
;
8
];
let
test
=
&
test
as
&
Any
;
assert
!
(
test
.is
::
<
[
uint
;
8
]
>
());
assert
!
(
!
test
.is
::
<
[
uint
;
10
]
>
());
...
...
src/libcoretest/cell.rs
浏览文件 @
cca1cf61
...
...
@@ -134,21 +134,21 @@ fn clone_ref_updates_flag() {
#[test]
fn
as_unsafe_cell
()
{
let
c1
:
Cell
<
uint
>
=
Cell
::
new
(
0
u
);
c1
.set
(
1
u
);
assert_eq!
(
1
u
,
unsafe
{
*
c1
.as_unsafe_cell
()
.get
()
});
let
c1
:
Cell
<
uint
>
=
Cell
::
new
(
0
);
c1
.set
(
1
);
assert_eq!
(
1
,
unsafe
{
*
c1
.as_unsafe_cell
()
.get
()
});
let
c2
:
Cell
<
uint
>
=
Cell
::
new
(
0
u
);
unsafe
{
*
c2
.as_unsafe_cell
()
.get
()
=
1
u
;
}
assert_eq!
(
1
u
,
c2
.get
());
let
c2
:
Cell
<
uint
>
=
Cell
::
new
(
0
);
unsafe
{
*
c2
.as_unsafe_cell
()
.get
()
=
1
;
}
assert_eq!
(
1
,
c2
.get
());
let
r1
:
RefCell
<
uint
>
=
RefCell
::
new
(
0
u
);
*
r1
.borrow_mut
()
=
1
u
;
assert_eq!
(
1
u
,
unsafe
{
*
r1
.as_unsafe_cell
()
.get
()
});
let
r1
:
RefCell
<
uint
>
=
RefCell
::
new
(
0
);
*
r1
.borrow_mut
()
=
1
;
assert_eq!
(
1
,
unsafe
{
*
r1
.as_unsafe_cell
()
.get
()
});
let
r2
:
RefCell
<
uint
>
=
RefCell
::
new
(
0
u
);
unsafe
{
*
r2
.as_unsafe_cell
()
.get
()
=
1
u
;
}
assert_eq!
(
1
u
,
*
r2
.borrow
());
let
r2
:
RefCell
<
uint
>
=
RefCell
::
new
(
0
);
unsafe
{
*
r2
.as_unsafe_cell
()
.get
()
=
1
;
}
assert_eq!
(
1
,
*
r2
.borrow
());
}
#[test]
...
...
src/libcoretest/char.rs
浏览文件 @
cca1cf61
...
...
@@ -41,18 +41,18 @@ fn test_is_whitespace() {
#[test]
fn
test_to_digit
()
{
assert_eq!
(
'0'
.to_digit
(
10
u
),
Some
(
0u
));
assert_eq!
(
'1'
.to_digit
(
2
u
),
Some
(
1u
));
assert_eq!
(
'2'
.to_digit
(
3
u
),
Some
(
2u
));
assert_eq!
(
'9'
.to_digit
(
10
u
),
Some
(
9u
));
assert_eq!
(
'a'
.to_digit
(
16
u
),
Some
(
10u
));
assert_eq!
(
'A'
.to_digit
(
16
u
),
Some
(
10u
));
assert_eq!
(
'b'
.to_digit
(
16
u
),
Some
(
11u
));
assert_eq!
(
'B'
.to_digit
(
16
u
),
Some
(
11u
));
assert_eq!
(
'z'
.to_digit
(
36
u
),
Some
(
35u
));
assert_eq!
(
'Z'
.to_digit
(
36
u
),
Some
(
35u
));
assert_eq!
(
' '
.to_digit
(
10
u
),
None
);
assert_eq!
(
'$'
.to_digit
(
36
u
),
None
);
assert_eq!
(
'0'
.to_digit
(
10
),
Some
(
0
));
assert_eq!
(
'1'
.to_digit
(
2
),
Some
(
1
));
assert_eq!
(
'2'
.to_digit
(
3
),
Some
(
2
));
assert_eq!
(
'9'
.to_digit
(
10
),
Some
(
9
));
assert_eq!
(
'a'
.to_digit
(
16
),
Some
(
10
));
assert_eq!
(
'A'
.to_digit
(
16
),
Some
(
10
));
assert_eq!
(
'b'
.to_digit
(
16
),
Some
(
11
));
assert_eq!
(
'B'
.to_digit
(
16
),
Some
(
11
));
assert_eq!
(
'z'
.to_digit
(
36
),
Some
(
35
));
assert_eq!
(
'Z'
.to_digit
(
36
),
Some
(
35
));
assert_eq!
(
' '
.to_digit
(
10
),
None
);
assert_eq!
(
'$'
.to_digit
(
36
),
None
);
}
#[test]
...
...
src/libcoretest/iter.rs
浏览文件 @
cca1cf61
...
...
@@ -79,8 +79,8 @@ fn test_counter_from_iter() {
#[test]
fn
test_iterator_chain
()
{
let
xs
=
[
0
u
,
1
,
2
,
3
,
4
,
5
];
let
ys
=
[
30
u
,
40
,
50
,
60
];
let
xs
=
[
0
,
1
,
2
,
3
,
4
,
5
];
let
ys
=
[
30
,
40
,
50
,
60
];
let
expected
=
[
0
,
1
,
2
,
3
,
4
,
5
,
30
,
40
,
50
,
60
];
let
mut
it
=
xs
.iter
()
.chain
(
ys
.iter
());
let
mut
i
=
0
;
...
...
@@ -90,7 +90,7 @@ fn test_iterator_chain() {
}
assert_eq!
(
i
,
expected
.len
());
let
ys
=
count
(
30
u
,
10
)
.take
(
4
);
let
ys
=
count
(
30
,
10
)
.take
(
4
);
let
mut
it
=
xs
.iter
()
.map
(|
&
x
|
x
)
.chain
(
ys
);
let
mut
i
=
0
;
for
x
in
it
{
...
...
@@ -102,14 +102,14 @@ fn test_iterator_chain() {
#[test]
fn
test_filter_map
()
{
let
it
=
count
(
0
u
,
1u
)
.take
(
10
)
let
it
=
count
(
0
,
1
)
.take
(
10
)
.filter_map
(|
x
|
if
x
%
2
==
0
{
Some
(
x
*
x
)
}
else
{
None
});
assert
!
(
it
.collect
::
<
Vec
<
uint
>>
()
==
vec!
[
0
*
0
,
2
*
2
,
4
*
4
,
6
*
6
,
8
*
8
]);
}
#[test]
fn
test_iterator_enumerate
()
{
let
xs
=
[
0
u
,
1
,
2
,
3
,
4
,
5
];
let
xs
=
[
0
,
1
,
2
,
3
,
4
,
5
];
let
mut
it
=
xs
.iter
()
.enumerate
();
for
(
i
,
&
x
)
in
it
{
assert_eq!
(
i
,
x
);
...
...
@@ -118,7 +118,7 @@ fn test_iterator_enumerate() {
#[test]
fn
test_iterator_peekable
()
{
let
xs
=
vec!
[
0
u
,
1
,
2
,
3
,
4
,
5
];
let
xs
=
vec!
[
0
,
1
,
2
,
3
,
4
,
5
];
let
mut
it
=
xs
.iter
()
.map
(|
&
x
|
x
)
.peekable
();
assert_eq!
(
it
.len
(),
6
);
...
...
@@ -150,9 +150,9 @@ fn test_iterator_peekable() {
#[test]
fn
test_iterator_take_while
()
{
let
xs
=
[
0
u
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
ys
=
[
0
u
,
1
,
2
,
3
,
5
,
13
];
let
mut
it
=
xs
.iter
()
.take_while
(|
&
x
|
*
x
<
15
u
);
let
xs
=
[
0
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
ys
=
[
0
,
1
,
2
,
3
,
5
,
13
];
let
mut
it
=
xs
.iter
()
.take_while
(|
&
x
|
*
x
<
15
);
let
mut
i
=
0
;
for
x
in
it
{
assert_eq!
(
*
x
,
ys
[
i
]);
...
...
@@ -163,9 +163,9 @@ fn test_iterator_take_while() {
#[test]
fn
test_iterator_skip_while
()
{
let
xs
=
[
0
u
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
xs
=
[
0
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
ys
=
[
15
,
16
,
17
,
19
];
let
mut
it
=
xs
.iter
()
.skip_while
(|
&
x
|
*
x
<
15
u
);
let
mut
it
=
xs
.iter
()
.skip_while
(|
&
x
|
*
x
<
15
);
let
mut
i
=
0
;
for
x
in
it
{
assert_eq!
(
*
x
,
ys
[
i
]);
...
...
@@ -176,7 +176,7 @@ fn test_iterator_skip_while() {
#[test]
fn
test_iterator_skip
()
{
let
xs
=
[
0
u
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
,
20
,
30
];
let
xs
=
[
0
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
,
20
,
30
];
let
ys
=
[
13
,
15
,
16
,
17
,
19
,
20
,
30
];
let
mut
it
=
xs
.iter
()
.skip
(
5
);
let
mut
i
=
0
;
...
...
@@ -191,8 +191,8 @@ fn test_iterator_skip() {
#[test]
fn
test_iterator_take
()
{
let
xs
=
[
0
u
s
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
ys
=
[
0
u
s
,
1
,
2
,
3
,
5
];
let
xs
=
[
0
,
1
,
2
,
3
,
5
,
13
,
15
,
16
,
17
,
19
];
let
ys
=
[
0
,
1
,
2
,
3
,
5
];
let
mut
it
=
xs
.iter
()
.take
(
5
);
let
mut
i
=
0
;
assert_eq!
(
it
.len
(),
5
);
...
...
@@ -207,8 +207,8 @@ fn test_iterator_take() {
#[test]
fn
test_iterator_take_short
()
{
let
xs
=
[
0
u
s
,
1
,
2
,
3
];
let
ys
=
[
0
u
s
,
1
,
2
,
3
];
let
xs
=
[
0
,
1
,
2
,
3
];
let
ys
=
[
0
,
1
,
2
,
3
];
let
mut
it
=
xs
.iter
()
.take
(
5
);
let
mut
i
=
0
;
assert_eq!
(
it
.len
(),
4
);
...
...
@@ -228,7 +228,7 @@ fn add(old: &mut int, new: &uint) -> Option<f64> {
*
old
+=
*
new
as
int
;
Some
(
*
old
as
f64
)
}
let
xs
=
[
0
u
,
1
,
2
,
3
,
4
];
let
xs
=
[
0
,
1
,
2
,
3
,
4
];
let
ys
=
[
0f64
,
1.0
,
3.0
,
6.0
,
10.0
];
let
mut
it
=
xs
.iter
()
.scan
(
0
,
add
);
...
...
@@ -242,8 +242,8 @@ fn add(old: &mut int, new: &uint) -> Option<f64> {
#[test]
fn
test_iterator_flat_map
()
{
let
xs
=
[
0
u
,
3
,
6
];
let
ys
=
[
0
u
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
];
let
xs
=
[
0
,
3
,
6
];
let
ys
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
];
let
mut
it
=
xs
.iter
()
.flat_map
(|
&
x
|
count
(
x
,
1
)
.take
(
3
));
let
mut
i
=
0
;
for
x
in
it
{
...
...
@@ -255,8 +255,8 @@ fn test_iterator_flat_map() {
#[test]
fn
test_inspect
()
{
let
xs
=
[
1
u
,
2
,
3
,
4
];
let
mut
n
=
0
u
;
let
xs
=
[
1
,
2
,
3
,
4
];
let
mut
n
=
0
;
let
ys
=
xs
.iter
()
.map
(|
&
x
|
x
)
...
...
@@ -291,13 +291,13 @@ fn count(st: &mut uint) -> Option<uint> {
#[test]
fn
test_cycle
()
{
let
cycle_len
=
3
;
let
it
=
count
(
0
u
,
1
)
.take
(
cycle_len
)
.cycle
();
let
it
=
count
(
0
,
1
)
.take
(
cycle_len
)
.cycle
();
assert_eq!
(
it
.size_hint
(),
(
uint
::
MAX
,
None
));
for
(
i
,
x
)
in
it
.take
(
100
)
.enumerate
()
{
assert_eq!
(
i
%
cycle_len
,
x
);
}
let
mut
it
=
count
(
0
u
,
1
)
.take
(
0
)
.cycle
();
let
mut
it
=
count
(
0
,
1
)
.take
(
0
)
.cycle
();
assert_eq!
(
it
.size_hint
(),
(
0
,
Some
(
0
)));
assert_eq!
(
it
.next
(),
None
);
}
...
...
@@ -305,7 +305,7 @@ fn test_cycle() {
#[test]
fn
test_iterator_nth
()
{
let
v
:
&
[
_
]
=
&
[
0
,
1
,
2
,
3
,
4
];
for
i
in
0
u
..
v
.len
()
{
for
i
in
0
..
v
.len
()
{
assert_eq!
(
v
.iter
()
.nth
(
i
)
.unwrap
(),
&
v
[
i
]);
}
assert_eq!
(
v
.iter
()
.nth
(
v
.len
()),
None
);
...
...
@@ -574,7 +574,7 @@ fn test_rposition() {
fn
g
(
xy
:
&
(
int
,
char
))
->
bool
{
let
(
_
x
,
y
)
=
*
xy
;
y
==
'd'
}
let
v
=
[(
0
,
'a'
),
(
1
,
'b'
),
(
2
,
'c'
),
(
3
,
'b'
)];
assert_eq!
(
v
.iter
()
.rposition
(
f
),
Some
(
3
u
));
assert_eq!
(
v
.iter
()
.rposition
(
f
),
Some
(
3
));
assert
!
(
v
.iter
()
.rposition
(
g
)
.is_none
());
}
...
...
@@ -601,7 +601,7 @@ fn check_randacc_iter<A, T>(a: T, len: uint) where
{
let
mut
b
=
a
.clone
();
assert_eq!
(
len
,
b
.indexable
());
let
mut
n
=
0
u
;
let
mut
n
=
0
;
for
(
i
,
elt
)
in
a
.enumerate
()
{
assert
!
(
Some
(
elt
)
==
b
.idx
(
i
));
n
+=
1
;
...
...
@@ -618,8 +618,8 @@ fn check_randacc_iter<A, T>(a: T, len: uint) where
#[test]
fn
test_double_ended_flat_map
()
{
let
u
=
[
0
u
,
1
];
let
v
=
[
5
u
,
6
,
7
,
8
];
let
u
=
[
0
,
1
];
let
v
=
[
5
,
6
,
7
,
8
];
let
mut
it
=
u
.iter
()
.flat_map
(|
x
|
v
[
*
x
..
v
.len
()]
.iter
());
assert_eq!
(
it
.next_back
()
.unwrap
(),
&
8
);
assert_eq!
(
it
.next
()
.unwrap
(),
&
5
);
...
...
@@ -849,30 +849,30 @@ fn test_min_max_result() {
#[test]
fn
test_iterate
()
{
let
mut
it
=
iterate
(
1
u
,
|
x
|
x
*
2
);
assert_eq!
(
it
.next
(),
Some
(
1
u
));
assert_eq!
(
it
.next
(),
Some
(
2
u
));
assert_eq!
(
it
.next
(),
Some
(
4
u
));
assert_eq!
(
it
.next
(),
Some
(
8
u
));
let
mut
it
=
iterate
(
1
,
|
x
|
x
*
2
);
assert_eq!
(
it
.next
(),
Some
(
1
));
assert_eq!
(
it
.next
(),
Some
(
2
));
assert_eq!
(
it
.next
(),
Some
(
4
));
assert_eq!
(
it
.next
(),
Some
(
8
));
}
#[test]
fn
test_repeat
()
{
let
mut
it
=
repeat
(
42
u
);
assert_eq!
(
it
.next
(),
Some
(
42
u
));
assert_eq!
(
it
.next
(),
Some
(
42
u
));
assert_eq!
(
it
.next
(),
Some
(
42
u
));
let
mut
it
=
repeat
(
42
);
assert_eq!
(
it
.next
(),
Some
(
42
));
assert_eq!
(
it
.next
(),
Some
(
42
));
assert_eq!
(
it
.next
(),
Some
(
42
));
}
#[test]
fn
test_fuse
()
{
let
mut
it
=
0
u
s
..
3
;
let
mut
it
=
0
..
3
;
assert_eq!
(
it
.len
(),
3
);
assert_eq!
(
it
.next
(),
Some
(
0
u
s
));
assert_eq!
(
it
.next
(),
Some
(
0
));
assert_eq!
(
it
.len
(),
2
);
assert_eq!
(
it
.next
(),
Some
(
1
u
s
));
assert_eq!
(
it
.next
(),
Some
(
1
));
assert_eq!
(
it
.len
(),
1
);
assert_eq!
(
it
.next
(),
Some
(
2
u
s
));
assert_eq!
(
it
.next
(),
Some
(
2
));
assert_eq!
(
it
.len
(),
0
);
assert_eq!
(
it
.next
(),
None
);
assert_eq!
(
it
.len
(),
0
);
...
...
@@ -884,7 +884,7 @@ fn test_fuse() {
#[bench]
fn
bench_rposition
(
b
:
&
mut
Bencher
)
{
let
it
:
Vec
<
uint
>
=
(
0
u
..
300
)
.collect
();
let
it
:
Vec
<
uint
>
=
(
0
..
300
)
.collect
();
b
.iter
(||
{
it
.iter
()
.rposition
(|
&
x
|
x
<=
150
);
});
...
...
@@ -893,7 +893,7 @@ fn bench_rposition(b: &mut Bencher) {
#[bench]
fn
bench_skip_while
(
b
:
&
mut
Bencher
)
{
b
.iter
(||
{
let
it
=
0
u
..
100
;
let
it
=
0
..
100
;
let
mut
sum
=
0
;
it
.skip_while
(|
&
x
|
{
sum
+=
x
;
sum
<
4000
})
.all
(|
_
|
true
);
});
...
...
@@ -901,10 +901,10 @@ fn bench_skip_while(b: &mut Bencher) {
#[bench]
fn
bench_multiple_take
(
b
:
&
mut
Bencher
)
{
let
mut
it
=
(
0
u
..
42
)
.cycle
();
let
mut
it
=
(
0
..
42
)
.cycle
();
b
.iter
(||
{
let
n
=
it
.next
()
.unwrap
();
for
_
in
0
u
..
n
{
for
_
in
0
..
n
{
it
.clone
()
.take
(
it
.next
()
.unwrap
())
.all
(|
_
|
true
);
}
});
...
...
src/libcoretest/mem.rs
浏览文件 @
cca1cf61
...
...
@@ -12,24 +12,24 @@
#[test]
fn
size_of_basic
()
{
assert_eq!
(
size_of
::
<
u8
>
(),
1
u
);
assert_eq!
(
size_of
::
<
u16
>
(),
2
u
);
assert_eq!
(
size_of
::
<
u32
>
(),
4
u
);
assert_eq!
(
size_of
::
<
u64
>
(),
8
u
);
assert_eq!
(
size_of
::
<
u8
>
(),
1
);
assert_eq!
(
size_of
::
<
u16
>
(),
2
);
assert_eq!
(
size_of
::
<
u32
>
(),
4
);
assert_eq!
(
size_of
::
<
u64
>
(),
8
);
}
#[test]
#[cfg(target_pointer_width
=
"32"
)]
fn
size_of_32
()
{
assert_eq!
(
size_of
::
<
uint
>
(),
4
u
);
assert_eq!
(
size_of
::
<*
const
uint
>
(),
4
u
);
assert_eq!
(
size_of
::
<
uint
>
(),
4
);
assert_eq!
(
size_of
::
<*
const
uint
>
(),
4
);
}
#[test]
#[cfg(target_pointer_width
=
"64"
)]
fn
size_of_64
()
{
assert_eq!
(
size_of
::
<
uint
>
(),
8
u
);
assert_eq!
(
size_of
::
<*
const
uint
>
(),
8
u
);
assert_eq!
(
size_of
::
<
uint
>
(),
8
);
assert_eq!
(
size_of
::
<*
const
uint
>
(),
8
);
}
#[test]
...
...
@@ -42,30 +42,30 @@ fn size_of_val_basic() {
#[test]
fn
align_of_basic
()
{
assert_eq!
(
align_of
::
<
u8
>
(),
1
u
);
assert_eq!
(
align_of
::
<
u16
>
(),
2
u
);
assert_eq!
(
align_of
::
<
u32
>
(),
4
u
);
assert_eq!
(
align_of
::
<
u8
>
(),
1
);
assert_eq!
(
align_of
::
<
u16
>
(),
2
);
assert_eq!
(
align_of
::
<
u32
>
(),
4
);
}
#[test]
#[cfg(target_pointer_width
=
"32"
)]
fn
align_of_32
()
{
assert_eq!
(
align_of
::
<
uint
>
(),
4
u
);
assert_eq!
(
align_of
::
<*
const
uint
>
(),
4
u
);
assert_eq!
(
align_of
::
<
uint
>
(),
4
);
assert_eq!
(
align_of
::
<*
const
uint
>
(),
4
);
}
#[test]
#[cfg(target_pointer_width
=
"64"
)]
fn
align_of_64
()
{
assert_eq!
(
align_of
::
<
uint
>
(),
8
u
);
assert_eq!
(
align_of
::
<*
const
uint
>
(),
8
u
);
assert_eq!
(
align_of
::
<
uint
>
(),
8
);
assert_eq!
(
align_of
::
<*
const
uint
>
(),
8
);
}
#[test]
fn
align_of_val_basic
()
{
assert_eq!
(
align_of_val
(
&
1u8
),
1
u
);
assert_eq!
(
align_of_val
(
&
1u16
),
2
u
);
assert_eq!
(
align_of_val
(
&
1u32
),
4
u
);
assert_eq!
(
align_of_val
(
&
1u8
),
1
);
assert_eq!
(
align_of_val
(
&
1u16
),
2
);
assert_eq!
(
align_of_val
(
&
1u32
),
4
);
}
#[test]
...
...
@@ -87,7 +87,7 @@ fn test_replace() {
#[test]
fn
test_transmute_copy
()
{
assert_eq!
(
1
u
,
unsafe
{
transmute_copy
(
&
1
)
});
assert_eq!
(
1
,
unsafe
{
transmute_copy
(
&
1
)
});
}
#[test]
...
...
src/libcoretest/num/uint_macros.rs
浏览文件 @
cca1cf61
...
...
@@ -33,8 +33,8 @@ fn test_bitwise_operators() {
assert!
(
0b1110
as
$T
==
(
0b1100
as
$T
)
.bitor
(
0b1010
as
$T
));
assert!
(
0b1000
as
$T
==
(
0b1100
as
$T
)
.bitand
(
0b1010
as
$T
));
assert!
(
0b0110
as
$T
==
(
0b1100
as
$T
)
.bitxor
(
0b1010
as
$T
));
assert!
(
0b1110
as
$T
==
(
0b0111
as
$T
)
.shl
(
1
u
));
assert!
(
0b0111
as
$T
==
(
0b1110
as
$T
)
.shr
(
1
u
));
assert!
(
0b1110
as
$T
==
(
0b0111
as
$T
)
.shl
(
1
));
assert!
(
0b0111
as
$T
==
(
0b1110
as
$T
)
.shr
(
1
));
assert!
(
MAX
-
(
0b1011
as
$T
)
==
(
0b1011
as
$T
)
.not
());
}
...
...
@@ -119,8 +119,8 @@ fn test_be() {
#[test]
fn
test_unsigned_checked_div
()
{
assert!
(
10
u
.checked_div
(
2
)
==
Some
(
5
));
assert!
(
5
u
.checked_div
(
0
)
==
None
);
assert!
(
10
.checked_div
(
2
)
==
Some
(
5
));
assert!
(
5
.checked_div
(
0
)
==
None
);
}
}
...
...
src/libcoretest/ops.rs
浏览文件 @
cca1cf61
...
...
@@ -33,11 +33,11 @@ fn alloc_obj_with_dtor(b: &mut Bencher) {
#[test]
fn
test_range
()
{
let
r
=
Range
{
start
:
2
u
,
end
:
10
};
let
mut
count
=
0
u
;
let
r
=
Range
{
start
:
2
,
end
:
10
};
let
mut
count
=
0
;
for
(
i
,
ri
)
in
r
.enumerate
()
{
assert
!
(
ri
==
i
+
2
);
assert
!
(
ri
>=
2
u
&&
ri
<
10u
);
assert
!
(
ri
>=
2
&&
ri
<
10
);
count
+=
1
;
}
assert
!
(
count
==
8
);
...
...
@@ -45,11 +45,11 @@ fn test_range() {
#[test]
fn
test_range_from
()
{
let
r
=
RangeFrom
{
start
:
2
u
};
let
mut
count
=
0
u
;
let
r
=
RangeFrom
{
start
:
2
};
let
mut
count
=
0
;
for
(
i
,
ri
)
in
r
.take
(
10
)
.enumerate
()
{
assert
!
(
ri
==
i
+
2
);
assert
!
(
ri
>=
2
u
&&
ri
<
12u
);
assert
!
(
ri
>=
2
&&
ri
<
12
);
count
+=
1
;
}
assert
!
(
count
==
10
);
...
...
@@ -58,7 +58,7 @@ fn test_range_from() {
#[test]
fn
test_range_to
()
{
// Not much to test.
let
_
=
RangeTo
{
end
:
42
u
};
let
_
=
RangeTo
{
end
:
42
};
}
#[test]
...
...
src/libcoretest/ptr.rs
浏览文件 @
cca1cf61
...
...
@@ -46,7 +46,7 @@ struct Pair {
v1
[
1
]
==
32001u16
&&
v1
[
2
]
==
0u16
));
copy_memory
(
v1
.as_mut_ptr
()
.offset
(
2
),
v0
.as_ptr
(),
1
u
);
v0
.as_ptr
(),
1
);
assert
!
((
v1
[
0
]
==
32002u16
&&
v1
[
1
]
==
32001u16
&&
v1
[
2
]
==
32000u16
));
...
...
src/libcoretest/tuple.rs
浏览文件 @
cca1cf61
...
...
@@ -19,7 +19,7 @@ fn test_clone() {
#[test]
fn
test_tuple_cmp
()
{
let
(
small
,
big
)
=
((
1
u
,
2u
,
3u
),
(
3u
,
2u
,
1u
));
let
(
small
,
big
)
=
((
1
,
2
,
3
),
(
3
,
2
,
1
));
let
nan
=
0.0f64
/
0.0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录