Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable adapter tests for encode_{lower, upper} #390

Merged
merged 3 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 85 additions & 82 deletions src/adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,85 +844,88 @@ impl<'a> UrnRef<'a> {
}
}

// TODO: uncomment when we undo the pub(crate) change
// #[cfg(test)]
// mod tests {
// use Uuid;
//
// #[test]
// fn hyphenated_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_hyphenated().encode_lower(&mut buf).len();
// assert_eq!(len, super::Hyphenated::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
// #[test]
// fn hyphenated_ref_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_hyphenated().encode_lower(&mut buf).len();
// assert_eq!(len, super::HyphenatedRef::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
//
// #[test]
// fn simple_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_simple().encode_lower(&mut buf).len();
// assert_eq!(len, super::Simple::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
// #[test]
// fn simple_ref_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_simple().encode_lower(&mut buf).len();
// assert_eq!(len, super::SimpleRef::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
//
// #[test]
// fn urn_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_urn().encode_lower(&mut buf).len();
// assert_eq!(len, super::Urn::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
// #[test]
// fn urn_ref_trailing() {
// let mut buf = [b'x'; 100];
// let len = Uuid::nil().to_urn().encode_lower(&mut buf).len();
// assert_eq!(len, super::UrnRef::LENGTH);
// assert!(buf[len..].iter().all(|x| *x == b'x'));
// }
//
// #[test]
// #[should_panic]
// fn hyphenated_too_small() {
// Uuid::nil().to_hyphenated().encode_lower(&mut [0; 35]);
// }
// #[test]
// #[should_panic]
// fn hyphenated_ref_too_small() {
// Uuid::nil().to_hyphenated_ref().encode_lower(&mut [0; 35]);
// }
//
// #[test]
// #[should_panic]
// fn simple_too_small() {
// Uuid::nil().to_simple().encode_lower(&mut [0; 31]);
// }
// #[test]
// #[should_panic]
// fn simple_ref_too_small() {
// Uuid::nil().to_simple_ref().encode_lower(&mut [0; 31]);
// }
// #[test]
// #[should_panic]
// fn urn_too_small() {
// Uuid::nil().to_urn().encode_lower(&mut [0; 44]);
// }
// #[test]
// #[should_panic]
// fn urn_ref_too_small() {
// Uuid::nil().to_urn_ref().encode_lower(&mut [0; 44]);
// }
// }
#[cfg(test)]
mod tests {
use crate::prelude::*;

#[test]
fn hyphenated_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_hyphenated().encode_lower(&mut buf).len();
assert_eq!(len, super::Hyphenated::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
fn hyphenated_ref_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_hyphenated().encode_lower(&mut buf).len();
assert_eq!(len, super::HyphenatedRef::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
fn simple_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_simple().encode_lower(&mut buf).len();
assert_eq!(len, super::Simple::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
fn simple_ref_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_simple().encode_lower(&mut buf).len();
assert_eq!(len, super::SimpleRef::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
fn urn_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_urn().encode_lower(&mut buf).len();
assert_eq!(len, super::Urn::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
fn urn_ref_trailing() {
let mut buf = [b'x'; 100];
let len = Uuid::nil().to_urn().encode_lower(&mut buf).len();
assert_eq!(len, super::UrnRef::LENGTH);
assert!(buf[len..].iter().all(|x| *x == b'x'));
}

#[test]
#[should_panic]
fn hyphenated_too_small() {
Uuid::nil().to_hyphenated().encode_lower(&mut [0; 35]);
}

#[test]
#[should_panic]
fn hyphenated_ref_too_small() {
Uuid::nil().to_hyphenated_ref().encode_lower(&mut [0; 35]);
}

#[test]
#[should_panic]
fn simple_too_small() {
Uuid::nil().to_simple().encode_lower(&mut [0; 31]);
}
#[test]
#[should_panic]
fn simple_ref_too_small() {
Uuid::nil().to_simple_ref().encode_lower(&mut [0; 31]);
}
#[test]
#[should_panic]
fn urn_too_small() {
Uuid::nil().to_urn().encode_lower(&mut [0; 44]);
}
#[test]
#[should_panic]
fn urn_ref_too_small() {
Uuid::nil().to_urn_ref().encode_lower(&mut [0; 44]);
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ impl Uuid {

#[cfg(test)]
mod tests {
pub extern crate std;
pub use std;
kinggoesgaming marked this conversation as resolved.
Show resolved Hide resolved

use super::test_util;
use crate::prelude::*;
Expand Down