Skip to content

Commit

Permalink
unittest: Add qrsequence_test
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 12, 2018
1 parent 11f82f5 commit d3cf423
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
7 changes: 7 additions & 0 deletions unittest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ check_PROGRAMS = \
nthitem_test \
osd_test \
progress_test \
qrsequence_test \
rect_test \
stats_test \
tablefind_test \
Expand Down Expand Up @@ -119,6 +120,9 @@ applybox_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
baseapi_test_SOURCES = baseapi_test.cc
baseapi_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)

baseapi_thread_test_SOURCES = baseapi_thread_test.cc
baseapi_thread_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)

bitvector_test_SOURCES = bitvector_test.cc
bitvector_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)

Expand Down Expand Up @@ -165,6 +169,9 @@ progress_test_SOURCES = progress_test.cc
progress_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
progress_test_LDADD = $(GTEST_LIBS) $(GMOCK_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)

qrsequence_test_SOURCES = qrsequence_test.cc
qrsequence_test_LDADD = $(ABSEIL_LIBS) $(GTEST_LIBS) $(TESS_LIBS)

rect_test_SOURCES = rect_test.cc
rect_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)

Expand Down
20 changes: 16 additions & 4 deletions unittest/qrsequence_test.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
//
// (C) Copyright 2017, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "tesseract/ccutil/qrsequence.h"

#include <algorithm>
#include <vector>

#include "cycletimer.h"
#include "include_gunit.h"
#include "log.h"
#include "qrsequence.h"

namespace {

class TestableQRSequenceGenerator : public QRSequenceGenerator {
Expand Down Expand Up @@ -33,8 +46,7 @@ TEST_P(QRSequenceGeneratorTest, GeneratesValidSequence) {
CycleTimer timer;
timer.Restart();
for (int i = 0; i < kRangeSize; ++i) vals[i] = generator.GetVal();
LOG(INFO) << kRangeSize << "-length sequence took " << timer.Get() * 1e3
<< "ms";
LOG(INFO) << kRangeSize << "-length sequence took " << timer.GetInMs() << "ms";
// Sort the numbers to verify that we've covered the range without repetition.
std::sort(vals.begin(), vals.end());
for (int i = 0; i < kRangeSize; ++i) {
Expand Down

0 comments on commit d3cf423

Please sign in to comment.