text: #include <gtest/gtest.h>
  #include <iostream>
  #include <vector>
  
  using namespace std;
  
  /**
   * This file is generated by leetcode_add.py
   *
   * 976.
   *      Largest Perimeter Triangle
   *
   * ––––––––––––––––––––––––––––– Description –––––––––––––––––––––––––––––
   *
   *   Given an integer array ‘nums’ , return “the largest perimeter of a
   *   triangle with a non-zero area, formed from three of these lengths” .
   *   If it is impossible to form any triangle of a non-zero area, return
   *   ‘0’ .
   *
   * ––––––––––––––––––––––––––––– Constraints –––––––––––––––––––––––––––––
   *
   *   • ‘3 ≤ nums.length ≤ 10⁴’
   *   • ‘1 ≤ nums[i] ≤ 10⁶’
   *
   */
  
  struct q976 : public ::testing::Test {
    // Leetcode answer here
    class Solution {
     private:
      int helper(vector<int> &nums, int i) {
        if (i + 2 >= nums.size()) {
          return 0;
        }
        int sum = nums[i] + nums[i + 1] + nums[i + 2];
  
        return max(nums[i    ] + nums[i + 1] > nums[i + 2] &&
                   nums[i + 1] + nums[i + 2] > nums[i    ] &&
                   nums[i    ] + nums[i + 2] > nums[i + 1] ? sum : 0,
                   helper(nums, i + 1));
      }
  
     public:
      int largestPerimeter(vector<int> &nums) {
        sort(nums.begin(), nums.end());
        
        return helper(nums, 0);
      }
    };
  
    class Solution *solution;
  };
  
  TEST_F(q976, sample_input01) {
    solution = new Solution();
    vector<int> nums = {2, 1, 2};
    int exp = 5;
    int act = solution->largestPerimeter(nums);
    EXPECT_EQ(act, exp);
    delete solution;
  }
  
  TEST_F(q976, sample_input02) {
    solution = new Solution();
    vector<int> nums = {1, 2, 1};
    int exp = 0;
    int act = solution->largestPerimeter(nums);
    EXPECT_EQ(act, exp);
    delete solution;
  }