mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-13 07:59: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 {
|
namespace {
|
||||||
|
|
||||||
class BitVectorTest : public testing::Test {
|
class BitVectorTest : public testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string OutputNameToPath(const std::string& name) {
|
std::string OutputNameToPath(const std::string& name) {
|
||||||
return file::JoinPath(FLAGS_test_tmpdir, name);
|
return file::JoinPath(FLAGS_test_tmpdir, name);
|
||||||
|
@ -27,7 +27,9 @@ class TestableColPartition : public ColPartition {
|
|||||||
|
|
||||||
class ColPartitionTest : public testing::Test {
|
class ColPartitionTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() {}
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
void TearDown() {}
|
void TearDown() {}
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,10 @@ namespace {
|
|||||||
|
|
||||||
class CommandlineflagsTest : public ::testing::Test {
|
class CommandlineflagsTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
void TestParser(int argc, const char** const_argv) {
|
void TestParser(int argc, const char** const_argv) {
|
||||||
TestParser("", argc, const_argv);
|
TestParser("", argc, const_argv);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@ namespace {
|
|||||||
// aka Directed Acyclic Word Graphs).
|
// aka Directed Acyclic Word Graphs).
|
||||||
class DawgTest : public testing::Test {
|
class DawgTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
void LoadWordlist(const std::string& filename, std::set<std::string>* words) const {
|
void LoadWordlist(const std::string& filename, std::set<std::string>* words) const {
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class DENORMTest : public testing::Test {
|
class DENORMTest : public testing::Test {
|
||||||
public:
|
protected:
|
||||||
void SetUp() {}
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
void TearDown() {}
|
void TearDown() {}
|
||||||
|
|
||||||
void ExpectCorrectTransform(const DENORM& denorm, const TPOINT& src,
|
void ExpectCorrectTransform(const DENORM& denorm, const TPOINT& src,
|
||||||
|
@ -105,6 +105,7 @@ class EquationFinderTest : public testing::Test {
|
|||||||
string testdata_dir_;
|
string testdata_dir_;
|
||||||
|
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
string tessdata_dir = file::JoinPath(FLAGS_test_srcdir, "tessdata");
|
string tessdata_dir = file::JoinPath(FLAGS_test_srcdir, "tessdata");
|
||||||
tesseract_.reset(new Tesseract());
|
tesseract_.reset(new Tesseract());
|
||||||
tesseract_->init_tesseract(tessdata_dir.c_str(), "eng", OEM_TESSERACT_ONLY);
|
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.
|
// The fixture for testing GenericHeap and DoublePtr.
|
||||||
class HeapTest : public testing::Test {
|
class HeapTest : public testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~HeapTest();
|
virtual ~HeapTest();
|
||||||
// Pushes the test data onto both the heap and the KDVector.
|
// Pushes the test data onto both the heap and the KDVector.
|
||||||
|
@ -29,6 +29,10 @@ namespace {
|
|||||||
|
|
||||||
class ImagedataTest : public ::testing::Test {
|
class ImagedataTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
ImagedataTest() {}
|
ImagedataTest() {}
|
||||||
|
|
||||||
// Creates a fake DocumentData, writes it to a file, and returns the filename.
|
// Creates a fake DocumentData, writes it to a file, and returns the filename.
|
||||||
|
@ -25,6 +25,11 @@ const int kPrimeLimit = 1000;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class IndexMapBiDiTest : public testing::Test {
|
class IndexMapBiDiTest : public testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string OutputNameToPath(const std::string& name) {
|
std::string OutputNameToPath(const std::string& name) {
|
||||||
return file::JoinPath(FLAGS_test_tmpdir, name);
|
return file::JoinPath(FLAGS_test_tmpdir, name);
|
||||||
|
@ -27,6 +27,10 @@ namespace {
|
|||||||
|
|
||||||
class IntSimdMatrixTest : public ::testing::Test {
|
class IntSimdMatrixTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Makes a random weights matrix of the given size.
|
// Makes a random weights matrix of the given size.
|
||||||
GENERIC_2D_ARRAY<int8_t> InitRandom(int no, int ni) {
|
GENERIC_2D_ARRAY<int8_t> InitRandom(int no, int ni) {
|
||||||
GENERIC_2D_ARRAY<int8_t> a(no, ni, 0);
|
GENERIC_2D_ARRAY<int8_t> a(no, ni, 0);
|
||||||
|
@ -24,6 +24,10 @@ const char kRenderableEngLigatureText[] = "fidelity effigy ſteep";
|
|||||||
|
|
||||||
class LigatureTableTest : public ::testing::Test {
|
class LigatureTableTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestCase() {
|
||||||
FLAGS_fonts_dir = File::JoinPath(FLAGS_test_srcdir, "testdata");
|
FLAGS_fonts_dir = File::JoinPath(FLAGS_test_srcdir, "testdata");
|
||||||
FLAGS_fontconfig_tmpdir = FLAGS_test_tmpdir;
|
FLAGS_fontconfig_tmpdir = FLAGS_test_tmpdir;
|
||||||
|
@ -16,9 +16,12 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class LLSQTest : public testing::Test {
|
class LLSQTest : public testing::Test {
|
||||||
public:
|
protected:
|
||||||
void SetUp() {}
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
void TearDown() {}
|
void TearDown() {}
|
||||||
|
|
||||||
void ExpectCorrectLine(const LLSQ& llsq, double m, double c, double rms,
|
void ExpectCorrectLine(const LLSQ& llsq, double m, double c, double rms,
|
||||||
|
@ -45,6 +45,10 @@ const int kBatchIterations = 1;
|
|||||||
// The fixture for testing LSTMTrainer.
|
// The fixture for testing LSTMTrainer.
|
||||||
class LSTMTrainerTest : public testing::Test {
|
class LSTMTrainerTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
LSTMTrainerTest() {}
|
LSTMTrainerTest() {}
|
||||||
std::string TestDataNameToPath(const std::string& name) {
|
std::string TestDataNameToPath(const std::string& name) {
|
||||||
return file::JoinPath(TESTDATA_DIR,
|
return file::JoinPath(TESTDATA_DIR,
|
||||||
|
@ -22,6 +22,10 @@ namespace {
|
|||||||
|
|
||||||
class MatrixTest : public ::testing::Test {
|
class MatrixTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Fills src_ with data so it can pretend to be a tensor thus:
|
// Fills src_ with data so it can pretend to be a tensor thus:
|
||||||
// dims_=[5, 4, 3, 2]
|
// dims_=[5, 4, 3, 2]
|
||||||
// array_=[0, 1, 2, ....119]
|
// array_=[0, 1, 2, ....119]
|
||||||
|
@ -12,6 +12,10 @@ namespace {
|
|||||||
|
|
||||||
class NetworkioTest : public ::testing::Test {
|
class NetworkioTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Sets up an Array2d object of the given size, initialized to increasing
|
// Sets up an Array2d object of the given size, initialized to increasing
|
||||||
// values starting with start.
|
// values starting with start.
|
||||||
std::unique_ptr<Array2D<int>> SetupArray(int ysize, int xsize, int 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.
|
// The fixture for testing GenericHeap and DoublePtr.
|
||||||
class NthItemTest : public testing::Test {
|
class NthItemTest : public testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~NthItemTest();
|
virtual ~NthItemTest();
|
||||||
// Pushes the test data onto the KDVector.
|
// Pushes the test data onto the KDVector.
|
||||||
|
@ -48,6 +48,10 @@ const char* kBadlyFormedHinWords[] = {
|
|||||||
|
|
||||||
class PangoFontInfoTest : public ::testing::Test {
|
class PangoFontInfoTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a fake fonts.conf file that points to the testdata fonts for
|
// Creates a fake fonts.conf file that points to the testdata fonts for
|
||||||
// fontconfig to initialize with.
|
// fontconfig to initialize with.
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestCase() {
|
||||||
|
@ -37,7 +37,12 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Trivial test fixture for a parameterized test.
|
// 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) {
|
TEST_P(QRSequenceGeneratorTest, GeneratesValidSequence) {
|
||||||
const int kRangeSize = GetParam();
|
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 {
|
class RecodeBeamTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
RecodeBeamTest() : lstm_dict_(&ccutil_) {}
|
RecodeBeamTest() : lstm_dict_(&ccutil_) {}
|
||||||
~RecodeBeamTest() { lstm_dict_.End(); }
|
~RecodeBeamTest() { lstm_dict_.End(); }
|
||||||
|
|
||||||
@ -153,7 +157,7 @@ class RecodeBeamTest : public ::testing::Test {
|
|||||||
!recoder_.IsValidFirstCode(labels[index])));
|
!recoder_.IsValidFirstCode(labels[index])));
|
||||||
EXPECT_NE(INVALID_UNICHAR_ID, uni_id)
|
EXPECT_NE(INVALID_UNICHAR_ID, uni_id)
|
||||||
<< "index=" << index << "/" << labels.size();
|
<< "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
|
// transcription is shorter, that is OK too, as we may just be testing
|
||||||
// that we get a valid sequence when padded with random data.
|
// that we get a valid sequence when padded with random data.
|
||||||
if (uni_id != unichar_null_char_ && decoded.size() < truth_utf8.size())
|
if (uni_id != unichar_null_char_ && decoded.size() < truth_utf8.size())
|
||||||
|
@ -17,7 +17,9 @@ namespace {
|
|||||||
|
|
||||||
class TBOXTest : public testing::Test {
|
class TBOXTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
void SetUp() {}
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
void TearDown() {}
|
void TearDown() {}
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,10 @@ namespace {
|
|||||||
|
|
||||||
class ScanutilsTest : public ::testing::Test {
|
class ScanutilsTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
string TestDataNameToPath(const string& name) {
|
string TestDataNameToPath(const string& name) {
|
||||||
return file::JoinPath(FLAGS_test_srcdir, "testdata/" + 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 {
|
class STATSTest : public testing::Test {
|
||||||
public:
|
public:
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
stats_.set_range(0, 16);
|
stats_.set_range(0, 16);
|
||||||
for (size_t i = 0; i < ARRAYSIZE(kTestData); ++i)
|
for (size_t i = 0; i < ARRAYSIZE(kTestData); ++i)
|
||||||
stats_.add(i, kTestData[i]);
|
stats_.add(i, kTestData[i]);
|
||||||
|
@ -10,6 +10,10 @@ namespace {
|
|||||||
|
|
||||||
class StridemapTest : public ::testing::Test {
|
class StridemapTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Sets up an Array2d object of the given size, initialized to increasing
|
// Sets up an Array2d object of the given size, initialized to increasing
|
||||||
// values starting with start.
|
// values starting with start.
|
||||||
std::unique_ptr<Array2D<int>> SetupArray(int ysize, int xsize, int 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 {
|
class StringRendererTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
static void SetUpTestCase() {
|
static void SetUpTestCase() {
|
||||||
l_chooseDisplayProg(L_DISPLAY_WITH_XZGV);
|
l_chooseDisplayProg(L_DISPLAY_WITH_XZGV);
|
||||||
FLAGS_fonts_dir = TESTING_DIR;
|
FLAGS_fonts_dir = TESTING_DIR;
|
||||||
|
@ -66,6 +66,7 @@ class TestableTableFinder : public tesseract::TableFinder {
|
|||||||
class TableFinderTest : public testing::Test {
|
class TableFinderTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
free_boxes_it_.set_to_list(&free_boxes_);
|
free_boxes_it_.set_to_list(&free_boxes_);
|
||||||
finder_.reset(new TestableTableFinder());
|
finder_.reset(new TestableTableFinder());
|
||||||
finder_->Init(1, ICOORD(0, 0), ICOORD(500, 500));
|
finder_->Init(1, ICOORD(0, 0), ICOORD(500, 500));
|
||||||
|
@ -71,6 +71,7 @@ class TestableStructuredTable : public tesseract::StructuredTable {
|
|||||||
class SharedTest : public testing::Test {
|
class SharedTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
ICOORD bleft(0, 0);
|
ICOORD bleft(0, 0);
|
||||||
ICOORD tright(1000, 1000);
|
ICOORD tright(1000, 1000);
|
||||||
text_grid_.reset(new ColPartitionGrid(5, bleft, tright));
|
text_grid_.reset(new ColPartitionGrid(5, bleft, tright));
|
||||||
|
@ -21,7 +21,10 @@ namespace {
|
|||||||
|
|
||||||
class TabVectorTest : public testing::Test {
|
class TabVectorTest : public testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() { vector_.reset(); }
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
vector_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void TearDown() {}
|
void TearDown() {}
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@ namespace {
|
|||||||
|
|
||||||
class TatweelTest : public ::testing::Test {
|
class TatweelTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
TatweelTest() {
|
TatweelTest() {
|
||||||
string filename = TestDataNameToPath("ara.wordlist");
|
string filename = TestDataNameToPath("ara.wordlist");
|
||||||
string wordlist;
|
string wordlist;
|
||||||
|
@ -23,6 +23,10 @@ namespace {
|
|||||||
|
|
||||||
class TfileTest : public ::testing::Test {
|
class TfileTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
TfileTest() {}
|
TfileTest() {}
|
||||||
|
|
||||||
// Some data to serialize.
|
// Some data to serialize.
|
||||||
|
@ -27,6 +27,10 @@ namespace {
|
|||||||
|
|
||||||
class UnicharcompressTest : public ::testing::Test {
|
class UnicharcompressTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
void SetUp() {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
|
||||||
// Loads and compresses the given unicharset.
|
// Loads and compresses the given unicharset.
|
||||||
void LoadUnicharset(const std::string& unicharset_name) {
|
void LoadUnicharset(const std::string& unicharset_name) {
|
||||||
std::string radical_stroke_file =
|
std::string radical_stroke_file =
|
||||||
|
@ -19,6 +19,13 @@ using testing::ElementsAreArray;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
class UnicharsetTest : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
std::locale::global(std::locale(""));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TEST(UnicharsetTest, Basics) {
|
TEST(UnicharsetTest, Basics) {
|
||||||
// This test verifies basic insertion, unichar_to_id, and encode.
|
// This test verifies basic insertion, unichar_to_id, and encode.
|
||||||
UNICHARSET u;
|
UNICHARSET u;
|
||||||
|
Loading…
Reference in New Issue
Block a user