mirror of
https://github.com/mainmatter/100-exercises-to-learn-rust
synced 2024-12-26 21:58:49 +01:00
Use "bytes" instead of "characters" consistently when talking about length of a String
.
This commit is contained in:
parent
0bce2485ab
commit
6c217f7b66
22 changed files with 49 additions and 55 deletions
|
@ -9,13 +9,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ticket {
|
Ticket {
|
||||||
|
|
|
@ -44,13 +44,13 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Title cannot be longer than 50 characters")]
|
#[should_panic(expected = "Title cannot be longer than 50 bytes")]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
Ticket::new(overly_long_title(), valid_description(), "To-Do".into());
|
Ticket::new(overly_long_title(), valid_description(), "To-Do".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Description cannot be longer than 500 characters")]
|
#[should_panic(expected = "Description cannot be longer than 500 bytes")]
|
||||||
fn description_cannot_be_longer_than_500_chars() {
|
fn description_cannot_be_longer_than_500_chars() {
|
||||||
Ticket::new(valid_title(), overly_long_description(), "To-Do".into());
|
Ticket::new(valid_title(), overly_long_description(), "To-Do".into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -11,13 +11,13 @@ mod ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -11,13 +11,13 @@ pub mod ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -15,13 +15,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -14,13 +14,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
@ -76,14 +76,14 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Title cannot be longer than 50 characters")]
|
#[should_panic(expected = "Title cannot be longer than 50 bytes")]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
Ticket::new(valid_title(), valid_description(), "To-Do".into())
|
Ticket::new(valid_title(), valid_description(), "To-Do".into())
|
||||||
.set_title(overly_long_title())
|
.set_title(overly_long_title())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Description cannot be longer than 500 characters")]
|
#[should_panic(expected = "Description cannot be longer than 500 bytes")]
|
||||||
fn description_cannot_be_longer_than_500_chars() {
|
fn description_cannot_be_longer_than_500_chars() {
|
||||||
Ticket::new(valid_title(), valid_description(), "To-Do".into())
|
Ticket::new(valid_title(), valid_description(), "To-Do".into())
|
||||||
.set_description(overly_long_description())
|
.set_description(overly_long_description())
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// TODO: Define a new `Order` type.
|
// TODO: Define a new `Order` type.
|
||||||
// It should keep track of three pieces of information: `product_name`, `quantity`, and `unit_price`.
|
// It should keep track of three pieces of information: `product_name`, `quantity`, and `unit_price`.
|
||||||
// The product name can't be empty and it can't be longer than 300 characters.
|
// The product name can't be empty and it can't be longer than 300 bytes.
|
||||||
// The quantity must be strictly greater than zero.
|
// The quantity must be strictly greater than zero.
|
||||||
// The unit price is in cents and must be strictly greater than zero.
|
// The unit price is in cents and must be strictly greater than zero.
|
||||||
// Order must include a method named `total` that returns the total price of the order.
|
// Order must include a method named `total` that returns the total price of the order.
|
||||||
|
|
|
@ -12,13 +12,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -20,13 +20,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
if status != "To-Do" && status != "In Progress" && status != "Done" {
|
||||||
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
panic!("Only `To-Do`, `In Progress`, and `Done` statuses are allowed");
|
||||||
|
|
|
@ -22,13 +22,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ticket {
|
Ticket {
|
||||||
|
|
|
@ -20,13 +20,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ticket {
|
Ticket {
|
||||||
|
|
|
@ -21,13 +21,13 @@ impl Ticket {
|
||||||
panic!("Title cannot be empty");
|
panic!("Title cannot be empty");
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
panic!("Title cannot be longer than 50 characters");
|
panic!("Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
panic!("Description cannot be empty");
|
panic!("Description cannot be empty");
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
panic!("Description cannot be longer than 500 characters");
|
panic!("Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ticket {
|
Ticket {
|
||||||
|
@ -59,13 +59,13 @@ mod tests {
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
let error =
|
let error =
|
||||||
Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err();
|
Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err();
|
||||||
assert_eq!(error, "Title cannot be longer than 50 characters");
|
assert_eq!(error, "Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn description_cannot_be_longer_than_500_chars() {
|
fn description_cannot_be_longer_than_500_chars() {
|
||||||
let error =
|
let error =
|
||||||
Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err();
|
Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err();
|
||||||
assert_eq!(error, "Description cannot be longer than 500 characters");
|
assert_eq!(error, "Description cannot be longer than 500 bytes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ impl Ticket {
|
||||||
return Err("Title cannot be empty".to_string());
|
return Err("Title cannot be empty".to_string());
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
return Err("Title cannot be longer than 50 characters".to_string());
|
return Err("Title cannot be longer than 50 bytes".to_string());
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
return Err("Description cannot be empty".to_string());
|
return Err("Description cannot be empty".to_string());
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
return Err("Description cannot be longer than 500 characters".to_string());
|
return Err("Description cannot be longer than 500 bytes".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Ticket {
|
Ok(Ticket {
|
||||||
|
@ -60,7 +60,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Title cannot be longer than 50 characters")]
|
#[should_panic(expected = "Title cannot be longer than 50 bytes")]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ impl Ticket {
|
||||||
return Err("Title cannot be empty".to_string());
|
return Err("Title cannot be empty".to_string());
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
return Err("Title cannot be longer than 50 characters".to_string());
|
return Err("Title cannot be longer than 50 bytes".to_string());
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
return Err("Description cannot be empty".to_string());
|
return Err("Description cannot be empty".to_string());
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
return Err("Description cannot be longer than 500 characters".to_string());
|
return Err("Description cannot be longer than 500 bytes".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Ticket {
|
Ok(Ticket {
|
||||||
|
@ -70,7 +70,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Title cannot be longer than 50 characters")]
|
#[should_panic(expected = "Title cannot be longer than 50 bytes")]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl Ticket {
|
||||||
}
|
}
|
||||||
if title.len() > 50 {
|
if title.len() > 50 {
|
||||||
return Err(TicketNewError::TitleError(
|
return Err(TicketNewError::TitleError(
|
||||||
"Title cannot be longer than 50 characters".to_string(),
|
"Title cannot be longer than 50 bytes".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if description.is_empty() {
|
if description.is_empty() {
|
||||||
|
@ -53,7 +53,7 @@ impl Ticket {
|
||||||
}
|
}
|
||||||
if description.len() > 500 {
|
if description.len() > 500 {
|
||||||
return Err(TicketNewError::DescriptionError(
|
return Err(TicketNewError::DescriptionError(
|
||||||
"Description cannot be longer than 500 characters".to_string(),
|
"Description cannot be longer than 500 bytes".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic(expected = "Title cannot be longer than 50 characters")]
|
#[should_panic(expected = "Title cannot be longer than 50 bytes")]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
easy_ticket(overly_long_title(), valid_description(), Status::ToDo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn title_cannot_be_longer_than_fifty_chars() {
|
fn title_cannot_be_longer_than_fifty_chars() {
|
||||||
let err = Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err();
|
let err = Ticket::new(overly_long_title(), valid_description(), Status::ToDo).unwrap_err();
|
||||||
assert_eq!(err.to_string(), "Title cannot be longer than 50 characters");
|
assert_eq!(err.to_string(), "Title cannot be longer than 50 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -79,7 +79,7 @@ mod tests {
|
||||||
let err = Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err();
|
let err = Ticket::new(valid_title(), overly_long_description(), Status::ToDo).unwrap_err();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
"Description cannot be longer than 500 characters"
|
"Description cannot be longer than 500 bytes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ mod status;
|
||||||
pub enum TicketNewError {
|
pub enum TicketNewError {
|
||||||
#[error("Title cannot be empty")]
|
#[error("Title cannot be empty")]
|
||||||
TitleCannotBeEmpty,
|
TitleCannotBeEmpty,
|
||||||
#[error("Title cannot be longer than 50 characters")]
|
#[error("Title cannot be longer than 50 bytes")]
|
||||||
TitleTooLong,
|
TitleTooLong,
|
||||||
#[error("Description cannot be empty")]
|
#[error("Description cannot be empty")]
|
||||||
DescriptionCannotBeEmpty,
|
DescriptionCannotBeEmpty,
|
||||||
#[error("Description cannot be longer than 500 characters")]
|
#[error("Description cannot be longer than 500 bytes")]
|
||||||
DescriptionTooLong,
|
DescriptionTooLong,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// TODO: Implement `TryFrom<String>` and `TryFrom<&str>` for the `TicketDescription` type,
|
// TODO: Implement `TryFrom<String>` and `TryFrom<&str>` for the `TicketDescription` type,
|
||||||
// enforcing that the description is not empty and is not longer than 500 characters.
|
// enforcing that the description is not empty and is not longer than 500 bytes.
|
||||||
// Implement the traits required to make the tests pass too.
|
// Implement the traits required to make the tests pass too.
|
||||||
|
|
||||||
pub struct TicketDescription(String);
|
pub struct TicketDescription(String);
|
||||||
|
@ -27,7 +27,7 @@ mod tests {
|
||||||
let err = TicketDescription::try_from(description).unwrap_err();
|
let err = TicketDescription::try_from(description).unwrap_err();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
"The description cannot be longer than 500 characters"
|
"The description cannot be longer than 500 bytes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,7 @@ mod tests {
|
||||||
"A title that's definitely longer than what should be allowed in a development ticket"
|
"A title that's definitely longer than what should be allowed in a development ticket"
|
||||||
.to_string();
|
.to_string();
|
||||||
let err = TicketTitle::try_from(title).unwrap_err();
|
let err = TicketTitle::try_from(title).unwrap_err();
|
||||||
assert_eq!(
|
assert_eq!(err.to_string(), "The title cannot be longer than 50 bytes");
|
||||||
err.to_string(),
|
|
||||||
"The title cannot be longer than 50 characters"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub struct TicketDescription(String);
|
||||||
pub enum TicketDescriptionError {
|
pub enum TicketDescriptionError {
|
||||||
#[error("The description cannot be empty")]
|
#[error("The description cannot be empty")]
|
||||||
Empty,
|
Empty,
|
||||||
#[error("The description cannot be longer than 500 characters")]
|
#[error("The description cannot be longer than 500 bytes")]
|
||||||
TooLong,
|
TooLong,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ mod tests {
|
||||||
let err = TicketDescription::try_from(overly_long_description()).unwrap_err();
|
let err = TicketDescription::try_from(overly_long_description()).unwrap_err();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
"The description cannot be longer than 500 characters"
|
"The description cannot be longer than 500 bytes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub struct TicketTitle(String);
|
||||||
pub enum TicketTitleError {
|
pub enum TicketTitleError {
|
||||||
#[error("The title cannot be empty")]
|
#[error("The title cannot be empty")]
|
||||||
Empty,
|
Empty,
|
||||||
#[error("The title cannot be longer than 50 characters")]
|
#[error("The title cannot be longer than 50 bytes")]
|
||||||
TooLong,
|
TooLong,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +61,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_try_from_long_string() {
|
fn test_try_from_long_string() {
|
||||||
let err = TicketTitle::try_from(overly_long_title()).unwrap_err();
|
let err = TicketTitle::try_from(overly_long_title()).unwrap_err();
|
||||||
assert_eq!(
|
assert_eq!(err.to_string(), "The title cannot be longer than 50 bytes");
|
||||||
err.to_string(),
|
|
||||||
"The title cannot be longer than 50 characters"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue