#include <gtest/gtest.h>
#include <iostream>
#include <string>

using namespace std;

/**
 * This file is generated by leetcode_add.py
 *
 * 171.
 *      Excel Sheet Column Number
 *
 * ––––––––––––––––––––––––––––– Description –––––––––––––––––––––––––––––
 *
 *   Given a string ‘columnTitle’ that represents the column title as
 *   appear in an Excel sheet, return “its corresponding column number”
 *   For
 *   A ->
 *   B ->
 *   C ->
 *   Z ->
 *   AA ->
 *   AB -> 28
 *
 * ––––––––––––––––––––––––––––– Constraints –––––––––––––––––––––––––––––
 *
 *   • ‘1 ≤ columnTitle.length ≤ 7’
 *   • ‘columnTitle’ consists only of uppercase English letters.
 *   • ‘columnTitle’ is in the range ‘['A', 'FXSHRXW']’ .
 *
 */

struct q171 : public ::testing::Test {
  // Leetcode answer here
  class Solution {
   public:
    int titleToNumber(string columnTitle) {
      int res = 0;
      for (const auto &c : columnTitle) {
        res = res * 26 + (c - 'A' + 1);
      }
      return res;
    }
  };

  class Solution *solution;
};

TEST_F(q171, sample_input01) {
  solution = new Solution();
  string columnTitle = "A";
  int exp = 1;
  int act = solution->titleToNumber(columnTitle);
  EXPECT_EQ(act, exp);
  delete solution;
}

TEST_F(q171, sample_input02) {
  solution = new Solution();
  string columnTitle = "AB";
  int exp = 28;
  int act = solution->titleToNumber(columnTitle);
  EXPECT_EQ(act, exp);
  delete solution;
}

TEST_F(q171, sample_input03) {
  solution = new Solution();
  string columnTitle = "ZY";
  int exp = 701;
  int act = solution->titleToNumber(columnTitle);
  EXPECT_EQ(act, exp);
  delete solution;
}