1 /* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
28 #include "eina_suite.h"
31 static const Eina_Unicode TEST0[] = {'t', 'e', 's', 't', '/', '0', 0};
32 static const Eina_Unicode TEST1[] = {'t', 'e', 's', 't', '/', '1', 0};
34 START_TEST(eina_ustringshare_simple)
36 const Eina_Unicode *t0;
37 const Eina_Unicode *t1;
41 t0 = eina_ustringshare_add(TEST0);
42 t1 = eina_ustringshare_add(TEST1);
46 fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
47 fail_if(eina_unicode_strcmp(t1, TEST1) != 0);
48 fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
49 fail_if((int)eina_unicode_strlen(TEST1) != eina_ustringshare_strlen(t1));
51 t0 = eina_ustringshare_ref(t0);
53 fail_if((int)strlen((char*)TEST0) != eina_stringshare_strlen((const char*)t0));
55 eina_ustringshare_del(t0);
56 eina_ustringshare_del(t0);
57 eina_ustringshare_del(t1);
64 START_TEST(eina_ustringshare_test_share)
66 const Eina_Unicode *t0;
67 const Eina_Unicode *t1;
71 t0 = eina_ustringshare_add(TEST0);
72 t1 = eina_ustringshare_add(TEST0);
76 fail_if(eina_unicode_strcmp(t0, TEST0) != 0);
77 fail_if(eina_unicode_strcmp(t1, TEST0) != 0);
79 fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t0));
80 fail_if((int)eina_unicode_strlen(TEST0) != eina_ustringshare_strlen(t1));
82 eina_ustringshare_del(t0);
83 eina_ustringshare_del(t1);
89 START_TEST(eina_ustringshare_putstuff)
91 const Eina_Unicode *tmp;
96 for (i = 10000; i > 0; --i)
98 Eina_Unicode string_[] = {'s', 't', 'r', 'i', 'n', 'g', '_', 0};
99 Eina_Unicode build[64];
100 eina_unicode_strcpy(build, string_);
104 tmp = eina_ustringshare_add(build);
105 fail_if(tmp != eina_ustringshare_add(build));
106 fail_if((int)eina_unicode_strlen(build) != eina_ustringshare_strlen(tmp));
114 eina_test_ustringshare(TCase *tc)
116 tcase_add_test(tc, eina_ustringshare_simple);
117 tcase_add_test(tc, eina_ustringshare_test_share);
118 tcase_add_test(tc, eina_ustringshare_putstuff);