[wip] unit tests
- re-added redundant `tests` submodules for good form
This commit is contained in:
parent
22eeada52a
commit
66f59b4b3b
2 changed files with 71 additions and 59 deletions
|
|
@ -109,8 +109,13 @@ impl From<bool> for FileID {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// technically redundant, but kept for refactoring purposes
|
||||||
fn true_makes_valids() {
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn true_makes_valids() {
|
||||||
let uri = Uri::from(true);
|
let uri = Uri::from(true);
|
||||||
let alias_id = AliasID::from(true);
|
let alias_id = AliasID::from(true);
|
||||||
let share_id = ShareID::from(true);
|
let share_id = ShareID::from(true);
|
||||||
|
|
@ -119,10 +124,10 @@ fn true_makes_valids() {
|
||||||
assert!((&uri, &alias_id).check().is_ok());
|
assert!((&uri, &alias_id).check().is_ok());
|
||||||
assert!(share_id.check().is_ok());
|
assert!(share_id.check().is_ok());
|
||||||
assert!((&share_id, &file_id).check().is_ok());
|
assert!((&share_id, &file_id).check().is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default_is_valid() {
|
fn default_is_valid() {
|
||||||
let uri = Uri::default();
|
let uri = Uri::default();
|
||||||
let alias_id = AliasID::from(true); // no `impl Default`
|
let alias_id = AliasID::from(true); // no `impl Default`
|
||||||
let share_id = ShareID::default();
|
let share_id = ShareID::default();
|
||||||
|
|
@ -131,10 +136,10 @@ fn default_is_valid() {
|
||||||
assert!((&uri, &alias_id).check().is_ok());
|
assert!((&uri, &alias_id).check().is_ok());
|
||||||
assert!(share_id.check().is_ok());
|
assert!(share_id.check().is_ok());
|
||||||
assert!((&share_id, &file_id).check().is_ok());
|
assert!((&share_id, &file_id).check().is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn false_makes_invalids() {
|
fn false_makes_invalids() {
|
||||||
use crate::Parameter;
|
use crate::Parameter;
|
||||||
|
|
||||||
fn test_check(value: impl CheckID, callback: impl FnOnce(&Parameter) -> bool) {
|
fn test_check(value: impl CheckID, callback: impl FnOnce(&Parameter) -> bool) {
|
||||||
|
|
@ -173,4 +178,5 @@ fn false_makes_invalids() {
|
||||||
test_check((&share_id_i, &file_id_i), is_share_id_i);
|
test_check((&share_id_i, &file_id_i), is_share_id_i);
|
||||||
test_check((&share_id_i, &file_id), is_share_id_i);
|
test_check((&share_id_i, &file_id), is_share_id_i);
|
||||||
test_check((&share_id, &file_id_i), is_file_id_i);
|
test_check((&share_id, &file_id_i), is_file_id_i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,14 @@ pub fn create_file(data: &[u8]) -> NamedTempFile {
|
||||||
tmp
|
tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// technically redundant, but kept for refactoring purposes
|
||||||
#[should_panic = "`impl foo for bar` expected: 1, actual: 0"]
|
#[cfg(test)]
|
||||||
fn make_check_trait_panic() {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic = "`impl foo for bar` expected: 1, actual: 0"]
|
||||||
|
fn make_check_trait_panic() {
|
||||||
check_trait(0, 1, "foo", "bar");
|
check_trait(0, 1, "foo", "bar");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue