Make XMLWriterLocaleTest hold a copy of the old locale string.

The rationale is the same as in 0d0a41d549. XMLWriterLocaleTest still sporadically fails with a stack buffer overflow error when built with MSVC 2019 prior to this change.

PiperOrigin-RevId: 534035241
Change-Id: I1c50457e386724021b8d97ab1fb9cc2ece795292
This commit is contained in:
Saran Tunyasuvunakool
2023-05-22 05:33:47 -07:00
committed by Copybara-Service
parent bb8044e5f3
commit fbbdf70401
+8 -3
View File
@@ -913,17 +913,22 @@ TEST_F(XMLWriterTest, SetPrecision) {
}
class XMLWriterLocaleTest : public MujocoTest {
public:
XMLWriterLocaleTest() : old_locale_(std::setlocale(LC_ALL, nullptr)) {}
protected:
char* old_locale;
void SetUp() override {
this->old_locale = std::setlocale(LC_ALL, nullptr);
if (!std::setlocale(LC_ALL, "de_DE.UTF-8")) {
GTEST_SKIP() << "This system doesn't support the de_DE.UTF-8 locale";
}
}
void TearDown() override {
std::setlocale(LC_ALL, old_locale);
std::setlocale(LC_ALL, old_locale_.c_str());
}
private:
std::string old_locale_;
};
TEST_F(XMLWriterLocaleTest, IgnoresLocale) {