Ejemplo n.º 1
0
// Infinities should be able to be used in ranges.
TEST_F(RangeTests, Valid_Infinity) {
  const Range full(-kInf, kInf);
  EXPECT_TRUE(full.Valid());

  const Range neg_half(-kInf, 0.0f);
  EXPECT_TRUE(neg_half.Valid());

  const Range pos_half(-10.0, kInf);
  EXPECT_TRUE(pos_half.Valid());
}
Ejemplo n.º 2
0
TEST_F(RangeTests, Valid) {
  // When start <= end, the range is considered valid.
  const Range valid(0.0f, 1.0f);
  EXPECT_TRUE(valid.Valid());

  // When end > start, the range is considered invalid.
  const Range invalid(1.0f, -1.0f);
  EXPECT_TRUE(valid.Valid());

  // By default, the range should be initialized to something invalid.
  const Range invalid_default;
  EXPECT_FALSE(invalid_default.Valid());
}
Ejemplo n.º 3
0
// 4.  |-b---------|       ==>  return a
//        |-a---|
TEST_F(RangeTests, Intersect_ContainsFirst) {
  const Range a(2.0f, 3.0f);
  const Range b(-10.0f, 10.0f);
  const Range intersection = Range::Intersect(a, b);
  EXPECT_TRUE(intersection.Valid());
  EXPECT_EQ(intersection, a);
}
Ejemplo n.º 4
0
// 2.  |-b---|    |-a---|  ==>  return invalid
TEST_F(RangeTests, Intersect_DisjointAbove) {
  const Range a(2.0f, 3.0f);
  const Range b(0.0f, 1.0f);
  const Range intersection = Range::Intersect(a, b);
  EXPECT_FALSE(intersection.Valid());
  EXPECT_TRUE(intersection.Invert().Valid());
  EXPECT_EQ(intersection.Invert().Length(), 1.0f);
}