mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-18 03:19:15 +08:00
Improve some unit tests.
This commit is contained in:
parent
0c19e1e14d
commit
6cc00aa332
@ -38,7 +38,7 @@ class QuickTest : public testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() { start_time_ = time(nullptr); }
|
||||
virtual void TearDown() {
|
||||
#if defined(DEBUG)
|
||||
#ifndef NDEBUG
|
||||
// Debug builds can be very slow, so allow 4 min for OCR of a test image.
|
||||
// apitest_example including disabled tests takes about 18 min on ARMv7.
|
||||
const time_t MAX_SECONDS_FOR_TEST = 240;
|
||||
|
@ -30,24 +30,29 @@ TEST(OutputBufferTest, WriteString) {
|
||||
const int kMaxBufSize = 128;
|
||||
char buffer[kMaxBufSize];
|
||||
for (int i = 0; i < kMaxBufSize; ++i) buffer[i] = '\0';
|
||||
FILE* fp = fmemopen(buffer, kMaxBufSize, "w");
|
||||
FILE* fp = tmpfile();
|
||||
CHECK(fp != nullptr);
|
||||
|
||||
{
|
||||
std::unique_ptr<OutputBuffer> output(new OutputBuffer(fp));
|
||||
output->WriteString("Hello ");
|
||||
output->WriteString("world!");
|
||||
}
|
||||
EXPECT_STREQ("Hello world!", buffer);
|
||||
std::unique_ptr<OutputBuffer> output(new OutputBuffer(fp));
|
||||
output->WriteString("Hello ");
|
||||
output->WriteString("world!");
|
||||
|
||||
rewind(fp);
|
||||
auto s = "Hello world!";
|
||||
fread(buffer, strlen(s), 1, fp);
|
||||
EXPECT_STREQ(s, buffer);
|
||||
}
|
||||
|
||||
TEST(InputBufferTest, Read) {
|
||||
const int kMaxBufSize = 128;
|
||||
char buffer[kMaxBufSize];
|
||||
snprintf(buffer, kMaxBufSize, "Hello\n world!");
|
||||
EXPECT_STREQ("Hello\n world!", buffer);
|
||||
FILE* fp = fmemopen(buffer, kMaxBufSize, "r");
|
||||
auto s = "Hello\n world!";
|
||||
snprintf(buffer, kMaxBufSize, s);
|
||||
EXPECT_STREQ(s, buffer);
|
||||
FILE* fp = tmpfile();
|
||||
CHECK(fp != nullptr);
|
||||
fwrite(buffer, strlen(s), 1, fp);
|
||||
rewind(fp);
|
||||
|
||||
std::string str;
|
||||
std::unique_ptr<InputBuffer> input(new InputBuffer(fp));
|
||||
|
@ -9,18 +9,21 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#include "include_gunit.h"
|
||||
#include "log.h" // for LOG
|
||||
|
||||
#include "recodebeam.h"
|
||||
#include "matrix.h"
|
||||
#include "pageres.h"
|
||||
#include "ratngs.h"
|
||||
#include <tesseract/genericvector.h>
|
||||
#include <tesseract/helpers.h>
|
||||
#include "unicharcompress.h"
|
||||
#include "normstrngs.h"
|
||||
#include "unicharset_training_utils.h"
|
||||
|
||||
#include "include_gunit.h"
|
||||
#include "log.h" // for LOG
|
||||
#include <tesseract/genericvector.h>
|
||||
#include <tesseract/helpers.h>
|
||||
|
||||
#include "absl/strings/str_format.h" // for absl::StrFormat
|
||||
|
||||
namespace tesseract {
|
||||
|
Loading…
Reference in New Issue
Block a user