Allocation inside of this test is probably not a great idea performance wise. It's very easy for the allocator to become a bottleneck if you are repeatedly calling this function.