root/lang/objective-cplusplus/i3/trunk/src/os-windows/OsTest2.cpp @ 34041

Revision 34041, 2.4 kB (checked in by saturday06, 5 years ago)

oajiofda

Line 
1#include <PrecompiledHeaders.h>
2#include <quicktest/quicktest.h>
3
4#include "Common.h"
5#include "ConfigFile.h"
6#include "Utf8ToUtf16Stream.h"
7
8#include <iostream>
9#include <fstream>
10
11#define WINDOWS_PATH_MAX_ELEMENTS 4000
12
13using namespace std;
14
15QT_TEST(bcooooiodefgffffh)
16{
17    //i3::Config config = i3::parse_config(_T("foo"));
18    // const TCHAR* foo = config.string_key;
19}
20
21#if 0
22
23QT_TEST(bcooooiodefgh)
24{
25    HMODULE cygwin1 = LoadLibrary(_T("d:\\cygwin\\bin\\cygwin1.dll"));
26    void (*cygwin1_cygwin_dll_init)() = (decltype(cygwin1_cygwin_dll_init))GetProcAddress(cygwin1, "cygwin_dll_init");
27    cygwin1_cygwin_dll_init();
28
29    int (*cygwin1_rmdir)(const char*)  = (decltype(cygwin1_rmdir))GetProcAddress(cygwin1, "rmdir");
30    int result = cygwin1_rmdir("/test");
31    FreeLibrary(cygwin1);
32}
33
34
35QT_TEST(bcoiodefgh)
36{
37    using namespace i3;
38    {
39        Utf8ToUtf16Stream test(stdout);
40    }
41
42    const char TEST_FILE[] = "test.txt";
43
44    { // ascii
45        const char TEST_DATA1[] = "foo";
46        const wchar_t TEST_DATAW1[] = L"foo";
47
48        FILE* f = fopen(TEST_FILE, "wb");
49        QT_CHECK(f);
50        {
51            Utf8ToUtf16Stream stream(f);
52            fprintf(stream.get(), TEST_DATA1);
53        }
54        fclose(f);
55
56        ifstream file(TEST_FILE, ifstream::binary);
57        char buf[1000] = {};
58        file.read(buf, _countof(buf));
59        wchar_t* wbuf = (wchar_t*)buf;
60        QT_CHECK(basic_string<wchar_t>((wchar_t*)buf) == TEST_DATAW1);
61    }
62    QT_CHECK(unlink(TEST_FILE) == 0);
63
64    { // unicode
65        extern const char* ptestdata_utf8;
66        extern const char* ptestdata_utf16le;
67
68        FILE* f = fopen(TEST_FILE, "wb");
69        QT_CHECK(f);
70        {
71            Utf8ToUtf16Stream stream(f);
72            fprintf(stream.get(), ptestdata_utf8);
73        }
74        fclose(f);
75
76        ifstream file(TEST_FILE, ifstream::binary);
77        char buf[4100] = {};
78        file.read(buf, _countof(buf));
79        wchar_t* wbuf = (wchar_t*)buf;
80        wchar_t* wtest = (wchar_t*)ptestdata_utf16le;
81        size_t a = wcslen(wbuf);
82        size_t b = wcslen(wtest);
83        QT_CHECK(a == b);
84        QT_CHECK(basic_string<wchar_t>((wchar_t*)buf) == (wchar_t*)ptestdata_utf16le);
85    }
86    QT_CHECK(unlink(TEST_FILE) == 0);
87
88}
89#endif
90
91QT_TEST(ajiofdjuae)
92{
93    //i3::check_args();
94}
95
96
97
98QT_TEST(aaaabcd)
99{
100    QT_CHECK(true);
101}
102
Note: See TracBrowser for help on using the browser.