Run more unittests with the user's locale

Hopefully this improves the test coverage.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2019-05-16 18:12:06 +02:00
parent ce6b0c024c
commit 8887cad12f
31 changed files with 122 additions and 9 deletions

View File

@ -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);

View File

@ -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() {}
};

View File

@ -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);
}

View File

@ -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<std::string>* words) const {
std::ifstream file(filename);
if (file.is_open()) {

View File

@ -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,

View File

@ -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);

View File

@ -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.

View File

@ -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.

View File

@ -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);

View File

@ -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<int8_t> InitRandom(int no, int ni) {
GENERIC_2D_ARRAY<int8_t> a(no, ni, 0);

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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]

View File

@ -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<Array2D<int>> SetupArray(int ysize, int xsize, int start) {

View File

@ -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.

View File

@ -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() {

View File

@ -37,7 +37,12 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) {
}
// Trivial test fixture for a parameterized test.
class QRSequenceGeneratorTest : public ::testing::TestWithParam<int> {};
class QRSequenceGeneratorTest : public ::testing::TestWithParam<int> {
protected:
void SetUp() {
std::locale::global(std::locale(""));
}
};
TEST_P(QRSequenceGeneratorTest, GeneratesValidSequence) {
const int kRangeSize = GetParam();

View File

@ -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(); }

View File

@ -17,7 +17,9 @@ namespace {
class TBOXTest : public testing::Test {
public:
void SetUp() {}
void SetUp() {
std::locale::global(std::locale(""));
}
void TearDown() {}
};

View File

@ -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);
}

View File

@ -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]);

View File

@ -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<Array2D<int>> SetupArray(int ysize, int xsize, int start) {

View File

@ -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;

View File

@ -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));

View File

@ -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));

View File

@ -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() {}

View File

@ -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;

View File

@ -23,6 +23,10 @@ namespace {
class TfileTest : public ::testing::Test {
protected:
void SetUp() {
std::locale::global(std::locale(""));
}
TfileTest() {}
// Some data to serialize.

View File

@ -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 =

View File

@ -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;