1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: env.tester.cxx,v $
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 ************************************************************************/
34 #include "rtl/ustring.hxx"
35 #include "rtl/string.hxx"
36 #include "rtl/alloc.h"
37 #include "uno/environment.hxx"
38 #include "uno/lbnames.h"
40 using namespace com::sun::star
;
43 static rtl::OUString
s_replaceCPP(rtl::OUString
const & str
)
45 rtl::OUString
cpp(RTL_CONSTASCII_USTRINGPARAM("CPP"));
49 sal_Int32 index_old
= 0;
50 sal_Int32 index
= str
.indexOf(cpp
, index_old
);
53 result
+= str
.copy(index_old
, index
- index_old
);
54 result
+= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV
)));
56 index_old
= index
+ 3;
57 index
= str
.indexOf(cpp
, index_old
);
59 result
+= str
.copy(index_old
);
65 rtl::OUString
register_test(rtl::OUString
const & envDcp
);
66 rtl::OUString
purpenv_test(rtl::OUString
const & envDcp
);
70 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc
, argv
)
73 rtl::OUString message
;
77 message
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n"));
79 rtl::OUString
envDcp(argv
[1], rtl_str_getLength(argv
[1]), RTL_TEXTENCODING_ASCII_US
);
80 envDcp
= s_replaceCPP(envDcp
);
83 message
+= register_test(envDcp
);
84 message
+= purpenv_test(envDcp
);
86 if (message
.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILURE"))) == -1)
88 message
+= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS PASSED\n"));
93 message
+= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS _NOT_ PASSED\n"));
98 message
= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("<env. descriptor>"));
103 << rtl::OUStringToOString(message
, RTL_TEXTENCODING_ASCII_US
).getStr()