From 6dab472b9d370e3c7c189a1607cc1d65c5cd53ba Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 2 Mar 2025 23:06:12 +0100
Subject: [PATCH] Add tests for the `rectangles` project

---
 rectangles/src/main.rs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/rectangles/src/main.rs b/rectangles/src/main.rs
index 8050301..14a3d0a 100644
--- a/rectangles/src/main.rs
+++ b/rectangles/src/main.rs
@@ -11,8 +11,31 @@ impl Rectangle {
             height: size,
         }
     }
+
+    fn can_hold(&self, other: &Rectangle) -> bool {
+        self.width > other.width && self.height > other.height
+    }
 }
 
 fn main() {
     let sq = Rectangle::square(3);
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn larger_can_hold_smaller() {
+        let larger = Rectangle {
+            width: 8,
+            height: 7,
+        };
+        let smaller = Rectangle {
+            width: 5,
+            height: 1,
+        };
+
+        assert!(larger.can_hold(&smaller));
+    }
+}