Skip to content

Commit 5a05f0f

Browse files
Add test for NumBuffer compilation error
1 parent a7a14d5 commit 5a05f0f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tests/run-make/num-fmt/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(int_format_into)]
2+
3+
use std::fmt::NumBuffer;
4+
5+
fn main() {
6+
let x = 0u32;
7+
let mut buf = NumBuffer::<u8>::new();
8+
x.format_into(&mut buf); //~ ERROR
9+
}

tests/run-make/num-fmt/rmake.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Test to ensure that if you use a `NumBuffer` with a too small integer, it
2+
// will fail at compilation time.
3+
4+
// FIXME: This test should be a `ui` test, but not possible for the following reasons:
5+
// * With the default `--emit`, the compilation succeeds, we can go around by using `--emit=link`
6+
// but then we get the second problem.
7+
// * Compilation error is not generated in the JSON output.
8+
//
9+
// So for not we go around this problem by moving it in `run-make` until we figure out what's
10+
// going on.
11+
12+
//@ needs-target-std
13+
14+
use run_make_support::rustc;
15+
16+
fn main() {
17+
rustc()
18+
.input("main.rs")
19+
.run_fail()
20+
.assert_stderr_contains("buffer is not big enough");
21+
}

0 commit comments

Comments
 (0)