File tree Expand file tree Collapse file tree 4 files changed +17
-20
lines changed
Expand file tree Collapse file tree 4 files changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,6 @@ include(GNUInstallDirs)
2626include (MaximumWarnings)
2727include (ClangTidy)
2828
29- option (USE_LOCALE "Use C++ locale support" OFF )
30-
31- if (USE_LOCALE)
32- add_definitions (-DSEXP_USE_LOCALE)
33- endif ()
34-
3529set (CMAKE_CXX_STANDARD 20)
3630set (CMAKE_CXX_STANDARD_REQUIRED ON )
3731set (CMAKE_CXX_EXTENSIONS OFF )
Original file line number Diff line number Diff line change @@ -27,9 +27,6 @@ std::string
2727Value::str () const
2828{
2929 std::ostringstream os;
30- #ifdef SEXP_USE_LOCALE
31- os.imbue (std::locale::classic ());
32- #endif
3330 os << *this ;
3431 return os.str ();
3532}
Original file line number Diff line number Diff line change @@ -38,17 +38,21 @@ TEST(IOTest, roundtrip)
3838 }
3939}
4040
41- #ifdef SEXP_USE_LOCALE
42-
4341TEST (IOLocaleTest, locale_safe_output)
4442{
4543 auto sx = sexp::Value::real (0 .015625f );
4644 std::stringstream out;
47- out.imbue (std::locale (" de_DE.UTF-8" ));
45+
46+ try {
47+ // This will fail when the locale is not installed on the system,
48+ // just ignore the test it in that case and let the test succeed.
49+ out.imbue (std::locale (" de_DE.UTF-8" ));
50+ } catch (std::exception const & err) {
51+ std::cerr << " warning: failed to setup locale: " << err.what () << std::endl;
52+ }
53+
4854 out << sx;
4955 ASSERT_EQ (" 0.015625" , out.str ());
5056}
5157
52- #endif
53-
5458/* EOF */
Original file line number Diff line number Diff line change 1616
1717#include < gtest/gtest.h>
1818
19+ #include < iostream>
1920#include < sstream>
2021
2122#include " sexp/io.hpp"
@@ -192,9 +193,6 @@ TEST(ParserTest, line_numbers)
192193 ASSERT_EQ (3 , sexp::list_ref (sx, 2 ).get_line ());
193194}
194195
195-
196- #ifdef SEXP_USE_LOCALE
197-
198196// C++ locale support comes in the form of ugly global state that
199197// spreads over most string formating functions, changing locale can
200198// break a lot of stuff.
@@ -209,7 +207,13 @@ class ParserLocaleTest : public ::testing::Test
209207
210208 virtual void SetUp () override
211209 {
212- std::locale::global (std::locale (" de_DE.UTF-8" ));
210+ try {
211+ // This will fail when the locale is not installed on the system,
212+ // just ignore the test it in that case and let the test succeed.
213+ std::locale::global (std::locale (" de_DE.UTF-8" ));
214+ } catch (std::exception const & err) {
215+ std::cerr << " warning: failed to setup locale: " << err.what () << std::endl;
216+ }
213217 }
214218
215219 virtual void TearDown () override
@@ -230,6 +234,4 @@ TEST_F(ParserLocaleTest, locale_safe_output)
230234 ASSERT_EQ (" 0.015625" , sx.str ());
231235}
232236
233- #endif
234-
235237/* EOF */
You can’t perform that action at this time.
0 commit comments