예제 #1
0
// Clamping with zero diff should return the center.
TEST_F(AngleTests, ClampWithZeroDiff) {
  const Angle a(-kPi + 1.1f);
  const Angle center(kPi - 2.1f);
  const Angle max_diff(0.0f);
  // This tests a negative number clamped to the range.
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(), center.ToRadians());
}
예제 #2
0
// Clamping a value that's below the range should clamp to the bottom boundary.
TEST_F(AngleTests, ClampBelow) {
  const Angle a(-kHalfPi - 0.2f);
  const Angle center(-kHalfPi);
  const Angle max_diff(0.1f);
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(),
                  (center - max_diff).ToRadians());
}
예제 #3
0
// Clamping a value that's above the range should clamp to the top boundary.
TEST_F(AngleTests, ClampAbove) {
  const Angle a(kHalfPi + 0.2f);
  const Angle center(kHalfPi);
  const Angle max_diff(0.1f);
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(),
                  (center + max_diff).ToRadians());
}
예제 #4
0
// Clamping to a range that strattles pi should wrap to the boundary that's
// closest under modular arithmetic.
TEST_F(AngleTests, ClampModularAtNegativeCenterNegativeAngle) {
  const Angle a(-kPi + 1.1f);
  const Angle center(kMinUniqueAngle);
  const Angle max_diff(0.1f);
  // This tests a negative number clamped to the range.
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(),
                  (center + max_diff).ToRadians());
}
예제 #5
0
// Clamping to a range that strattles pi should wrap to the boundary that's
// closest under modular arithmetic.
TEST_F(AngleTests, ClampModularAtPositiveCenterPositiveAngle) {
  const Angle a(kPi - 0.2f);
  const Angle center(kPi);
  const Angle max_diff(0.1f);
  // This tests a positive number clamped to the range.
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(),
                  (center - max_diff).ToRadians());
}
예제 #6
0
// Clamping to a range that strattles pi should wrap to the boundary that's
// closest under modular arithmetic.
TEST_F(AngleTests, ClampModularAtNegativeCenterPositiveAngle) {
  const Angle a(kPi - 0.2f);
  const Angle center(kMinUniqueAngle);
  const Angle max_diff(0.1f);
  // This tests a positive number clamped to a range centered about a negative
  // number.
  EXPECT_FLOAT_EQ(a.Clamp(center, max_diff).ToRadians(),
                  (center - max_diff).ToRadians());
}