Goodness-of-fit testing for regime-switching models