Update ooo320-m1
[ooovba.git] / cppu / test / EnvDcp / EnvDcp.test.cxx
blob4ff300f642715ce91982f7033fdecb5f824ef165
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EnvDcp.test.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "sal/main.h"
33 #include "cppu/EnvDcp.hxx"
35 #include <iostream>
38 static rtl::OUString s_message;
40 static void s_test__getTypeName(void)
42 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__getTypeName"));
44 rtl::OUString envDcp(RTL_CONSTASCII_USTRINGPARAM("acaQEQWE123:asda:2342"));
46 rtl::OUString typeName(cppu::EnvDcp::getTypeName(envDcp));
48 rtl::OUString ref(RTL_CONSTASCII_USTRINGPARAM("acaQEQWE123"));
50 if (typeName == ref)
51 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
53 else
55 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - FAILURE\n"));
56 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t got: \""));
57 s_message += typeName;
58 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
59 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t expected: \""));
60 s_message += ref;
61 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
65 static void s_test__getPurpose(void)
67 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__getPurpose"));
69 rtl::OUString envDcp(RTL_CONSTASCII_USTRINGPARAM("acaQEQWE123:asda:2342"));
71 rtl::OUString purpose(cppu::EnvDcp::getPurpose(envDcp));
73 rtl::OUString ref(RTL_CONSTASCII_USTRINGPARAM(":asda:2342"));
75 if (purpose == ref)
76 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
78 else
80 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - FAILURE\n"));
81 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t got: \""));
82 s_message += purpose;
83 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
84 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t expected: \""));
85 s_message += ref;
86 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
90 SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv)
92 s_test__getTypeName();
93 s_test__getPurpose();
95 int ret;
96 if (s_message.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILURE"))) == -1)
98 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS PASSED\n"));
99 ret = 0;
101 else
103 s_message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS _NOT_ PASSED\n"));
104 ret = -1;
107 std::cerr
108 << argv[0]
109 << std::endl
110 << rtl::OUStringToOString(s_message, RTL_TEXTENCODING_ASCII_US).getStr()
111 << std::endl;
113 return ret;