Re #8356. Avoid memory leak in test.

By using a shared_array instead of a bare C dynamically-allocated array.
Re #8356. Fix memory leaks in tests.

By not allocating objects on the heap for no good reason.
Re #8356. Re #8356. Fix memory leaks in tests.

By calling delete as appropriate on heap allocated objects.
Re #8356. Fix memory leaks in tests.

By a combination of creating objects on the stack instead of the heap and
calling delete where still appropriate.
Merge branch 'bugfix/8356_geometry_test_memory_leaks' into develop