efl

Форк
0
/
eina_cxx_test_stringshare.cc 
69 строк · 1.8 Кб
1
/*
2
 * Copyright 2019 by its authors. See AUTHORS.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
#ifdef HAVE_CONFIG_H
18
# include <config.h>
19
#endif
20

21
#include <functional>
22

23
#include <Eina.hh>
24

25
#include "eina_cxx_suite.h"
26

27
EFL_START_TEST(eina_cxx_stringshare_constructors)
28
{
29
  efl::eina::eina_init eina_init;
30

31
  efl::eina::stringshare string1;
32
  ck_assert(string1.empty());
33

34
  efl::eina::stringshare string2("string");
35
  ck_assert(string2.size() == 6);
36
  ck_assert(string2 == "string");
37

38
  efl::eina::stringshare string3(string2);
39
  ck_assert(string2 == string3);
40

41
  efl::eina::stringshare string4(string3.begin(), string3.end());
42
  ck_assert(string2 == string3);
43
}
44
EFL_END_TEST
45

46
EFL_START_TEST(eina_cxx_stringshare_iterators)
47
{
48
  efl::eina::eina_init eina_init;
49

50
  const char str[] = "string";
51
  const char rstr[] = "gnirts";
52

53
  efl::eina::stringshare string(str);
54
  ck_assert(string.size() == 6);
55
  ck_assert(string == str);
56

57
  ck_assert(std::equal(string.begin(), string.end(), str));
58
  ck_assert(std::equal(string.rbegin(), string.rend(), rstr));
59
  ck_assert(std::equal(string.cbegin(), string.cend(), str));
60
  ck_assert(std::equal(string.crbegin(), string.crend(), rstr));
61
}
62
EFL_END_TEST
63

64
void
65
eina_test_stringshare(TCase *tc)
66
{
67
  tcase_add_test(tc, eina_cxx_stringshare_constructors);
68
  tcase_add_test(tc, eina_cxx_stringshare_iterators);
69
}
70

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.