root/lang/objective-cplusplus/i3/trunk/src/Test1.cpp @ 34947

Revision 34947, 4.6 kB (checked in by saturday06, 5 years ago)

usakotsu

Line 
1#include <PrecompiledHeaders.h>
2#include "Common.h"
3#include "Mediator.h"
4#include <boost/algorithm/string.hpp>
5#include <algorithm>
6#include <boost/range.hpp>
7#include <mil/MscCrt.h>
8
9#include <quicktest/quicktest.h>
10
11using namespace std;
12using namespace boost;
13
14namespace ns_intrusrangaaaaaaaaa {
15//using namespace boost::intrusive;
16//
17////This is a base hook
18//class MyClass : public slist_base_hook<>
19//{
20//    int int_;
21//
22//public:
23//
24//    MyClass(int i)
25//            :  int_(i)
26//    {}
27//};
28//
29////Define an slist that will store MyClass using the public base hook
30//typedef slist<MyClass, constant_time_size<false> > BaseList;
31//
32}
33//
34//QT_TEST(intrusrangeaaa)
35//{
36//    using namespace ns_intrusrangaaaaaaaaa;
37//    typedef std::vector<MyClass>::iterator VectIt;
38//    typedef std::vector<MyClass>::reverse_iterator VectRit;
39//
40//    //Create several MyClass objects, each one with a different value
41//    std::vector<MyClass> values;
42//    for (int i = 0; i < 100; ++i)  values.push_back(MyClass(i));
43//
44//    BaseList baselist;
45//
46//    //Now insert them in the reverse order in the base hook list
47//    for (VectIt it(values.begin()), itend(values.end()); it != itend; ++it)
48//        baselist.push_front(*it);
49//
50//    //Now test lists
51//    {
52//        BaseList::iterator bit(baselist.begin()), bitend(baselist.end());
53//
54//        VectRit rit(values.rbegin()), ritend(values.rend());
55//        VectIt  it(values.begin()), itend(values.end());
56//
57//        //Test the objects inserted in the base hook list
58//        for (; rit != ritend; ++rit, ++bit)
59//        {
60//            QT_CHECK(&*bit == &*rit);
61//        }
62//
63//    }
64//
65//    return;
66//}
67
68
69QT_TEST(rangeaaa) {
70//    char a[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
71//    char b[] = { 0x03, 0x04 };
72//    char* foo = std::search(boost::begin(a), boost::end(a),
73//                            boost::begin(b), boost::end(b));
74#undef printf
75//    printf("%d %d %d %d\n", foo[0], foo[1], foo[2], foo[3]);
76}
77
78QT_TEST(test_sgrin) {
79    //char before_buffer[] = {0,1,2,3,4,5,6,7,8,9};
80    //boost::array<char, 5> data = {{}};
81    //char after_buffer[] = {9,8,7,6,5,4,3,2,1,0};
82    char foo[2];
83    char* bar = strdup("foobarbaz");
84//    QT_CHECK(strcpy_s(foo, bar) == ERANGE);
85    free(bar);
86
87}
88
89
90#if defined(UNICODE) || defined(_UNICODE)
91
92QT_TEST(test_gettext) {
93    const char* buf = (const char*)wgettext("ABCDE");
94    QT_CHECK(buf[0] == 0x41);
95    QT_CHECK(buf[1] == 0);
96    QT_CHECK(buf[2] == 0x42);
97    QT_CHECK(buf[3] == 0);
98    QT_CHECK(buf[4] == 0x43);
99    QT_CHECK(buf[5] == 0);
100    QT_CHECK(buf[6] == 0x44);
101    QT_CHECK(buf[7] == 0);
102    QT_CHECK(buf[8] == 0x45);
103    QT_CHECK(buf[9] == 0);
104    QT_CHECK(buf[10] == 0);
105    QT_CHECK(buf[11] == 0);
106}
107
108#endif
109
110#ifdef ENABLE_NLS
111
112QT_TEST(gettextaaaooaaa) {
113    using namespace std;
114
115        bool result = false;
116#if defined(_UNICODE) && defined(UNICODE)
117#define JA_ENCODING ".UTF-16LE"
118    WCHAR hello_world_ja[] = {
119        0x4E16, 0x754C, 0x3088, 0x002C,
120        0x0020, 0x3053, 0x3093, 0x306B,
121        0x3061, 0x306F, 0x0021, 0x0000,
122    };
123#else
124#define JA_ENCODING ".Shift_JIS"
125    CHAR hello_world_ja[] = {
126        0x90, 0xA2, 0x8A, 0x45, 0x82, 0xE6, 0x2C,
127        0x20, 0x82, 0xB1, 0x82, 0xF1, 0x82, 0xC9,
128        0x82, 0xBF, 0x82, 0xCD, 0x21, 0x00,
129    };
130#endif
131
132    int argc = 0;
133    char** argv = NULL;
134
135    QT_CHECK(!init_os_global_data(argc, argv));
136    QT_CHECK(!init_gui_global_data(argc, argv));
137
138    basic_string<TCHAR> got;
139#ifndef __CYGWIN__
140    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "en"), -1);
141    got = (const TCHAR*)_("Hello, world!");
142        result = got == _T("Hello, world!");
143    QT_CHECK(result);
144
145    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "ja" JA_ENCODING), -1);
146    got = (const TCHAR*)_("Hello, world!");
147        result = got == hello_world_ja;
148    QT_CHECK(result);
149
150    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "de"), -1);
151    got = (const TCHAR*)_("Hello, world!");
152        result = got == _T("Hallo, Welt!");
153    QT_CHECK(result);
154
155    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "ja" JA_ENCODING), -1);
156    got = (const TCHAR*)_("Hello, world!");
157        result = got == hello_world_ja;
158    QT_CHECK(result);
159
160    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "en"), -1);
161    got = (const TCHAR*)_("Hello, world!");
162        result = got == _T("Hello, world!");
163    QT_CHECK(result);
164
165    QT_CHECK_NOT_EQUAL(my_setenv("LANGUAGE", "de"), -1);
166    got = (const TCHAR*)_("Hello, world!");
167        result = got == _T("Hallo, Welt!");
168    QT_CHECK(result);
169#endif
170}
171
172#endif
173
Note: See TracBrowser for help on using the browser.