<commit_before>#include <primitiv/config.h>

#include <limits>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include <primitiv/string_utils.h>

using std::string;
using std::vector;

namespace primitiv {
namespace string_utils {

class StringUtilsTest : public testing::Test {};

TEST_F(StringUtilsTest, CheckJoin) {
  EXPECT_EQ("", join(vector<string> {}, ""));
  EXPECT_EQ("", join(vector<string> {}, "."));
  EXPECT_EQ("", join(vector<string> {}, "xxx"));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, ""));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, "."));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, "xxx"));
  EXPECT_EQ("foobar", join(vector<string> {"foo", "bar"}, ""));
  EXPECT_EQ("foo.bar", join(vector<string> {"foo", "bar"}, "."));
  EXPECT_EQ("fooxxxbar", join(vector<string> {"foo", "bar"}, "xxx"));
  EXPECT_EQ("foobarbaz", join(vector<string> {"foo", "bar", "baz"}, ""));
  EXPECT_EQ("foo.bar.baz", join(vector<string> {"foo", "bar", "baz"}, "."));
  EXPECT_EQ("fooxxxbarxxxbaz", join(vector<string> {"foo", "bar", "baz"}, "xxx"));
}

TEST_F(StringUtilsTest, CheckToString) {
  // Generated by std::to_string()
  EXPECT_EQ("0.000000", to_string(0.0f));
  EXPECT_EQ("1.000000", to_string(1.0f));
  EXPECT_EQ("1.100000", to_string(1.1f));
  EXPECT_EQ("1.234568", to_string(1.23456789f));
  EXPECT_EQ("340282346638528859811704183484516925440.000000",
            to_string(std::numeric_limits<float>::max())); // max float
  EXPECT_EQ("-1.000000", to_string(-1.0f));
  EXPECT_EQ("-1.100000", to_string(-1.1f));
  EXPECT_EQ("-12.345679", to_string(-12.3456789f));
  EXPECT_EQ("-340282346638528859811704183484516925440.000000",
            to_string(-std::numeric_limits<float>::max())); // min float
  EXPECT_EQ("0", to_string(0u));
  EXPECT_EQ("5", to_string(5u));
  EXPECT_EQ("123", to_string(123u));
  EXPECT_EQ("4294967295", to_string(0xffffffffu)); // max uint32_t
}

}  // namespace string_utils
}  // namespace primitiv<commit_msg>Use numeric_limits instead of actual numbers in a test<commit_after>#include <primitiv/config.h>

#include <limits>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include <primitiv/string_utils.h>

using std::string;
using std::vector;

namespace primitiv {
namespace string_utils {

class StringUtilsTest : public testing::Test {};

TEST_F(StringUtilsTest, CheckJoin) {
  EXPECT_EQ("", join(vector<string> {}, ""));
  EXPECT_EQ("", join(vector<string> {}, "."));
  EXPECT_EQ("", join(vector<string> {}, "xxx"));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, ""));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, "."));
  EXPECT_EQ("foo", join(vector<string> {"foo"}, "xxx"));
  EXPECT_EQ("foobar", join(vector<string> {"foo", "bar"}, ""));
  EXPECT_EQ("foo.bar", join(vector<string> {"foo", "bar"}, "."));
  EXPECT_EQ("fooxxxbar", join(vector<string> {"foo", "bar"}, "xxx"));
  EXPECT_EQ("foobarbaz", join(vector<string> {"foo", "bar", "baz"}, ""));
  EXPECT_EQ("foo.bar.baz", join(vector<string> {"foo", "bar", "baz"}, "."));
  EXPECT_EQ("fooxxxbarxxxbaz", join(vector<string> {"foo", "bar", "baz"}, "xxx"));
}

TEST_F(StringUtilsTest, CheckToString) {
  // Generated by std::to_string()
  EXPECT_EQ("0.000000", to_string(0.0f));
  EXPECT_EQ("1.000000", to_string(1.0f));
  EXPECT_EQ("1.100000", to_string(1.1f));
  EXPECT_EQ("1.234568", to_string(1.23456789f));
  EXPECT_EQ("340282346638528859811704183484516925440.000000",
            to_string(std::numeric_limits<float>::max()));
  EXPECT_EQ("-1.000000", to_string(-1.0f));
  EXPECT_EQ("-1.100000", to_string(-1.1f));
  EXPECT_EQ("-12.345679", to_string(-12.3456789f));
  EXPECT_EQ("-340282346638528859811704183484516925440.000000",
            to_string(-std::numeric_limits<float>::max()));
  EXPECT_EQ("0", to_string(0u));
  EXPECT_EQ("5", to_string(5u));
  EXPECT_EQ("123", to_string(123u));
  EXPECT_EQ("4294967295",
            to_string(std::numeric_limits<std::uint32_t>::max()));
}

}  // namespace string_utils
}  // namespace primitiv
{'fraction_non_alphanumeric': 0.22377972465581977, 'fraction_numerical': 0.095369211514393, 'mean_word_length': 6.239130434782608, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3680092', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1523, 'n_words': 227}