2024-06-21 16:22:37 -04:00
|
|
|
struct ColorRegularStruct {
|
|
|
|
// TODO: Add the fields that the test `regular_structs` expects.
|
|
|
|
// What types should the fields have? What are the minimum and maximum values for RGB colors?
|
2019-05-25 07:39:58 -04:00
|
|
|
}
|
|
|
|
|
2024-06-21 16:22:37 -04:00
|
|
|
struct ColorTupleStruct(/* TODO: Add the fields that the test `tuple_structs` expects */);
|
2019-05-25 07:39:58 -04:00
|
|
|
|
2019-06-20 10:45:53 -04:00
|
|
|
#[derive(Debug)]
|
2024-06-21 16:22:37 -04:00
|
|
|
struct UnitStruct;
|
2019-05-25 07:39:58 -04:00
|
|
|
|
2024-04-17 16:46:21 -04:00
|
|
|
fn main() {
|
|
|
|
// You can optionally experiment here.
|
|
|
|
}
|
|
|
|
|
2019-05-25 07:39:58 -04:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
2024-06-21 16:22:37 -04:00
|
|
|
fn regular_structs() {
|
|
|
|
// TODO: Instantiate a regular struct.
|
2019-05-25 07:39:58 -04:00
|
|
|
// let green =
|
|
|
|
|
2022-07-14 05:59:29 -04:00
|
|
|
assert_eq!(green.red, 0);
|
|
|
|
assert_eq!(green.green, 255);
|
|
|
|
assert_eq!(green.blue, 0);
|
2019-05-25 07:39:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tuple_structs() {
|
2024-06-21 16:22:37 -04:00
|
|
|
// TODO: Instantiate a tuple struct.
|
2019-05-25 07:39:58 -04:00
|
|
|
// let green =
|
|
|
|
|
2022-07-14 05:59:29 -04:00
|
|
|
assert_eq!(green.0, 0);
|
|
|
|
assert_eq!(green.1, 255);
|
|
|
|
assert_eq!(green.2, 0);
|
2019-05-25 07:39:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unit_structs() {
|
2024-06-21 16:22:37 -04:00
|
|
|
// TODO: Instantiate a unit struct.
|
|
|
|
// let unit_struct =
|
|
|
|
let message = format!("{unit_struct:?}s are fun!");
|
2019-05-25 07:39:58 -04:00
|
|
|
|
2024-06-21 16:22:37 -04:00
|
|
|
assert_eq!(message, "UnitStructs are fun!");
|
2019-05-25 07:39:58 -04:00
|
|
|
}
|
|
|
|
}
|