tested triangle function