test function for random pattern generator