leetcode/tests/jianzhi_offer/string_test.cpp
2023-05-25 10:20:40 +08:00

27 lines
699 B
C++

#include "gtest/gtest.h"
#include "jianzhi_offer.h"
TEST(ReplaceSpaceTest, BasicAssertions) {
std::string input = "We are happy.";
std::string expected = "We%20are%20happy.";
yaha::String s;
ASSERT_EQ(expected, s.replace_space(input));
}
TEST(IsNumberTest, BasicAssertions) {
yaha::String s;
ASSERT_TRUE(s.is_number("0"));
ASSERT_TRUE(s.is_number(" .1 "));
ASSERT_FALSE(s.is_number("."));
ASSERT_FALSE(s.is_number("e"));
ASSERT_FALSE(s.is_number("e9"));
}
TEST(ReverseLeftWords, BasicAssertions) {
yaha::String s;
ASSERT_EQ("cdefgab", s.reverse_left_words("abcdefg", 2));
ASSERT_EQ("umghlrlose", s.reverse_left_words("lrloseumgh", 6));
}