From e1ec72eab6d00b3ba38e5932bc88920f103b6e4a Mon Sep 17 00:00:00 2001 From: aunsane Date: Fri, 27 Apr 2018 21:33:17 +0300 Subject: Telegram: initial commit - tdlib moved to telegram dir --- libs/tdlib/td/tdutils/test/variant.cpp | 75 ---------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 libs/tdlib/td/tdutils/test/variant.cpp (limited to 'libs/tdlib/td/tdutils/test/variant.cpp') diff --git a/libs/tdlib/td/tdutils/test/variant.cpp b/libs/tdlib/td/tdutils/test/variant.cpp deleted file mode 100644 index 5c5e18d1d8..0000000000 --- a/libs/tdlib/td/tdutils/test/variant.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -#include "td/utils/Slice.h" -#include "td/utils/StringBuilder.h" -#include "td/utils/tests.h" -#include "td/utils/Variant.h" - -REGISTER_TESTS(variant); - -using namespace td; - -static const size_t BUF_SIZE = 1024 * 1024; -static char buf[BUF_SIZE], buf2[BUF_SIZE]; -static StringBuilder sb(MutableSlice(buf, BUF_SIZE - 1)); -static StringBuilder sb2(MutableSlice(buf2, BUF_SIZE - 1)); - -static std::string move_sb() { - auto res = sb.as_cslice().str(); - sb.clear(); - return res; -} - -static std::string name(int id) { - if (id == 1) { - return "A"; - } - if (id == 2) { - return "B"; - } - if (id == 3) { - return "C"; - } - return ""; -} - -template -class Class { - public: - Class() { - sb << "+" << name(id); - } - Class(const Class &) = delete; - Class &operator=(const Class &) = delete; - Class(Class &&) = delete; - Class &operator=(Class &&) = delete; - ~Class() { - sb << "-" << name(id); - } -}; - -using A = Class<1>; -using B = Class<2>; -using C = Class<3>; - -TEST(Variant, simple) { - { - Variant, std::unique_ptr, std::unique_ptr> abc; - ASSERT_STREQ("", sb.as_cslice()); - abc = std::make_unique(); - ASSERT_STREQ("+A", sb.as_cslice()); - sb.clear(); - abc = std::make_unique(); - ASSERT_STREQ("+B-A", sb.as_cslice()); - sb.clear(); - abc = std::make_unique(); - ASSERT_STREQ("+C-B", sb.as_cslice()); - sb.clear(); - } - ASSERT_STREQ("-C", move_sb()); - sb.clear(); -}; -- cgit v1.2.3