MCPcopy Create free account
hub / github.com/Stanford-Trinity/ARTEMIS / test_parse_patch

Function test_parse_patch

codex-rs/apply-patch/src/parser.rs:430–558  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

428
429#[test]
430fn test_parse_patch() {
431 assert_eq!(
432 parse_patch_text("bad", ParseMode::Strict),
433 Err(InvalidPatchError(
434 "The first line of the patch must be '*** Begin Patch'".to_string()
435 ))
436 );
437 assert_eq!(
438 parse_patch_text("*** Begin Patch\nbad", ParseMode::Strict),
439 Err(InvalidPatchError(
440 "The last line of the patch must be '*** End Patch'".to_string()
441 ))
442 );
443 assert_eq!(
444 parse_patch_text(
445 "*** Begin Patch\n\
446 *** Update File: test.py\n\
447 *** End Patch",
448 ParseMode::Strict
449 ),
450 Err(InvalidHunkError {
451 message: "Update file hunk for path 'test.py' is empty".to_string(),
452 line_number: 2,
453 })
454 );
455 assert_eq!(
456 parse_patch_text(
457 "*** Begin Patch\n\
458 *** End Patch",
459 ParseMode::Strict
460 )
461 .unwrap()
462 .hunks,
463 Vec::new()
464 );
465 assert_eq!(
466 parse_patch_text(
467 "*** Begin Patch\n\
468 *** Add File: path/add.py\n\
469 +abc\n\
470 +def\n\
471 *** Delete File: path/delete.py\n\
472 *** Update File: path/update.py\n\
473 *** Move to: path/update2.py\n\
474 @@ def f():\n\
475 - pass\n\
476 + return 123\n\
477 *** End Patch",
478 ParseMode::Strict
479 )
480 .unwrap()
481 .hunks,
482 vec![
483 AddFile {
484 path: PathBuf::from("path/add.py"),
485 contents: "abc\ndef\n".to_string()
486 },
487 DeleteFile {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected