xref: /aoo41x/main/tools/workben/inetmimetest.cxx (revision 89b56da7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 
27 #include <tools/inetmime.hxx>
28 
29 #include "rtl/textenc.h"
30 #include "rtl/ustring.hxx"
31 
32 #include <cstdlib>
33 #include <iostream>
34 
35 namespace {
36 
testDecode(char const * input,char const * expected)37 bool testDecode(char const * input, char const * expected) {
38     rtl::OUString result = INetMIME::decodeHeaderFieldBody(
39         INetMIME::HEADER_FIELD_TEXT, input);
40     bool success = result.equalsAscii(expected);
41     if (!success) {
42         std::cout
43             << "FAILED: decodeHeaderFieldBody(\"" << input << "\"): \""
44             << rtl::OUStringToOString(
45                 result, RTL_TEXTENCODING_ASCII_US).getStr()
46             << "\" != \"" << expected << "\"\n";
47     }
48     return success;
49 }
50 
51 }
52 
53 int
54 #if defined WNT
55 __cdecl
56 #endif
main()57 main() {
58     bool success = true;
59     success &= testDecode("=?iso-8859-1?B?QQ==?=", "A");
60     success &= testDecode("=?iso-8859-1?B?QUI=?=", "AB");
61     success &= testDecode("=?iso-8859-1?B?QUJD?=", "ABC");
62     return success ? EXIT_SUCCESS : EXIT_FAILURE;
63 }
64