A ternary detection test with applications to the sidelobe blanking problem