@@ -34,6 +34,9 @@ fn test_valid_arg() {
34
34
35
35
new_ucmd ! ( ) . arg ( "-F" ) . arg ( "10" ) . succeeds ( ) ;
36
36
new_ucmd ! ( ) . arg ( "--from-line" ) . arg ( "0" ) . succeeds ( ) ;
37
+
38
+ new_ucmd ! ( ) . arg ( "-P" ) . arg ( "something" ) . succeeds ( ) ;
39
+ new_ucmd ! ( ) . arg ( "--pattern" ) . arg ( "-1" ) . succeeds ( ) ;
37
40
}
38
41
}
39
42
@@ -151,3 +154,50 @@ fn test_more_error_on_multiple_files() {
151
154
. stderr_contains ( "file3" ) ;
152
155
}
153
156
}
157
+
158
+ #[ test]
159
+ fn test_more_pattern_found ( ) {
160
+ if std:: io:: stdout ( ) . is_terminal ( ) {
161
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
162
+ let at = & scene. fixtures ;
163
+
164
+ let file = "test_file" ;
165
+
166
+ at. write ( file, "line1\n line2" ) ;
167
+
168
+ // output only the second line "line2"
169
+ scene
170
+ . ucmd ( )
171
+ . arg ( "-P" )
172
+ . arg ( "line2" )
173
+ . arg ( file)
174
+ . succeeds ( )
175
+ . no_stderr ( )
176
+ . stdout_does_not_contain ( "line1" )
177
+ . stdout_contains ( "line2" ) ;
178
+ }
179
+ }
180
+
181
+ #[ test]
182
+ fn test_more_pattern_not_found ( ) {
183
+ if std:: io:: stdout ( ) . is_terminal ( ) {
184
+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
185
+ let at = & scene. fixtures ;
186
+
187
+ let file = "test_file" ;
188
+
189
+ let file_content = "line1\n line2" ;
190
+ at. write ( file, file_content) ;
191
+
192
+ scene
193
+ . ucmd ( )
194
+ . arg ( "-P" )
195
+ . arg ( "something" )
196
+ . arg ( file)
197
+ . succeeds ( )
198
+ . no_stderr ( )
199
+ . stdout_contains ( "Pattern not found" )
200
+ . stdout_contains ( "line1" )
201
+ . stdout_contains ( "line2" ) ;
202
+ }
203
+ }
0 commit comments