Fuzz tests for copying and pasting

Captain's Log: Stardate 77836.9

The copy/paste/duplicate/import machinery now has some really solid tests, and works pretty nicely.

The tests are important because pasting is a little bit more complex than one might expect. There are a bunch of edge cases having to do with links. For example, if you copy a body and a link with one end attached to it, the paste code needs to create a new link that's attached to the copied body on one end, and a not-copied body on the other end. There's also some complexity around MIDI and Host Parameter routes, and making sure that the new entities are hooked up like the user would expect. And then of course there's the logic for finding a good empty spot to put the new entities so that they don't overlap with existing ones.

I wrote out some regular straightforward unit tests, but also as usual created a fuzz test. It creates random presets, selects random subsets of entities, copies and pastes them, and then checks a bunch of invariants, like "the new entities have the same parameters as the old ones," "the links are hooked up correctly," etc. It only takes a second or two to do this 10,000 times. This gives me a lot of confidence. And the best part is that as I add entities, parameters, etc in the future, the test uses the common fuzz infrastructure so the test will automatically include and test all the new stuff.


© 2024 Anukari LLC, All Rights Reserved
Contact Us|Legal