Skip to content

Commit

Permalink
Merge #390
Browse files Browse the repository at this point in the history
390: enable adapter tests for encode_{lower, upper} r=Dylan-DPC a=kinggoesgaming

**I'm submitting a(n)** other

# Description
`encode_{lower, upper}` tests were not enabled when we enabled the functions.

# Motivation
More tests

# Tests
New tests enabled

# Related Issue(s)


Co-authored-by: Hunar Roop Kahlon <[email protected]>
  • Loading branch information
bors[bot] and kinggoesgaming committed Apr 1, 2019
2 parents 2a8f213 + 6cbfb3a commit ce195c3
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 83 deletions.
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;
extern crate std;

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

0 comments on commit ce195c3

Please sign in to comment.