You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2007/07/18 00:01:28 UTC
svn commit: r557071 -
/incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp
Author: sebor
Date: Tue Jul 17 15:01:27 2007
New Revision: 557071
URL: http://svn.apache.org/viewvc?view=rev&rev=557071
Log:
2007-07-17 Martin Sebor <se...@roguewave.com>
* 22.locale.cons.stdcxx-485.cpp: Called rw_locales() to obtain
the set of installed locales to use. Introduced a dependency on
rw_test() required in order to be able to call rw_locales().
Modified:
incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp
Modified: incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp?view=diff&rev=557071&r1=557070&r2=557071
==============================================================================
--- incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp (original)
+++ incubator/stdcxx/trunk/tests/localization/22.locale.cons.stdcxx-485.cpp Tue Jul 17 15:01:27 2007
@@ -1,15 +1,84 @@
+/************************************************************************
+ *
+ * 22.locale.cons.stdcxx-485.cpp
+ *
+ * test exercising the thread safety of locale ctors
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ *
+ **************************************************************************/
+
#include <cassert>
+#include <cstring>
#include <locale>
-int main (int argc, char *argv[])
+#include <rw_locale.h>
+#include <driver.h>
+
+
+static int
+run_test (int, char**)
{
+ // obtain a NUL-separated list of installed locales
+ const char* const names = rw_locales ();
+
+ if (0 == names || '\0' == *names)
+ return 0;
+
+ // repeatedly create a large set of unique named locale objects
for (int j = 0; j != 2; ++j) {
std::locale locales [64];
- for (int i = 1; i < argc; ++i)
- locales [i] = std::locale (argv [i]);
+ std::size_t i = 0;
+
+ for (const char *pn = names; *pn; ++i, pn += std::strlen (pn) + 1) {
+ if (i == sizeof locales / sizeof *locales)
+ break;
+
+ locales [i] = std::locale (pn);
+ }
- for (int i = 1; i < argc; ++i)
- assert (std::has_facet<std::collate<char> >(locales [i]));
+ i = 0;
+
+ for (const char *pn = names; *pn; ++i, pn += std::strlen (pn) + 1) {
+ if (i == sizeof locales / sizeof *locales)
+ break;
+
+ rw_assert (std::has_facet<std::collate<char> >(locales [i]),
+ 0, __LINE__,
+ "std::has_facet<std::collate<char> >(locales(#s))",
+ pn);
+ }
}
+
+ return 0;
+}
+
+
+int main (int argc, char* argv[])
+{
+ return rw_test (argc, argv, __FILE__,
+ "lib.locale.cons",
+ "STDCXX-485",
+ run_test,
+ "",
+ (void*)0);
}