moved_ut.cpp 512 B

12345678910111213141516171819202122
  1. #include <library/cpp/testing/unittest/registar.h>
  2. #include "moved.h"
  3. Y_UNIT_TEST_SUITE(TMovedTest) {
  4. Y_UNIT_TEST(Simple) {
  5. TMoved<THolder<int>> h1(MakeHolder<int>(10));
  6. TMoved<THolder<int>> h2 = h1;
  7. UNIT_ASSERT(!*h1);
  8. UNIT_ASSERT(!!*h2);
  9. UNIT_ASSERT_VALUES_EQUAL(10, **h2);
  10. }
  11. void Foo(TMoved<THolder<int>> h) {
  12. UNIT_ASSERT_VALUES_EQUAL(11, **h);
  13. }
  14. Y_UNIT_TEST(PassToFunction) {
  15. THolder<int> h(new int(11));
  16. Foo(h);
  17. }
  18. }