leetcode/tests/s0008_string_to_integer.cpp

25 lines
466 B
C++
Raw Normal View History

2022-11-02 14:02:42 +00:00
#include "s0008_string_to_integer.hpp"
#include <gtest/gtest.h>
TEST(Problem8, Case1) {
string i = std::string("42");
int o = 42;
2022-11-30 10:20:36 +00:00
S0008 solution;
2022-11-02 14:02:42 +00:00
EXPECT_EQ(solution.myAtoi(i), o);
}
TEST(Problem8, Case2) {
string i = std::string(" -42");
int o = -42;
2022-11-30 10:20:36 +00:00
S0008 solution;
2022-11-02 14:02:42 +00:00
EXPECT_EQ(solution.myAtoi(i), o);
}
TEST(Problem8, Case3) {
string i = std::string("4193 with words");
int o = 4193;
2022-11-30 10:20:36 +00:00
S0008 solution;
2022-11-02 14:02:42 +00:00
EXPECT_EQ(solution.myAtoi(i), o);
}