コード例 #1
0
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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
ファイル: angle_test.cpp プロジェクト: 80245089/pienoon
// 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());
}