Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Raphaël Gomès
micro-timer
Commits
6dbf275963cf
Commit
1b750c3f
authored
Feb 28, 2020
by
Raphaël Gomès
Browse files
Update compilation tests to account for the new `mut` changes
parent
df62aeed57b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/compilation.rs
0 → 100644
View file @
6dbf2759
//! Compilation tests: they only test if the compilation fails, not the
//! macro output
use
log
;
use
micro_timer
::
timed
;
#[test]
fn
check_name_conflict
()
{
#[timed]
fn
thing
(
_value
:
usize
)
->
usize
{
let
timer
=
10
;
timer
}
assert_eq!
(
thing
(
1
),
10
as
usize
);
}
#[test]
fn
test_mut
()
{
#[timed]
fn
thing
(
mut
value
:
usize
)
{
value
=
5
;
}
thing
(
1
);
}
#[test]
fn
test_ref_mut
()
{
#[timed]
fn
thing
(
value
:
&
mut
String
)
{
value
.push
(
'a'
);
}
let
mut
a
=
String
::
new
();
thing
(
&
mut
a
);
assert_eq!
(
"a"
,
a
);
}
#[test]
fn
test_fn_mut
()
{
#[timed]
fn
thing
(
value
:
&
mut
String
)
{
value
.push
(
'a'
);
}
let
mut
a
=
String
::
new
();
thing
(
&
mut
a
);
assert_eq!
(
"a"
,
a
);
}
#[test]
fn
test_mut_struct
()
{
#[timed]
fn
thing
(
value
:
Thing
)
->
&
mut
String
{
value
.value
}
let
mut
s
=
String
::
new
();
struct
Thing
<
'a
>
{
value
:
&
'a
mut
String
,
}
thing
(
Thing
{
value
:
&
mut
s
});
}
#[test]
fn
test_mut_pointer
()
{
#[timed]
fn
thing
(
value
:
*
mut
u8
)
{
unsafe
{
*
value
!=
0u8
};
}
let
mut
s
=
String
::
new
();
thing
(
s
.as_mut_ptr
());
}
tests/tests.rs
deleted
100644 → 0
View file @
df62aeed
use
log
;
use
micro_timer
::
timed
;
use
std
::
time
::
Duration
;
#[test]
fn
check
()
{
#[timed]
fn
thing
(
_value
:
usize
)
->
usize
{
let
timer
=
10
;
std
::
thread
::
sleep
(
Duration
::
from_millis
(
10
));
timer
}
assert_eq!
(
thing
(
1
),
10
as
usize
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment