Add tests

This commit is contained in:
Brendan Molloy 2021-08-04 20:40:28 +02:00
parent e3cfa98b2f
commit 345cafbdef
2 changed files with 42 additions and 0 deletions

View File

@ -494,6 +494,22 @@ mod tests {
assert_eq!(s2, "abcd efgh");
}
#[test]
fn cmp() {
let s1: String<4> = String::from("abcd");
let s2: String<4> = String::from("zzzz");
assert!(s1 < s2);
}
#[test]
fn cmp_heterogenous_size() {
let s1: String<4> = String::from("abcd");
let s2: String<8> = String::from("zzzz");
assert!(s1 < s2);
}
#[test]
fn debug() {
use core::fmt::Write;

View File

@ -907,6 +907,32 @@ mod tests {
assert_eq!(xs, ys);
}
#[test]
fn cmp() {
let mut xs: Vec<i32, 4> = Vec::new();
let mut ys: Vec<i32, 4> = Vec::new();
assert_eq!(xs, ys);
xs.push(1).unwrap();
ys.push(2).unwrap();
assert!(xs < ys);
}
#[test]
fn cmp_heterogenous_size() {
let mut xs: Vec<i32, 4> = Vec::new();
let mut ys: Vec<i32, 8> = Vec::new();
assert_eq!(xs, ys);
xs.push(1).unwrap();
ys.push(2).unwrap();
assert!(xs < ys);
}
#[test]
fn full() {
let mut v: Vec<i32, 4> = Vec::new();