Added the triangle function and assoicated unit tests