@@ -36,17 +36,17 @@ macro_rules! assert_history_items {
36
36
37
37
fn create_lines ( ) -> Vec < Line > {
38
38
vec ! [
39
- Line :: new ( "pick aaa c1" ) . unwrap( ) ,
40
- Line :: new ( "pick bbb c2" ) . unwrap( ) ,
41
- Line :: new ( "pick ccc c3" ) . unwrap( ) ,
42
- Line :: new ( "pick ddd c4" ) . unwrap( ) ,
43
- Line :: new ( "pick eee c5" ) . unwrap( ) ,
39
+ Line :: parse ( "pick aaa c1" ) . unwrap( ) ,
40
+ Line :: parse ( "pick bbb c2" ) . unwrap( ) ,
41
+ Line :: parse ( "pick ccc c3" ) . unwrap( ) ,
42
+ Line :: parse ( "pick ddd c4" ) . unwrap( ) ,
43
+ Line :: parse ( "pick eee c5" ) . unwrap( ) ,
44
44
]
45
45
}
46
46
47
47
macro_rules! assert_todo_lines {
48
48
( $lines: expr, $( $arg: expr) ,* ) => {
49
- let expected = vec![ $( Line :: new ( $arg) . unwrap( ) , ) * ] ;
49
+ let expected = vec![ $( Line :: parse ( $arg) . unwrap( ) , ) * ] ;
50
50
pretty_assertions:: assert_str_eq!(
51
51
$lines. iter( ) . map( Line :: to_text) . collect:: <Vec <String >>( ) . join( "\n " ) ,
52
52
expected. iter( ) . map( Line :: to_text) . collect:: <Vec <String >>( ) . join( "\n " )
@@ -229,7 +229,7 @@ fn undo_redo_add_range_end_index_at_bottom() {
229
229
#[ test]
230
230
fn undo_redo_remove_start ( ) {
231
231
let mut history = History :: new ( 10 ) ;
232
- history. record ( HistoryItem :: new_remove ( 0 , 0 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
232
+ history. record ( HistoryItem :: new_remove ( 0 , 0 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
233
233
let mut lines = create_lines ( ) ;
234
234
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 0 , 0 ) ) ;
235
235
assert_todo_lines ! (
@@ -255,7 +255,7 @@ fn undo_redo_remove_start() {
255
255
#[ test]
256
256
fn undo_redo_remove_end ( ) {
257
257
let mut history = History :: new ( 10 ) ;
258
- history. record ( HistoryItem :: new_remove ( 5 , 5 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
258
+ history. record ( HistoryItem :: new_remove ( 5 , 5 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
259
259
let mut lines = create_lines ( ) ;
260
260
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 5 , 5 ) ) ;
261
261
assert_todo_lines ! (
@@ -281,7 +281,7 @@ fn undo_redo_remove_end() {
281
281
#[ test]
282
282
fn undo_redo_remove_middle ( ) {
283
283
let mut history = History :: new ( 10 ) ;
284
- history. record ( HistoryItem :: new_remove ( 2 , 2 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
284
+ history. record ( HistoryItem :: new_remove ( 2 , 2 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
285
285
let mut lines = create_lines ( ) ;
286
286
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 2 , 2 ) ) ;
287
287
assert_todo_lines ! (
@@ -308,8 +308,8 @@ fn undo_redo_remove_middle() {
308
308
fn undo_redo_remove_range_start_index_top ( ) {
309
309
let mut history = History :: new ( 10 ) ;
310
310
history. record ( HistoryItem :: new_remove ( 0 , 1 , vec ! [
311
- Line :: new ( "drop xxx cx" ) . unwrap( ) ,
312
- Line :: new ( "drop yyy cy" ) . unwrap( ) ,
311
+ Line :: parse ( "drop xxx cx" ) . unwrap( ) ,
312
+ Line :: parse ( "drop yyy cy" ) . unwrap( ) ,
313
313
] ) ) ;
314
314
let mut lines = create_lines ( ) ;
315
315
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 0 , 1 ) ) ;
@@ -338,8 +338,8 @@ fn undo_redo_remove_range_start_index_top() {
338
338
fn undo_redo_remove_range_start_index_bottom ( ) {
339
339
let mut history = History :: new ( 10 ) ;
340
340
history. record ( HistoryItem :: new_remove ( 6 , 5 , vec ! [
341
- Line :: new ( "drop xxx cx" ) . unwrap( ) ,
342
- Line :: new ( "drop yyy cy" ) . unwrap( ) ,
341
+ Line :: parse ( "drop xxx cx" ) . unwrap( ) ,
342
+ Line :: parse ( "drop yyy cy" ) . unwrap( ) ,
343
343
] ) ) ;
344
344
let mut lines = create_lines ( ) ;
345
345
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 6 , 5 ) ) ;
@@ -368,8 +368,8 @@ fn undo_redo_remove_range_start_index_bottom() {
368
368
fn undo_redo_remove_range_end_index_top ( ) {
369
369
let mut history = History :: new ( 10 ) ;
370
370
history. record ( HistoryItem :: new_remove ( 1 , 0 , vec ! [
371
- Line :: new ( "drop xxx cx" ) . unwrap( ) ,
372
- Line :: new ( "drop yyy cy" ) . unwrap( ) ,
371
+ Line :: parse ( "drop xxx cx" ) . unwrap( ) ,
372
+ Line :: parse ( "drop yyy cy" ) . unwrap( ) ,
373
373
] ) ) ;
374
374
let mut lines = create_lines ( ) ;
375
375
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 1 , 0 ) ) ;
@@ -398,8 +398,8 @@ fn undo_redo_remove_range_end_index_top() {
398
398
fn undo_redo_remove_range_end_index_bottom ( ) {
399
399
let mut history = History :: new ( 10 ) ;
400
400
history. record ( HistoryItem :: new_remove ( 5 , 6 , vec ! [
401
- Line :: new ( "drop xxx cx" ) . unwrap( ) ,
402
- Line :: new ( "drop yyy cy" ) . unwrap( ) ,
401
+ Line :: parse ( "drop xxx cx" ) . unwrap( ) ,
402
+ Line :: parse ( "drop yyy cy" ) . unwrap( ) ,
403
403
] ) ) ;
404
404
let mut lines = create_lines ( ) ;
405
405
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Remove , 5 , 6 ) ) ;
@@ -702,7 +702,7 @@ fn undo_redo_swap_down_range_up_index_end() {
702
702
#[ test]
703
703
fn undo_redo_modify_single_index_start ( ) {
704
704
let mut history = History :: new ( 10 ) ;
705
- history. record ( HistoryItem :: new_modify ( 0 , 0 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
705
+ history. record ( HistoryItem :: new_modify ( 0 , 0 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
706
706
let mut lines = create_lines ( ) ;
707
707
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 0 , 0 ) ) ;
708
708
assert_todo_lines ! (
@@ -727,7 +727,7 @@ fn undo_redo_modify_single_index_start() {
727
727
#[ test]
728
728
fn undo_redo_modify_single_index_end ( ) {
729
729
let mut history = History :: new ( 10 ) ;
730
- history. record ( HistoryItem :: new_modify ( 4 , 4 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
730
+ history. record ( HistoryItem :: new_modify ( 4 , 4 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
731
731
let mut lines = create_lines ( ) ;
732
732
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 4 , 4 ) ) ;
733
733
assert_todo_lines ! (
@@ -752,7 +752,7 @@ fn undo_redo_modify_single_index_end() {
752
752
#[ test]
753
753
fn undo_redo_modify_single_index_middle ( ) {
754
754
let mut history = History :: new ( 10 ) ;
755
- history. record ( HistoryItem :: new_modify ( 2 , 2 , vec ! [ Line :: new ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
755
+ history. record ( HistoryItem :: new_modify ( 2 , 2 , vec ! [ Line :: parse ( "drop xxx cx" ) . unwrap( ) ] ) ) ;
756
756
let mut lines = create_lines ( ) ;
757
757
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 2 , 2 ) ) ;
758
758
assert_todo_lines ! (
@@ -778,9 +778,9 @@ fn undo_redo_modify_single_index_middle() {
778
778
fn undo_redo_modify_range_down_index_start ( ) {
779
779
let mut history = History :: new ( 10 ) ;
780
780
history. record ( HistoryItem :: new_modify ( 0 , 2 , vec ! [
781
- Line :: new ( "drop xx1 c1" ) . unwrap( ) ,
782
- Line :: new ( "drop xx2 c2" ) . unwrap( ) ,
783
- Line :: new ( "drop xx3 c3" ) . unwrap( ) ,
781
+ Line :: parse ( "drop xx1 c1" ) . unwrap( ) ,
782
+ Line :: parse ( "drop xx2 c2" ) . unwrap( ) ,
783
+ Line :: parse ( "drop xx3 c3" ) . unwrap( ) ,
784
784
] ) ) ;
785
785
let mut lines = create_lines ( ) ;
786
786
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 0 , 2 ) ) ;
@@ -807,9 +807,9 @@ fn undo_redo_modify_range_down_index_start() {
807
807
fn undo_redo_modify_range_down_index_end ( ) {
808
808
let mut history = History :: new ( 10 ) ;
809
809
history. record ( HistoryItem :: new_modify ( 2 , 4 , vec ! [
810
- Line :: new ( "drop xx1 c1" ) . unwrap( ) ,
811
- Line :: new ( "drop xx2 c2" ) . unwrap( ) ,
812
- Line :: new ( "drop xx3 c3" ) . unwrap( ) ,
810
+ Line :: parse ( "drop xx1 c1" ) . unwrap( ) ,
811
+ Line :: parse ( "drop xx2 c2" ) . unwrap( ) ,
812
+ Line :: parse ( "drop xx3 c3" ) . unwrap( ) ,
813
813
] ) ) ;
814
814
let mut lines = create_lines ( ) ;
815
815
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 2 , 4 ) ) ;
@@ -836,9 +836,9 @@ fn undo_redo_modify_range_down_index_end() {
836
836
fn undo_redo_modify_range_up_index_start ( ) {
837
837
let mut history = History :: new ( 10 ) ;
838
838
history. record ( HistoryItem :: new_modify ( 2 , 0 , vec ! [
839
- Line :: new ( "drop xx1 c1" ) . unwrap( ) ,
840
- Line :: new ( "drop xx2 c2" ) . unwrap( ) ,
841
- Line :: new ( "drop xx3 c3" ) . unwrap( ) ,
839
+ Line :: parse ( "drop xx1 c1" ) . unwrap( ) ,
840
+ Line :: parse ( "drop xx2 c2" ) . unwrap( ) ,
841
+ Line :: parse ( "drop xx3 c3" ) . unwrap( ) ,
842
842
] ) ) ;
843
843
let mut lines = create_lines ( ) ;
844
844
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 2 , 0 ) ) ;
@@ -865,9 +865,9 @@ fn undo_redo_modify_range_up_index_start() {
865
865
fn undo_redo_modify_range_up_index_end ( ) {
866
866
let mut history = History :: new ( 10 ) ;
867
867
history. record ( HistoryItem :: new_modify ( 4 , 2 , vec ! [
868
- Line :: new ( "drop xx1 c1" ) . unwrap( ) ,
869
- Line :: new ( "drop xx2 c2" ) . unwrap( ) ,
870
- Line :: new ( "drop xx3 c3" ) . unwrap( ) ,
868
+ Line :: parse ( "drop xx1 c1" ) . unwrap( ) ,
869
+ Line :: parse ( "drop xx2 c2" ) . unwrap( ) ,
870
+ Line :: parse ( "drop xx3 c3" ) . unwrap( ) ,
871
871
] ) ) ;
872
872
let mut lines = create_lines ( ) ;
873
873
assert_some_eq ! ( history. undo( & mut lines) , ( Operation :: Modify , 4 , 2 ) ) ;
0 commit comments