Skip to content

Commit

Permalink
added test cases for string count_chars
Browse files Browse the repository at this point in the history
  • Loading branch information
itzandroidtab committed Mar 23, 2024
1 parent 9e33692 commit ed47600
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions klib/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,14 @@ TEST_CASE("klib itoa", "[klib::string]") {
REQUIRE(std::string(buffer) == "false");
}

TEST_CASE("klib count_chars", "[klib::string::detail]") {
REQUIRE(klib::string::detail::count_chars(0) == 1);
REQUIRE(klib::string::detail::count_chars(10) == 2);
REQUIRE(klib::string::detail::count_chars(100) == 3);
REQUIRE(klib::string::detail::count_chars(99) == 2);
REQUIRE(klib::string::detail::count_chars<klib::base::BIN>(0b11) == 2);
REQUIRE(klib::string::detail::count_chars<klib::base::HEX>(0xff) == 2);
REQUIRE(klib::string::detail::count_chars<klib::base::OCT>(077) == 2);
}

// TODO: stoa

0 comments on commit ed47600

Please sign in to comment.