summaryrefslogtreecommitdiff
path: root/src/tests/eina_cxx/eina_cxx_test_stringshare.cc
blob: d10ad362e3c1f7013dff5ec65dee2f630d7c6561 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "Eina.hh"

#include <algorithm>
#include <functional>

#include <check.h>

START_TEST(eina_cxx_stringshare_constructors)
{
  efl::eina::eina_init eina_init;

  efl::eina::stringshare string1;
  ck_assert(string1.empty());

  efl::eina::stringshare string2("string");
  ck_assert(string2.size() == 6);
  ck_assert(string2 == "string");

  efl::eina::stringshare string3(string2);
  ck_assert(string2 == string3);

  efl::eina::stringshare string4(string3.begin(), string3.end());
  ck_assert(string2 == string3);
}
END_TEST

START_TEST(eina_cxx_stringshare_iterators)
{
  efl::eina::eina_init eina_init;

  const char str[] = "string";
  const char rstr[] = "gnirts";

  efl::eina::stringshare string(str);
  ck_assert(string.size() == 6);
  ck_assert(string == str);

  ck_assert(std::equal(string.begin(), string.end(), str));
  ck_assert(std::equal(string.rbegin(), string.rend(), rstr));
  ck_assert(std::equal(string.cbegin(), string.cend(), str));
  ck_assert(std::equal(string.crbegin(), string.crend(), rstr));
}
END_TEST

void
eina_test_stringshare(TCase *tc)
{
  tcase_add_test(tc, eina_cxx_stringshare_constructors);
  tcase_add_test(tc, eina_cxx_stringshare_iterators);
}