code and unit test for detect triangle