mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-12 15:39:04 +08:00
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:
parent
ce6b0c024c
commit
8887cad12f
@ -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);
|
||||
|
@ -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() {}
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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]
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
@ -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(); }
|
||||
|
||||
|
@ -17,7 +17,9 @@ namespace {
|
||||
|
||||
class TBOXTest : public testing::Test {
|
||||
public:
|
||||
void SetUp() {}
|
||||
void SetUp() {
|
||||
std::locale::global(std::locale(""));
|
||||
}
|
||||
|
||||
void TearDown() {}
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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() {}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -23,6 +23,10 @@ namespace {
|
||||
|
||||
class TfileTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() {
|
||||
std::locale::global(std::locale(""));
|
||||
}
|
||||
|
||||
TfileTest() {}
|
||||
|
||||
// Some data to serialize.
|
||||
|
@ -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 =
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user