summaryrefslogtreecommitdiff
path: root/cppu/test/env_substs
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2007-05-09 12:47:30 +0000
committerKurt Zenker <kz@openoffice.org>2007-05-09 12:47:30 +0000
commitd7e71735959aa9579e2e66934f5cabee3016786d (patch)
treec951e9c005fe402fe4bd038e8a826b2bebfa0831 /cppu/test/env_substs
parent01dedbb1ea5224cc70f2cb731ec71df03028ad51 (diff)
INTEGRATION: CWS bunoexttm (1.1.2.2.2); FILE ADDED
2007/02/08 10:59:10 kr 1.1.2.2.2.2: fixed: pass copy of string 2007/01/25 17:05:48 kr 1.1.2.2.2.1: fixed: license, a bug, warnings
Diffstat (limited to 'cppu/test/env_substs')
-rw-r--r--cppu/test/env_substs/env_subst.test.cxx103
1 files changed, 103 insertions, 0 deletions
diff --git a/cppu/test/env_substs/env_subst.test.cxx b/cppu/test/env_substs/env_subst.test.cxx
new file mode 100644
index 000000000..e466945e6
--- /dev/null
+++ b/cppu/test/env_substs/env_subst.test.cxx
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: env_subst.test.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: kz $ $Date: 2007-05-09 13:47:30 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include "sal/main.h"
+
+#include "uno/environment.hxx"
+
+#include <iostream>
+
+
+using namespace com::sun::star;
+
+static rtl::OUString s_comment;
+
+static void s_test_substituting(void)
+{
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test_substituting\n"));
+
+ putenv(strdup("UNO_ENV_SUBST:uno:unsafe=uno:affine"));
+
+ uno::Environment env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:unsafe")));
+ if (!env.getTypeName().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:affine"))))
+ {
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tFAILURE - expected \"uno:affine\" instead of \""));
+ s_comment += env.getTypeName();
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
+ }
+}
+
+static void s_test_not_substituting(void)
+{
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test_not_substituting\n"));
+
+ putenv(strdup("UNO_ENV_SUBST:uno:unsafe=uno:affine"));
+
+ uno::Environment env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:affine")));
+ if (!env.getTypeName().equals(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:affine"))))
+ {
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tFAILURE - expected \"uno:affine\" instead of \""));
+ s_comment += env.getTypeName();
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n"));
+ }
+}
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv)
+{
+ s_test_substituting();
+ s_test_not_substituting();
+
+
+ int ret;
+ if (s_comment.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILURE"))) == -1)
+ {
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS PASSED\n"));
+ ret = 0;
+ }
+ else
+ {
+ s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS _NOT_ PASSED\n"));
+ ret = -1;
+ }
+
+ std::cerr
+ << argv[0]
+ << std::endl
+ << rtl::OUStringToOString(s_comment, RTL_TEXTENCODING_ASCII_US).getStr()
+ << std::endl;
+
+ return ret;
+}
+