diff --git a/unittest/bitvector_test.cc b/unittest/bitvector_test.cc index 54d849a3..a9b72833 100644 --- a/unittest/bitvector_test.cc +++ b/unittest/bitvector_test.cc @@ -24,6 +24,11 @@ const int kPrimeLimit = 1000; namespace { class BitVectorTest : public testing::Test { + protected: + void SetUp() override { + std::locale::global(std::locale("")); + } + public: std::string OutputNameToPath(const std::string& name) { return file::JoinPath(FLAGS_test_tmpdir, name); diff --git a/unittest/colpartition_test.cc b/unittest/colpartition_test.cc index 140f06c2..46756651 100644 --- a/unittest/colpartition_test.cc +++ b/unittest/colpartition_test.cc @@ -27,7 +27,9 @@ class TestableColPartition : public ColPartition { class ColPartitionTest : public testing::Test { protected: - void SetUp() {} + void SetUp() { + std::locale::global(std::locale("")); + } void TearDown() {} }; diff --git a/unittest/commandlineflags_test.cc b/unittest/commandlineflags_test.cc index d767bc80..e97770b2 100644 --- a/unittest/commandlineflags_test.cc +++ b/unittest/commandlineflags_test.cc @@ -31,6 +31,10 @@ namespace { class CommandlineflagsTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + void TestParser(int argc, const char** const_argv) { TestParser("", argc, const_argv); } diff --git a/unittest/dawg_test.cc b/unittest/dawg_test.cc index dc035767..621fa7d2 100644 --- a/unittest/dawg_test.cc +++ b/unittest/dawg_test.cc @@ -27,6 +27,10 @@ namespace { // aka Directed Acyclic Word Graphs). class DawgTest : public testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + void LoadWordlist(const std::string& filename, std::set* words) const { std::ifstream file(filename); if (file.is_open()) { diff --git a/unittest/denorm_test.cc b/unittest/denorm_test.cc index 861602fb..b1f75b9d 100644 --- a/unittest/denorm_test.cc +++ b/unittest/denorm_test.cc @@ -17,9 +17,12 @@ namespace { class DENORMTest : public testing::Test { - public: - void SetUp() {} + protected: + void SetUp() { + std::locale::global(std::locale("")); + } + public: void TearDown() {} void ExpectCorrectTransform(const DENORM& denorm, const TPOINT& src, diff --git a/unittest/equationdetect_test.cc b/unittest/equationdetect_test.cc index a22b10c8..69cf85ea 100644 --- a/unittest/equationdetect_test.cc +++ b/unittest/equationdetect_test.cc @@ -105,6 +105,7 @@ class EquationFinderTest : public testing::Test { string testdata_dir_; void SetUp() { + std::locale::global(std::locale("")); string tessdata_dir = file::JoinPath(FLAGS_test_srcdir, "tessdata"); tesseract_.reset(new Tesseract()); tesseract_->init_tesseract(tessdata_dir.c_str(), "eng", OEM_TESSERACT_ONLY); diff --git a/unittest/heap_test.cc b/unittest/heap_test.cc index 26046d50..4daae766 100644 --- a/unittest/heap_test.cc +++ b/unittest/heap_test.cc @@ -25,6 +25,11 @@ int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0}; // The fixture for testing GenericHeap and DoublePtr. class HeapTest : public testing::Test { + protected: + void SetUp() { + std::locale::global(std::locale("")); + } + public: virtual ~HeapTest(); // Pushes the test data onto both the heap and the KDVector. diff --git a/unittest/imagedata_test.cc b/unittest/imagedata_test.cc index b5fb1df2..526a81fd 100644 --- a/unittest/imagedata_test.cc +++ b/unittest/imagedata_test.cc @@ -29,6 +29,10 @@ namespace { class ImagedataTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + ImagedataTest() {} // Creates a fake DocumentData, writes it to a file, and returns the filename. diff --git a/unittest/indexmapbidi_test.cc b/unittest/indexmapbidi_test.cc index 25f9eabf..0ac3951f 100644 --- a/unittest/indexmapbidi_test.cc +++ b/unittest/indexmapbidi_test.cc @@ -25,6 +25,11 @@ const int kPrimeLimit = 1000; namespace { class IndexMapBiDiTest : public testing::Test { + protected: + void SetUp() { + std::locale::global(std::locale("")); + } + public: std::string OutputNameToPath(const std::string& name) { return file::JoinPath(FLAGS_test_tmpdir, name); diff --git a/unittest/intsimdmatrix_test.cc b/unittest/intsimdmatrix_test.cc index f767ad41..aec8db01 100644 --- a/unittest/intsimdmatrix_test.cc +++ b/unittest/intsimdmatrix_test.cc @@ -27,6 +27,10 @@ namespace { class IntSimdMatrixTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + // Makes a random weights matrix of the given size. GENERIC_2D_ARRAY InitRandom(int no, int ni) { GENERIC_2D_ARRAY a(no, ni, 0); diff --git a/unittest/ligature_table_test.cc b/unittest/ligature_table_test.cc index 3e37123e..5ada5758 100644 --- a/unittest/ligature_table_test.cc +++ b/unittest/ligature_table_test.cc @@ -24,6 +24,10 @@ const char kRenderableEngLigatureText[] = "fidelity effigy ſteep"; class LigatureTableTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + static void SetUpTestCase() { FLAGS_fonts_dir = File::JoinPath(FLAGS_test_srcdir, "testdata"); FLAGS_fontconfig_tmpdir = FLAGS_test_tmpdir; diff --git a/unittest/linlsq_test.cc b/unittest/linlsq_test.cc index c61e0453..8f41ca96 100644 --- a/unittest/linlsq_test.cc +++ b/unittest/linlsq_test.cc @@ -16,9 +16,12 @@ namespace { class LLSQTest : public testing::Test { - public: - void SetUp() {} + protected: + void SetUp() { + std::locale::global(std::locale("")); + } + public: void TearDown() {} void ExpectCorrectLine(const LLSQ& llsq, double m, double c, double rms, diff --git a/unittest/lstm_test.h b/unittest/lstm_test.h index 68a828ef..06c2320d 100644 --- a/unittest/lstm_test.h +++ b/unittest/lstm_test.h @@ -45,6 +45,10 @@ const int kBatchIterations = 1; // The fixture for testing LSTMTrainer. class LSTMTrainerTest : public testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + LSTMTrainerTest() {} std::string TestDataNameToPath(const std::string& name) { return file::JoinPath(TESTDATA_DIR, diff --git a/unittest/matrix_test.cc b/unittest/matrix_test.cc index 5bb8cb14..6774fa4c 100644 --- a/unittest/matrix_test.cc +++ b/unittest/matrix_test.cc @@ -22,6 +22,10 @@ namespace { class MatrixTest : public ::testing::Test { protected: + void SetUp() override { + std::locale::global(std::locale("")); + } + // Fills src_ with data so it can pretend to be a tensor thus: // dims_=[5, 4, 3, 2] // array_=[0, 1, 2, ....119] diff --git a/unittest/networkio_test.cc b/unittest/networkio_test.cc index 8efe743a..aaa82093 100644 --- a/unittest/networkio_test.cc +++ b/unittest/networkio_test.cc @@ -12,6 +12,10 @@ namespace { class NetworkioTest : public ::testing::Test { protected: + void SetUp() override { + std::locale::global(std::locale("")); + } + // Sets up an Array2d object of the given size, initialized to increasing // values starting with start. std::unique_ptr> SetupArray(int ysize, int xsize, int start) { diff --git a/unittest/nthitem_test.cc b/unittest/nthitem_test.cc index 670faf99..b242cc49 100644 --- a/unittest/nthitem_test.cc +++ b/unittest/nthitem_test.cc @@ -20,6 +20,11 @@ int test_data[] = {8, 1, 2, -4, 7, 9, 65536, 4, 9, 0, -32767, 6, 7}; // The fixture for testing GenericHeap and DoublePtr. class NthItemTest : public testing::Test { + protected: + void SetUp() override { + std::locale::global(std::locale("")); + } + public: virtual ~NthItemTest(); // Pushes the test data onto the KDVector. diff --git a/unittest/pango_font_info_test.cc b/unittest/pango_font_info_test.cc index 875b57b3..fde4f34f 100644 --- a/unittest/pango_font_info_test.cc +++ b/unittest/pango_font_info_test.cc @@ -48,6 +48,10 @@ const char* kBadlyFormedHinWords[] = { class PangoFontInfoTest : public ::testing::Test { protected: + void SetUp() override { + std::locale::global(std::locale("")); + } + // Creates a fake fonts.conf file that points to the testdata fonts for // fontconfig to initialize with. static void SetUpTestCase() { diff --git a/unittest/qrsequence_test.cc b/unittest/qrsequence_test.cc index 8ce3eba4..18f059e4 100644 --- a/unittest/qrsequence_test.cc +++ b/unittest/qrsequence_test.cc @@ -37,7 +37,12 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) { } // Trivial test fixture for a parameterized test. -class QRSequenceGeneratorTest : public ::testing::TestWithParam {}; +class QRSequenceGeneratorTest : public ::testing::TestWithParam { + protected: + void SetUp() { + std::locale::global(std::locale("")); + } +}; TEST_P(QRSequenceGeneratorTest, GeneratesValidSequence) { const int kRangeSize = GetParam(); diff --git a/unittest/recodebeam_test.cc b/unittest/recodebeam_test.cc index 1d1bc59a..b1736e01 100644 --- a/unittest/recodebeam_test.cc +++ b/unittest/recodebeam_test.cc @@ -69,6 +69,10 @@ const float kVi2ndScores[] = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01}; class RecodeBeamTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + RecodeBeamTest() : lstm_dict_(&ccutil_) {} ~RecodeBeamTest() { lstm_dict_.End(); } @@ -153,7 +157,7 @@ class RecodeBeamTest : public ::testing::Test { !recoder_.IsValidFirstCode(labels[index]))); EXPECT_NE(INVALID_UNICHAR_ID, uni_id) << "index=" << index << "/" << labels.size(); - // To the extent of truth_utf8, we expect decoded to match, but if + // To the extent of truth_utf8, we expect decoded to match, but if // transcription is shorter, that is OK too, as we may just be testing // that we get a valid sequence when padded with random data. if (uni_id != unichar_null_char_ && decoded.size() < truth_utf8.size()) diff --git a/unittest/rect_test.cc b/unittest/rect_test.cc index 069ca7de..38f77eb8 100644 --- a/unittest/rect_test.cc +++ b/unittest/rect_test.cc @@ -17,7 +17,9 @@ namespace { class TBOXTest : public testing::Test { public: - void SetUp() {} + void SetUp() { + std::locale::global(std::locale("")); + } void TearDown() {} }; diff --git a/unittest/scanutils_test.cc b/unittest/scanutils_test.cc index 5d14924e..f54f87df 100644 --- a/unittest/scanutils_test.cc +++ b/unittest/scanutils_test.cc @@ -6,6 +6,10 @@ namespace { class ScanutilsTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + string TestDataNameToPath(const string& name) { return file::JoinPath(FLAGS_test_srcdir, "testdata/" + name); } diff --git a/unittest/stats_test.cc b/unittest/stats_test.cc index 6b0a7ae7..be692cfb 100644 --- a/unittest/stats_test.cc +++ b/unittest/stats_test.cc @@ -22,6 +22,7 @@ const int kTestData[] = {2, 0, 12, 1, 1, 2, 10, 1, 0, 0, 0, 2, 0, 4, 1, 1}; class STATSTest : public testing::Test { public: void SetUp() { + std::locale::global(std::locale("")); stats_.set_range(0, 16); for (size_t i = 0; i < ARRAYSIZE(kTestData); ++i) stats_.add(i, kTestData[i]); diff --git a/unittest/stridemap_test.cc b/unittest/stridemap_test.cc index 2427eba0..d9b58755 100644 --- a/unittest/stridemap_test.cc +++ b/unittest/stridemap_test.cc @@ -10,6 +10,10 @@ namespace { class StridemapTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + // Sets up an Array2d object of the given size, initialized to increasing // values starting with start. std::unique_ptr> SetupArray(int ysize, int xsize, int start) { diff --git a/unittest/stringrenderer_test.cc b/unittest/stringrenderer_test.cc index 6841e490..c778b480 100644 --- a/unittest/stringrenderer_test.cc +++ b/unittest/stringrenderer_test.cc @@ -50,6 +50,10 @@ using tesseract::StringRenderer; class StringRendererTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + static void SetUpTestCase() { l_chooseDisplayProg(L_DISPLAY_WITH_XZGV); FLAGS_fonts_dir = TESTING_DIR; diff --git a/unittest/tablefind_test.cc b/unittest/tablefind_test.cc index a73544c3..06712475 100644 --- a/unittest/tablefind_test.cc +++ b/unittest/tablefind_test.cc @@ -66,6 +66,7 @@ class TestableTableFinder : public tesseract::TableFinder { class TableFinderTest : public testing::Test { protected: void SetUp() { + std::locale::global(std::locale("")); free_boxes_it_.set_to_list(&free_boxes_); finder_.reset(new TestableTableFinder()); finder_->Init(1, ICOORD(0, 0), ICOORD(500, 500)); diff --git a/unittest/tablerecog_test.cc b/unittest/tablerecog_test.cc index 55d60831..a9c19b25 100644 --- a/unittest/tablerecog_test.cc +++ b/unittest/tablerecog_test.cc @@ -71,6 +71,7 @@ class TestableStructuredTable : public tesseract::StructuredTable { class SharedTest : public testing::Test { protected: void SetUp() { + std::locale::global(std::locale("")); ICOORD bleft(0, 0); ICOORD tright(1000, 1000); text_grid_.reset(new ColPartitionGrid(5, bleft, tright)); diff --git a/unittest/tabvector_test.cc b/unittest/tabvector_test.cc index d4f15fdd..9b78d6cb 100644 --- a/unittest/tabvector_test.cc +++ b/unittest/tabvector_test.cc @@ -21,7 +21,10 @@ namespace { class TabVectorTest : public testing::Test { protected: - void SetUp() { vector_.reset(); } + void SetUp() { + std::locale::global(std::locale("")); + vector_.reset(); + } void TearDown() {} diff --git a/unittest/tatweel_test.cc b/unittest/tatweel_test.cc index 4f7ed920..422e2288 100644 --- a/unittest/tatweel_test.cc +++ b/unittest/tatweel_test.cc @@ -7,6 +7,10 @@ namespace { class TatweelTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + TatweelTest() { string filename = TestDataNameToPath("ara.wordlist"); string wordlist; diff --git a/unittest/tfile_test.cc b/unittest/tfile_test.cc index d7f08d3d..9cad4ea9 100644 --- a/unittest/tfile_test.cc +++ b/unittest/tfile_test.cc @@ -23,6 +23,10 @@ namespace { class TfileTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + TfileTest() {} // Some data to serialize. diff --git a/unittest/unicharcompress_test.cc b/unittest/unicharcompress_test.cc index b36db1f2..a7eff561 100644 --- a/unittest/unicharcompress_test.cc +++ b/unittest/unicharcompress_test.cc @@ -27,6 +27,10 @@ namespace { class UnicharcompressTest : public ::testing::Test { protected: + void SetUp() { + std::locale::global(std::locale("")); + } + // Loads and compresses the given unicharset. void LoadUnicharset(const std::string& unicharset_name) { std::string radical_stroke_file = diff --git a/unittest/unicharset_test.cc b/unittest/unicharset_test.cc index 927a60aa..f1622fe3 100644 --- a/unittest/unicharset_test.cc +++ b/unittest/unicharset_test.cc @@ -19,6 +19,13 @@ using testing::ElementsAreArray; namespace { +class UnicharsetTest : public ::testing::Test { + protected: + void SetUp() override { + std::locale::global(std::locale("")); + } +}; + TEST(UnicharsetTest, Basics) { // This test verifies basic insertion, unichar_to_id, and encode. UNICHARSET u;