ScopedValueTest.cpp 845 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AtomCore/Utils/ScopedValue.h>
  9. #include <AzCore/UnitTest/TestTypes.h>
  10. namespace UnitTest
  11. {
  12. TEST(ScopedValueTest, TestBoolValue)
  13. {
  14. bool localValue = false;
  15. {
  16. AZ::ScopedValue<bool> scopedValue(&localValue, true, false);
  17. EXPECT_EQ(true, localValue);
  18. }
  19. EXPECT_EQ(false, localValue);
  20. }
  21. TEST(ScopedValueTest, TestIntValue)
  22. {
  23. int localValue = 0;
  24. {
  25. AZ::ScopedValue<int> scopedValue(&localValue, 1, 2);
  26. EXPECT_EQ(1, localValue);
  27. }
  28. EXPECT_EQ(2, localValue);
  29. }
  30. }