<commit_before>// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/string_ordinal.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

TEST(StringOrdinalTest, IsValid) {
  EXPECT_TRUE(StringOrdinal("b").IsValid());
  EXPECT_TRUE(StringOrdinal("ab").IsValid());

  EXPECT_FALSE(StringOrdinal("aa").IsValid());
  EXPECT_FALSE(StringOrdinal().IsValid());
}

TEST(StringOrdinalTest, LessThan) {
  StringOrdinal small("b");
  StringOrdinal middle("n");
  StringOrdinal big("z");

  EXPECT_TRUE(small.LessThan(middle));
  EXPECT_TRUE(small.LessThan(big));
  EXPECT_TRUE(middle.LessThan(big));

  EXPECT_FALSE(big.LessThan(small));
  EXPECT_FALSE(big.LessThan(middle));
  EXPECT_FALSE(middle.LessThan(small));
}

// Tests the CreateBetween StringOrdinal function by calling
// on the small_value with the large_value as the  parameter and
// vice-versa.
void TestCreateBetween(StringOrdinal small_value,
                       StringOrdinal large_value,
                       const std::string& expected_result) {
  StringOrdinal result = small_value.CreateBetween(large_value);
  EXPECT_EQ(expected_result, result.ToString());

  result = large_value.CreateBetween(small_value);
  EXPECT_EQ(expected_result, result.ToString());<commit_msg>On Windows, if PCH is turned on then there is a macro named small (Thanks hbono for pointing it out). That collides with the varialbe name in string_ordinal_unittest.cc Review URL: http://codereview.chromium.org/8465005<commit_after>// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/string_ordinal.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

TEST(StringOrdinalTest, IsValid) {
  EXPECT_TRUE(StringOrdinal("b").IsValid());
  EXPECT_TRUE(StringOrdinal("ab").IsValid());

  EXPECT_FALSE(StringOrdinal("aa").IsValid());
  EXPECT_FALSE(StringOrdinal().IsValid());
}

TEST(StringOrdinalTest, LessThan) {
  StringOrdinal small_value("b");
  StringOrdinal middle_value("n");
  StringOrdinal big_value("z");

  EXPECT_TRUE(small_value.LessThan(middle_value));
  EXPECT_TRUE(small_value.LessThan(big_value));
  EXPECT_TRUE(middle_value.LessThan(big_value));

  EXPECT_FALSE(big_value.LessThan(small_value));
  EXPECT_FALSE(big_value.LessThan(middle_value));
  EXPECT_FALSE(middle_value.LessThan(small_value));
}

// Tests the CreateBetween StringOrdinal function by calling
// on the small_value with the large_value as the  parameter and
// vice-versa.
void TestCreateBetween(StringOrdinal small_value,
                       StringOrdinal large_value,
                       const std::string& expected_result) {
  StringOrdinal result = small_value.CreateBetween(large_value);
  EXPECT_EQ(expected_result, result.ToString());

  result = large_value.CreateBetween(small_value);
  EXPECT_EQ(expected_result, result.ToString());
{'fraction_non_alphanumeric': 0.11400651465798045, 'fraction_numerical': 0.004885993485342019, 'mean_word_length': 5.142, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '355050', 'n_tokens_mistral': 953, 'n_tokens_neox': 940, 'n_words': 207}