@@ -9,10 +9,17 @@ mod tests {
99 let expected = "expected output" ;
1010
1111 // Act
12+ let start_time = std:: time:: Instant :: now ( ) ;
1213 let result = function_one ( input) ;
14+ let duration = start_time. elapsed ( ) ;
1315
1416 // Assert
15- assert_eq ! ( result, expected) ;
17+ assert_eq ! ( result, expected, "The function did not return the expected result for a valid input" ) ;
18+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
19+
20+ // Additional checks
21+ assert ! ( !result. is_empty( ) , "Result should not be empty for a valid input" ) ;
22+ assert_ne ! ( result, "unexpected output" , "Result should not be 'unexpected output' for a valid input" ) ;
1623 }
1724
1825 #[ test]
@@ -22,10 +29,17 @@ mod tests {
2229 let expected = 84 ;
2330
2431 // Act
32+ let start_time = std:: time:: Instant :: now ( ) ;
2533 let result = function_two ( input) ;
34+ let duration = start_time. elapsed ( ) ;
2635
2736 // Assert
28- assert_eq ! ( result, expected) ;
37+ assert_eq ! ( result, expected, "The function did not return the expected result for a positive input" ) ;
38+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
39+
40+ // Additional checks
41+ assert ! ( result > 0 , "Result should be positive for a positive input" ) ;
42+ assert_ne ! ( result, 0 , "Result should not be zero for a non-zero input" ) ;
2943 }
3044
3145 #[ test]
@@ -56,10 +70,17 @@ mod tests {
5670 let expected = "another expected output" ;
5771
5872 // Act
73+ let start_time = std:: time:: Instant :: now ( ) ;
5974 let result = function_four ( input) ;
75+ let duration = start_time. elapsed ( ) ;
6076
6177 // Assert
62- assert_eq ! ( result, expected) ;
78+ assert_eq ! ( result, expected, "The function did not return the expected result for a valid input" ) ;
79+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
80+
81+ // Additional checks
82+ assert ! ( !result. is_empty( ) , "Result should not be empty for a valid input" ) ;
83+ assert_ne ! ( result, "unexpected output" , "Result should not be 'unexpected output' for a valid input" ) ;
6384 }
6485
6586 #[ test]
@@ -69,10 +90,13 @@ mod tests {
6990 let expected = "empty output" ;
7091
7192 // Act
93+ let start_time = std:: time:: Instant :: now ( ) ;
7294 let result = function_one ( input) ;
95+ let duration = start_time. elapsed ( ) ;
7396
7497 // Assert
75- assert_eq ! ( result, expected) ;
98+ assert_eq ! ( result, expected, "The function did not return the expected result for an empty input" ) ;
99+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
76100
77101 // Additional checks
78102 assert ! ( result. is_empty( ) , "Result should be empty for empty input" ) ;
@@ -139,4 +163,86 @@ mod tests {
139163 assert ! ( result. contains( "special" ) , "Result should contain 'special' for special characters input" ) ;
140164 assert_ne ! ( result, "unexpected output" , "Result should not be 'unexpected output' for special characters input" ) ;
141165 }
166+
167+ #[ test]
168+ fn test_function_one_long_input ( ) {
169+ // Arrange
170+ let input = "a" . repeat ( 1000 ) ;
171+ let expected = "long output" ;
172+
173+ // Act
174+ let start_time = std:: time:: Instant :: now ( ) ;
175+ let result = function_one ( & input) ;
176+ let duration = start_time. elapsed ( ) ;
177+
178+ // Assert
179+ assert_eq ! ( result, expected, "The function did not return the expected result for a long input" ) ;
180+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
181+
182+ // Additional checks
183+ assert ! ( !result. is_empty( ) , "Result should not be empty for a long input" ) ;
184+ assert_ne ! ( result, "short output" , "Result should not be 'short output' for a long input" ) ;
185+ }
186+
187+ #[ test]
188+ fn test_function_two_large_input ( ) {
189+ // Arrange
190+ let input = 1_000_000 ;
191+ let expected = 2_000_000 ;
192+
193+ // Act
194+ let start_time = std:: time:: Instant :: now ( ) ;
195+ let result = function_two ( input) ;
196+ let duration = start_time. elapsed ( ) ;
197+
198+ // Assert
199+ assert_eq ! ( result, expected, "The function did not return the expected result for a large input" ) ;
200+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
201+
202+ // Additional checks
203+ assert ! ( result > 0 , "Result should be positive for a large input" ) ;
204+ assert_ne ! ( result, 0 , "Result should not be zero for a non-zero input" ) ;
205+ }
206+
207+ #[ test]
208+ fn test_function_three_large_vector ( ) {
209+ // Arrange
210+ let input: Vec < i32 > = ( 1 ..=1000 ) . collect ( ) ;
211+ let expected: Vec < i32 > = input. iter ( ) . map ( |& x| x * 2 ) . collect ( ) ;
212+
213+ // Act
214+ let start_time = std:: time:: Instant :: now ( ) ;
215+ let result = function_three ( & input) ;
216+ let duration = start_time. elapsed ( ) ;
217+
218+ // Assert
219+ assert_eq ! ( result, expected, "The function did not return the expected result for a large vector" ) ;
220+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
221+
222+ // Additional checks
223+ assert ! ( !result. is_empty( ) , "Result should not be empty for a large vector input" ) ;
224+ assert_eq ! ( result. len( ) , input. len( ) , "Result length should match input length" ) ;
225+ assert_ne ! ( result, input, "Result should not be the same as input vector" ) ;
226+ }
227+
228+ #[ test]
229+ fn test_function_four_unicode_input ( ) {
230+ // Arrange
231+ let input = "こんにちは" ;
232+ let expected = "unicode output" ;
233+
234+ // Act
235+ let start_time = std:: time:: Instant :: now ( ) ;
236+ let result = function_four ( input) ;
237+ let duration = start_time. elapsed ( ) ;
238+
239+ // Assert
240+ assert_eq ! ( result, expected, "The function did not return the expected result for a unicode input" ) ;
241+ assert ! ( duration. as_millis( ) < 10 , "The function took too long to execute" ) ;
242+
243+ // Additional checks
244+ assert ! ( !result. is_empty( ) , "Result should not be empty for a unicode input" ) ;
245+ assert ! ( result. contains( "unicode" ) , "Result should contain 'unicode' for a unicode input" ) ;
246+ assert_ne ! ( result, "unexpected output" , "Result should not be 'unexpected output' for a unicode input" ) ;
247+ }
142248}
0 commit comments