wip(engine): transform table test literals bumped to edith 20, size asserts documented
Browse files at this commit5984e274c40bbae2705ab2f3c32f1f3eede3ae75Parent: 7ef56182 changed files +47 -42
- crates/engine/src/edith.rs +40 -40
- crates/engine/src/project.rs +7 -2
crates/engine/src/edith.rsmodified+40 -40
| @@ -1604,7 +1604,7 @@ mod tests { | |||
| 1604 | video 1 0 0 30 0 - - - fit 1000\n"; | 1604 | video 1 0 0 30 0 - - - fit 1000\n"; |
| 1605 | let old = parse(v9, &dir).expect("v9 still loads"); | 1605 | let old = parse(v9, &dir).expect("v9 still loads"); |
| 1606 | assert_eq!(old.subtitles, Vec::new()); | 1606 | assert_eq!(old.subtitles, Vec::new()); |
| 1607 | - assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 19\n")); | 1607 | + assert!(flat(&dir, &old.sources, &old.lanes, old.playhead).starts_with(b"edith 20\n")); |
| 1608 | // ...and the line itself is not a v9 line: a dialect may not be mixed. | 1608 | // ...and the line itself is not a v9 line: a dialect may not be mixed. |
| 1609 | let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir) | 1609 | let mixed = parse(b"edith 9\nsource 0 a.mp4\nsubtitle - subs.srt\n", &dir) |
| 1610 | .unwrap_err() | 1610 | .unwrap_err() |
| @@ -2082,10 +2082,10 @@ mod tests { | |||
| 2082 | let bytes = flat(&dir, &sources, &lanes, 12); | 2082 | let bytes = flat(&dir, &sources, &lanes, 12); |
| 2083 | assert_eq!( | 2083 | assert_eq!( |
| 2084 | String::from_utf8_lossy(&bytes), | 2084 | String::from_utf8_lossy(&bytes), |
| 2085 | - "edith 19\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 2085 | + "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2086 | source 2 /elsewhere/b.mp4\n\ | 2086 | source 2 /elsewhere/b.mp4\n\ |
| 2087 | - video 1 0 0 30 0 0 - - fit 1000 0 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0\n\ | 2087 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\ |
| 2088 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0\n", | 2088 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n", |
| 2089 | "the file under the project directory is written relative to it, \ | 2089 | "the file under the project directory is written relative to it, \ |
| 2090 | each with the audio stream it plays" | 2090 | each with the audio stream it plays" |
| 2091 | ); | 2091 | ); |
| @@ -2119,9 +2119,9 @@ mod tests { | |||
| 2119 | let bytes = flat(&dir, &sources, &lanes, 7); | 2119 | let bytes = flat(&dir, &sources, &lanes, 7); |
| 2120 | assert_eq!( | 2120 | assert_eq!( |
| 2121 | String::from_utf8_lossy(&bytes), | 2121 | String::from_utf8_lossy(&bytes), |
| 2122 | - "edith 19\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ | 2122 | + "edith 20\nplayhead 7\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2123 | - video 1 0 0 30 0 4 - - fit 1000 0 0 0\naudio 1\n\ | 2123 | + video 1 0 0 30 0 4 - - fit 1000 0 0 0 -\naudio 1\n\ |
| 2124 | - video 2 40 0 10 0 - - - fit 1000 0 0 0\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0\n", | 2124 | + video 2 40 0 10 0 - - - fit 1000 0 0 0 -\naudio 2 0 0 30 0 4 - - fit 1000 0 0 0 -\n", |
| 2125 | "an empty lane is a line of its own; everything else is its clips" | 2125 | "an empty lane is a line of its own; everything else is its clips" |
| 2126 | ); | 2126 | ); |
| 2127 | let back = parse(&bytes, &dir).expect("parse"); | 2127 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2239,12 +2239,12 @@ mod tests { | |||
| 2239 | let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); | 2239 | let bytes = emit(&dir, &sources, &lanes, &eq, &[], (1280, 720), 0); |
| 2240 | assert_eq!( | 2240 | assert_eq!( |
| 2241 | String::from_utf8_lossy(&bytes), | 2241 | String::from_utf8_lossy(&bytes), |
| 2242 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2242 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2243 | eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ | 2243 | eq 80.0:-3.0:0.707:ls 1000.0:4.5:1.0:pk\n\ |
| 2244 | eq 16777215.0:-0.1:3.918315e-39:hs\n\ | 2244 | eq 16777215.0:-0.1:3.918315e-39:hs\n\ |
| 2245 | eq\n\ | 2245 | eq\n\ |
| 2246 | - video 1 0 0 30 0 0 0 - fit 1000 0 0 0\nvideo 1 30 10 20 0 - 1 - fit 1000 0 0 0\n\ | 2246 | + video 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\nvideo 1 30 10 20 0 - 1 - fit 1000 0 0 0 -\n\ |
| 2247 | - audio 1 0 0 30 0 0 0 - fit 1000 0 0 0\naudio 1 30 0 10 0 - 2 - fit 1000 0 0 0\n", | 2247 | + audio 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\naudio 1 30 0 10 0 - 2 - fit 1000 0 0 0 -\n", |
| 2248 | "the table comes before the clips, and a clip names a line of it" | 2248 | "the table comes before the clips, and a clip names a line of it" |
| 2249 | ); | 2249 | ); |
| 2250 | 2250 | ||
| @@ -2355,12 +2355,12 @@ mod tests { | |||
| 2355 | let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); | 2355 | let bytes = emit(&dir, &sources, &lanes, &[], &color, (1280, 720), 0); |
| 2356 | assert_eq!( | 2356 | assert_eq!( |
| 2357 | String::from_utf8_lossy(&bytes), | 2357 | String::from_utf8_lossy(&bytes), |
| 2358 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2358 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2359 | color 0.1:1.2:0.9:-0.3\n\ | 2359 | color 0.1:1.2:0.9:-0.3\n\ |
| 2360 | color -1e-7:16777215.0:3.918315e-39:-0.0\n\ | 2360 | color -1e-7:16777215.0:3.918315e-39:-0.0\n\ |
| 2361 | color 0.0:1.0:1.0:0.0\n\ | 2361 | color 0.0:1.0:1.0:0.0\n\ |
| 2362 | - video 1 0 0 30 0 0 - 0 fit 1000 0 0 0\nvideo 1 30 10 20 0 - - 1 fit 1000 0 0 0\n\ | 2362 | + video 1 0 0 30 0 0 - 0 fit 1000 0 0 0 -\nvideo 1 30 10 20 0 - - 1 fit 1000 0 0 0 -\n\ |
| 2363 | - audio 1 0 0 30 0 0 - 0 fit 1000 0 0 0\naudio 1 30 0 10 0 - - 2 fit 1000 0 0 0\n", | 2363 | + audio 1 0 0 30 0 0 - 0 fit 1000 0 0 0 -\naudio 1 30 0 10 0 - - 2 fit 1000 0 0 0 -\n", |
| 2364 | "the table comes before the clips, and a clip names a line of it" | 2364 | "the table comes before the clips, and a clip names a line of it" |
| 2365 | ); | 2365 | ); |
| 2366 | 2366 | ||
| @@ -2420,9 +2420,9 @@ mod tests { | |||
| 2420 | (1280, 720), | 2420 | (1280, 720), |
| 2421 | old.playhead | 2421 | old.playhead |
| 2422 | )), | 2422 | )), |
| 2423 | - "edith 19\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2423 | + "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2424 | eq 80.0:-3.0:0.707:ls\n\ | 2424 | eq 80.0:-3.0:0.707:ls\n\ |
| 2425 | - video 1 0 0 30 0 0 0 - fit 1000 0 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0\n" | 2425 | + video 1 0 0 30 0 0 0 - fit 1000 0 0 0 -\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n" |
| 2426 | ); | 2426 | ); |
| 2427 | } | 2427 | } |
| 2428 | 2428 | ||
| @@ -2462,9 +2462,9 @@ mod tests { | |||
| 2462 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2462 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2463 | assert_eq!( | 2463 | assert_eq!( |
| 2464 | String::from_utf8_lossy(&bytes), | 2464 | String::from_utf8_lossy(&bytes), |
| 2465 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2465 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2466 | - video 1 0 0 30 0 - - - fit 2000 0 0 0\nvideo 1 15 30 40 0 - - - fit 250 0 0 0\n\ | 2466 | + video 1 0 0 30 0 - - - fit 2000 0 0 0 -\nvideo 1 15 30 40 0 - - - fit 250 0 0 0 -\n\ |
| 2467 | - audio 1 0 0 30 0 - - - fit 2000 0 0 0\n", | 2467 | + audio 1 0 0 30 0 - - - fit 2000 0 0 0 -\n", |
| 2468 | "the rate is the clip line's last field, in thousandths" | 2468 | "the rate is the clip line's last field, in thousandths" |
| 2469 | ); | 2469 | ); |
| 2470 | let back = parse(&bytes, &dir).expect("parse"); | 2470 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2491,8 +2491,8 @@ mod tests { | |||
| 2491 | (1280, 720), | 2491 | (1280, 720), |
| 2492 | old.playhead | 2492 | old.playhead |
| 2493 | )), | 2493 | )), |
| 2494 | - "edith 19\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2494 | + "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2495 | - video 1 0 0 30 0 0 - - fit 1000 0 0 0\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0\n" | 2495 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n" |
| 2496 | ); | 2496 | ); |
| 2497 | // A rate outside what the editor can set is a corrupt line, by name. | 2497 | // A rate outside what the editor can set is a corrupt line, by name. |
| 2498 | let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n"; | 2498 | let bad = b"edith 8\nsource 0 a.mp4\nvideo 1 0 0 30 0 - - - fit 9000\n"; |
| @@ -2540,8 +2540,8 @@ mod tests { | |||
| 2540 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2540 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2541 | assert_eq!( | 2541 | assert_eq!( |
| 2542 | String::from_utf8_lossy(&bytes), | 2542 | String::from_utf8_lossy(&bytes), |
| 2543 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2543 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2544 | - video 1 0 0 30 0 - - - fit 1000 5 7 0\n", | 2544 | + video 1 0 0 30 0 - - - fit 1000 5 7 0 -\n", |
| 2545 | "the fades are the clip line's last two fields" | 2545 | "the fades are the clip line's last two fields" |
| 2546 | ); | 2546 | ); |
| 2547 | let back = parse(&bytes, &dir).expect("parse"); | 2547 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2591,8 +2591,8 @@ mod tests { | |||
| 2591 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); | 2591 | let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); |
| 2592 | assert_eq!( | 2592 | assert_eq!( |
| 2593 | String::from_utf8_lossy(&bytes), | 2593 | String::from_utf8_lossy(&bytes), |
| 2594 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ | 2594 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2595 | - video 1 0 0 30 0 - - - fit 1000 0 0 9\n", | 2595 | + video 1 0 0 30 0 - - - fit 1000 0 0 9 -\n", |
| 2596 | "the dissolve is the clip line's own last field" | 2596 | "the dissolve is the clip line's own last field" |
| 2597 | ); | 2597 | ); |
| 2598 | let back = parse(&bytes, &dir).expect("parse"); | 2598 | let back = parse(&bytes, &dir).expect("parse"); |
| @@ -2643,10 +2643,10 @@ mod tests { | |||
| 2643 | ); | 2643 | ); |
| 2644 | assert_eq!( | 2644 | assert_eq!( |
| 2645 | String::from_utf8_lossy(&bytes), | 2645 | String::from_utf8_lossy(&bytes), |
| 2646 | - "edith 19\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ | 2646 | + "edith 20\nplayhead 0\nresolution 1280 720\nfps 23.976023976023978\n\ |
| 2647 | limiter -1.5 on\nsource 0 a.mp4\n\ | 2647 | limiter -1.5 on\nsource 0 a.mp4\n\ |
| 2648 | - video 1 0 0 30 0 - - - fit 1000 0 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0\n\ | 2648 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n\ |
| 2649 | - audio 2 0 0 30 0 - - - fit 1000 0 0 0\n\ | 2649 | + audio 2 0 0 30 0 - - - fit 1000 0 0 0 -\n\ |
| 2650 | gain audio 1 3.0\ngain audio 2 -6.5\n", | 2650 | gain audio 1 3.0\ngain audio 2 -6.5\n", |
| 2651 | "the mix is lines of its own, the gains after the lanes they name" | 2651 | "the mix is lines of its own, the gains after the lanes they name" |
| 2652 | ); | 2652 | ); |
| @@ -2675,8 +2675,8 @@ mod tests { | |||
| 2675 | (1280, 720), | 2675 | (1280, 720), |
| 2676 | old.playhead | 2676 | old.playhead |
| 2677 | )), | 2677 | )), |
| 2678 | - "edith 19\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ | 2678 | + "edith 20\nplayhead 3\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2679 | - video 1 0 0 30 0 - - - fit 1000 0 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0\n" | 2679 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n" |
| 2680 | ); | 2680 | ); |
| 2681 | 2681 | ||
| 2682 | // Each of the three refuses by name, on its own line. | 2682 | // Each of the three refuses by name, on its own line. |
| @@ -2839,10 +2839,10 @@ mod tests { | |||
| 2839 | assert!(old.eq.is_empty(), "nothing before v5 equalizes anything"); | 2839 | assert!(old.eq.is_empty(), "nothing before v5 equalizes anything"); |
| 2840 | assert_eq!( | 2840 | assert_eq!( |
| 2841 | String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)), | 2841 | String::from_utf8_lossy(&flat(&dir, &old.sources, &old.lanes, old.playhead)), |
| 2842 | - "edith 19\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 2842 | + "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2843 | source 2 /elsewhere/b.mp4\n\ | 2843 | source 2 /elsewhere/b.mp4\n\ |
| 2844 | - video 1 0 0 30 0 0 - - fit 1000 0 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0\n\ | 2844 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\ |
| 2845 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0\n" | 2845 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n" |
| 2846 | ); | 2846 | ); |
| 2847 | // An empty lane's line is still the whole of that lane, eq or no eq. | 2847 | // An empty lane's line is still the whole of that lane, eq or no eq. |
| 2848 | let empty = parse( | 2848 | let empty = parse( |
| @@ -2892,10 +2892,10 @@ mod tests { | |||
| 2892 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); | 2892 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); |
| 2893 | assert_eq!( | 2893 | assert_eq!( |
| 2894 | String::from_utf8_lossy(&v5), | 2894 | String::from_utf8_lossy(&v5), |
| 2895 | - "edith 19\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ | 2895 | + "edith 20\nplayhead 12\nresolution 1280 720\nsource 0 a.mp4\n\ |
| 2896 | source 0 /elsewhere/b.mp4\n\ | 2896 | source 0 /elsewhere/b.mp4\n\ |
| 2897 | - video 1 0 0 30 0 0 - - fit 1000 0 0 0\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0\n\ | 2897 | + video 1 0 0 30 0 0 - - fit 1000 0 0 0 -\nvideo 1 30 10 20 1 1 - - fit 1000 0 0 0 -\n\ |
| 2898 | - audio 1 0 0 30 0 0 - - fit 1000 0 0 0\n", | 2898 | + audio 1 0 0 30 0 0 - - fit 1000 0 0 0 -\n", |
| 2899 | "a re-saved v2 project differs only by its version, the lane \ | 2899 | "a re-saved v2 project differs only by its version, the lane \ |
| 2900 | numbers, the streams it always meant and an equalizer it has none of" | 2900 | numbers, the streams it always meant and an equalizer it has none of" |
| 2901 | ); | 2901 | ); |
| @@ -2924,7 +2924,7 @@ mod tests { | |||
| 2924 | // Saved again it is the current version, which round-trips to the | 2924 | // Saved again it is the current version, which round-trips to the |
| 2925 | // same document. | 2925 | // same document. |
| 2926 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); | 2926 | let v5 = flat(&dir, &back.sources, &back.lanes, back.playhead); |
| 2927 | - assert!(v5.starts_with(b"edith 19\n")); | 2927 | + assert!(v5.starts_with(b"edith 20\n")); |
| 2928 | let again = parse(&v5, &dir).expect("v5 parses"); | 2928 | let again = parse(&v5, &dir).expect("v5 parses"); |
| 2929 | assert_eq!(again.lanes, back.lanes); | 2929 | assert_eq!(again.lanes, back.lanes); |
| 2930 | // A dialect may not be mixed: lane lines under v1, `clip` under v2. | 2930 | // A dialect may not be mixed: lane lines under v1, `clip` under v2. |
| @@ -3035,8 +3035,8 @@ mod tests { | |||
| 3035 | let bytes = std::fs::read(&path).expect("read back"); | 3035 | let bytes = std::fs::read(&path).expect("read back"); |
| 3036 | assert_eq!( | 3036 | assert_eq!( |
| 3037 | String::from_utf8_lossy(&bytes), | 3037 | String::from_utf8_lossy(&bytes), |
| 3038 | - "edith 19\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ | 3038 | + "edith 20\nplayhead 0\nresolution 1280 720\nsource 1 a.mp4\n\ |
| 3039 | - video 1 0 0 30 0 - - - fit 1000 0 0 0\naudio 1 0 0 30 0 - - - fit 1000 0 0 0\n" | 3039 | + video 1 0 0 30 0 - - - fit 1000 0 0 0 -\naudio 1 0 0 30 0 - - - fit 1000 0 0 0 -\n" |
| 3040 | ); | 3040 | ); |
| 3041 | // Loading rejoins the *given* directory, so the file is reached by the | 3041 | // Loading rejoins the *given* directory, so the file is reached by the |
| 3042 | // way the project was opened -- the same file, through the link, still | 3042 | // way the project was opened -- the same file, through the link, still |
| @@ -3080,10 +3080,10 @@ mod tests { | |||
| 3080 | #[test] | 3080 | #[test] |
| 3081 | fn a_wrong_first_line_is_refused_by_name() { | 3081 | fn a_wrong_first_line_is_refused_by_name() { |
| 3082 | let dir = PathBuf::from("/proj"); | 3082 | let dir = PathBuf::from("/proj"); |
| 3083 | - let err = parse(b"edith 20\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) | 3083 | + let err = parse(b"edith 21\nsource 0 a.mp4\nvideo 0 0 5 0 -\n", &dir) |
| 3084 | .unwrap_err() | 3084 | .unwrap_err() |
| 3085 | .to_string(); | 3085 | .to_string(); |
| 3086 | - assert_eq!(err, "line 1: unsupported version 20"); | 3086 | + assert_eq!(err, "line 1: unsupported version 21"); |
| 3087 | for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] { | 3087 | for junk in [&b""[..], b"{}\n", b"source a.mp4\n"] { |
| 3088 | assert_eq!( | 3088 | assert_eq!( |
| 3089 | parse(junk, &dir).unwrap_err().to_string(), | 3089 | parse(junk, &dir).unwrap_err().to_string(), |
crates/engine/src/project.rsmodified+7 -2
| @@ -6748,6 +6748,9 @@ mod tests { | |||
| 6748 | /// 52 bytes of fields, but the struct's own alignment is 8 (from the | 6748 | /// 52 bytes of fields, but the struct's own alignment is 8 (from the |
| 6749 | /// `usize` source and the 8-byte `Option<u32>` link), so an odd number of | 6749 | /// `usize` source and the 8-byte `Option<u32>` link), so an odd number of |
| 6750 | /// words after it pads out to the next multiple of 8: 56 bytes total. | 6750 | /// words after it pads out to the next multiple of 8: 56 bytes total. |
| 6751 | + /// The transform index is a third `Option<u16>`, same reason as the eq and | ||
| 6752 | + /// colour ones before it -- it lands in bytes already spent on padding, so | ||
| 6753 | + /// the struct still costs 56. | ||
| 6751 | /// This is the assert that says so: a clip that grows a word grows every | 6754 | /// This is the assert that says so: a clip that grows a word grows every |
| 6752 | /// undo snapshot and every clipboard copy with it. | 6755 | /// undo snapshot and every clipboard copy with it. |
| 6753 | #[test] | 6756 | #[test] |
| @@ -8104,13 +8107,15 @@ mod tests { | |||
| 8104 | /// Not a claim about correctness but about cost: a clip is copied on every | 8107 | /// Not a claim about correctness but about cost: a clip is copied on every |
| 8105 | /// paste, every undo snapshot and every lane clone, so its size is worth | 8108 | /// paste, every undo snapshot and every lane clone, so its size is worth |
| 8106 | /// knowing. The eq index fit the padding a `Copy` clip already had; the | 8109 | /// knowing. The eq index fit the padding a `Copy` clip already had; the |
| 8107 | - /// colour one did not, and the struct grew a word. | 8110 | + /// colour one did not, and the struct grew a word. The transform index is |
| 8111 | + /// a third `Option<u16>`, and it fits the padding the fit policy and the | ||
| 8112 | + /// transition byte already left behind, so the struct did not grow again. | ||
| 8108 | #[test] | 8113 | #[test] |
| 8109 | fn a_clip_is_still_a_small_copy() { | 8114 | fn a_clip_is_still_a_small_copy() { |
| 8110 | assert_eq!( | 8115 | assert_eq!( |
| 8111 | std::mem::size_of::<Clip>(), | 8116 | std::mem::size_of::<Clip>(), |
| 8112 | 56, | 8117 | 56, |
| 8113 | - "Clip changed size -- 32 before the colour index, 40 before the fades, 48 after, 56 with the transition" | 8118 | + "Clip changed size -- 32 before the colour index, 40 before the fades, 48 after, 56 with the transition, still 56 with the transform index" |
| 8114 | ); | 8119 | ); |
| 8115 | } | 8120 | } |
| 8116 | 8121 | ||