(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func TestApplyBinaryFragment(t *testing.T) { |
| 80 | tests := map[string]applyTest{ |
| 81 | "literalCreate": {Files: getApplyFiles("bin_fragment_literal_create")}, |
| 82 | "literalModify": {Files: getApplyFiles("bin_fragment_literal_modify")}, |
| 83 | "deltaModify": {Files: getApplyFiles("bin_fragment_delta_modify")}, |
| 84 | "deltaModifyLarge": {Files: getApplyFiles("bin_fragment_delta_modify_large")}, |
| 85 | |
| 86 | "errorIncompleteAdd": { |
| 87 | Files: applyFiles{ |
| 88 | Src: "bin_fragment_delta_error.src", |
| 89 | Patch: "bin_fragment_delta_error_incomplete_add.patch", |
| 90 | }, |
| 91 | Err: "incomplete add", |
| 92 | }, |
| 93 | "errorIncompleteCopy": { |
| 94 | Files: applyFiles{ |
| 95 | Src: "bin_fragment_delta_error.src", |
| 96 | Patch: "bin_fragment_delta_error_incomplete_copy.patch", |
| 97 | }, |
| 98 | Err: "incomplete copy", |
| 99 | }, |
| 100 | "errorSrcSize": { |
| 101 | Files: applyFiles{ |
| 102 | Src: "bin_fragment_delta_error.src", |
| 103 | Patch: "bin_fragment_delta_error_src_size.patch", |
| 104 | }, |
| 105 | Err: &Conflict{}, |
| 106 | }, |
| 107 | "errorDstSize": { |
| 108 | Files: applyFiles{ |
| 109 | Src: "bin_fragment_delta_error.src", |
| 110 | Patch: "bin_fragment_delta_error_dst_size.patch", |
| 111 | }, |
| 112 | Err: "insufficient or extra data", |
| 113 | }, |
| 114 | } |
| 115 | |
| 116 | for name, test := range tests { |
| 117 | t.Run(name, func(t *testing.T) { |
| 118 | test.run(t, func(dst io.Writer, src io.ReaderAt, file *File) error { |
| 119 | applier := NewBinaryApplier(dst, src) |
| 120 | return applier.ApplyFragment(file.BinaryFragment) |
| 121 | }) |
| 122 | }) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func TestApplyFile(t *testing.T) { |
| 127 | tests := map[string]applyTest{ |
nothing calls this directly
no test coverage detected