/* * Copyright 2026 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "rtc_base/numerics/safe_conversions.h" #include #include #include "test/gtest.h" namespace webrtc { TEST(SafeConversionsTest, SaturatedCastDoubleToInt64) { // Representable double in range. double val_in_range = 9223372036854774784.0; EXPECT_EQ(saturated_cast(val_in_range), 9223372036854774784LL); // Double that rounds to 2^63 (overflow). double val_overflow = 9223372036854775800.0; // Rounds to 9223372036854775808.0 EXPECT_EQ(saturated_cast(val_overflow), std::numeric_limits::max()); } } // namespace webrtc