Commit f2bf49e2 by Jonah Ryan-Davis Committed by Commit Bot

Fix locale being reset to default after ShCompileTest.DecimalSepLocale

This test changes the global locale, but wasn't changing the locale back to the original locale, which was messing up tests that followed. Bug: 943140 Change-Id: I0abacbd4a724538c9dbe5cb61ef1854ca79a76e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1531539 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 134425c7
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <clocale> #include <clocale>
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "angle_gl.h" #include "angle_gl.h"
#include "common/angleutils.h"
#include "common/platform.h" #include "common/platform.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -46,10 +47,30 @@ class ShCompileTest : public testing::Test ...@@ -46,10 +47,30 @@ class ShCompileTest : public testing::Test
ShBuiltInResources mResources; ShBuiltInResources mResources;
class ScopedRestoreDefaultLocale : angle::NonCopyable
{
public:
ScopedRestoreDefaultLocale();
~ScopedRestoreDefaultLocale();
private:
std::locale defaultLocale;
};
public: public:
ShHandle mCompiler; ShHandle mCompiler;
}; };
ShCompileTest::ScopedRestoreDefaultLocale::ScopedRestoreDefaultLocale()
{
defaultLocale = std::locale();
}
ShCompileTest::ScopedRestoreDefaultLocale::~ScopedRestoreDefaultLocale()
{
std::locale::global(defaultLocale);
}
class ShCompileComputeTest : public ShCompileTest class ShCompileComputeTest : public ShCompileTest
{ {
public: public:
...@@ -144,6 +165,9 @@ TEST_F(ShCompileTest, DecimalSepLocale) ...@@ -144,6 +165,9 @@ TEST_F(ShCompileTest, DecimalSepLocale)
int testedLocales = 0; int testedLocales = 0;
// Ensure the locale is reset after the test runs.
ScopedRestoreDefaultLocale restoreLocale;
for (const std::string &locale : availableLocales) for (const std::string &locale : availableLocales)
{ {
// If the locale doesn't exist on the testing platform, the locale constructor will fail, // If the locale doesn't exist on the testing platform, the locale constructor will fail,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment