Implement Error trait for CapacityError

This commit is contained in:
bluss
2015-09-20 13:02:08 +02:00
parent d833e2c56d
commit c73d5fa203
2 changed files with 51 additions and 19 deletions
+10
View File
@@ -266,6 +266,8 @@ fn test_write() {
#[test]
fn test_string() {
use std::error::Error;
let text = "hello world";
let mut s = ArrayString::<[_; 16]>::new();
s.push_str(text).unwrap();
@@ -280,4 +282,12 @@ fn test_string() {
let mut t = ArrayString::<[_; 2]>::new();
assert!(t.push_str(text).is_err());
assert_eq!(&t, "");
// Test Error trait / try
let t = || -> Result<(), Box<Error>> {
let mut t = ArrayString::<[_; 2]>::new();
try!(t.push_str(text));
Ok(())
}();
assert!(t.is_err());
}