mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
Modernize code (clang-tidy -checks='-*,google-readability-braces-around-statements')
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
49d4afca63
commit
fbaac9dc9d
@ -326,8 +326,9 @@ static void matrixDotVector(int dim1, int dim2, const int8_t *wi, const double *
|
||||
group_size /= 2;
|
||||
w_step /= 2;
|
||||
|
||||
if (output + group_size <= rounded_num_out)
|
||||
if (output + group_size <= rounded_num_out) {
|
||||
PartialMatrixDotVector8(wi, scales, u, rounded_num_in, v);
|
||||
}
|
||||
}
|
||||
|
||||
const IntSimdMatrix IntSimdMatrix::intSimdMatrixAVX2 = {
|
||||
|
@ -186,10 +186,12 @@ public:
|
||||
|
||||
void *data() { // get current data
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::data", ABORT, nullptr);
|
||||
if (!current)
|
||||
}
|
||||
if (!current) {
|
||||
NULL_DATA.error("CLIST_ITERATOR::data", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return current->data;
|
||||
}
|
||||
@ -209,8 +211,9 @@ public:
|
||||
|
||||
bool empty() { // is list empty?
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::empty", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return list->empty();
|
||||
}
|
||||
@ -248,8 +251,9 @@ public:
|
||||
inline void CLIST_ITERATOR::set_to_list( // change list
|
||||
CLIST *list_to_iterate) {
|
||||
#ifndef NDEBUG
|
||||
if (!list_to_iterate)
|
||||
if (!list_to_iterate) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
list = list_to_iterate;
|
||||
@ -284,10 +288,12 @@ inline void CLIST_ITERATOR::add_after_then_move( // element to add
|
||||
CLIST_LINK *new_element;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_after_then_move", ABORT, nullptr);
|
||||
if (!new_data)
|
||||
}
|
||||
if (!new_data) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_after_then_move", ABORT, "new_data is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
new_element = new CLIST_LINK;
|
||||
@ -331,10 +337,12 @@ inline void CLIST_ITERATOR::add_after_stay_put( // element to add
|
||||
CLIST_LINK *new_element;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_after_stay_put", ABORT, nullptr);
|
||||
if (!new_data)
|
||||
}
|
||||
if (!new_data) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_after_stay_put", ABORT, "new_data is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
new_element = new CLIST_LINK;
|
||||
@ -380,10 +388,12 @@ inline void CLIST_ITERATOR::add_before_then_move( // element to add
|
||||
CLIST_LINK *new_element;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_before_then_move", ABORT, nullptr);
|
||||
if (!new_data)
|
||||
}
|
||||
if (!new_data) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_before_then_move", ABORT, "new_data is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
new_element = new CLIST_LINK;
|
||||
@ -423,10 +433,12 @@ inline void CLIST_ITERATOR::add_before_stay_put( // element to add
|
||||
CLIST_LINK *new_element;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
|
||||
if (!new_data)
|
||||
}
|
||||
if (!new_data) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_before_stay_put", ABORT, "new_data is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
new_element = new CLIST_LINK;
|
||||
@ -465,10 +477,12 @@ inline void CLIST_ITERATOR::add_before_stay_put( // element to add
|
||||
|
||||
inline void CLIST_ITERATOR::add_list_after(CLIST *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_list_after", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -510,10 +524,12 @@ inline void CLIST_ITERATOR::add_list_after(CLIST *list_to_add) {
|
||||
|
||||
inline void CLIST_ITERATOR::add_list_before(CLIST *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_list_before", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -556,11 +572,13 @@ inline void *CLIST_ITERATOR::extract() {
|
||||
void *extracted_data;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::extract", ABORT, nullptr);
|
||||
if (!current) // list empty or
|
||||
// element extracted
|
||||
}
|
||||
if (!current) { // list empty or
|
||||
// element extracted
|
||||
NULL_CURRENT.error("CLIST_ITERATOR::extract", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->singleton()) {
|
||||
@ -593,8 +611,9 @@ inline void *CLIST_ITERATOR::extract() {
|
||||
|
||||
inline void *CLIST_ITERATOR::move_to_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::move_to_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
current = list->First();
|
||||
@ -616,8 +635,9 @@ inline void *CLIST_ITERATOR::move_to_first() {
|
||||
|
||||
inline void CLIST_ITERATOR::mark_cycle_pt() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::mark_cycle_pt", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current) {
|
||||
@ -637,8 +657,9 @@ inline void CLIST_ITERATOR::mark_cycle_pt() {
|
||||
|
||||
inline bool CLIST_ITERATOR::at_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::at_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -656,8 +677,9 @@ inline bool CLIST_ITERATOR::at_first() {
|
||||
|
||||
inline bool CLIST_ITERATOR::at_last() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::at_last", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -675,8 +697,9 @@ inline bool CLIST_ITERATOR::at_last() {
|
||||
|
||||
inline bool CLIST_ITERATOR::cycled_list() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::cycled_list", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((list->empty()) || ((current == cycle_pt) && started_cycling));
|
||||
@ -691,8 +714,9 @@ inline bool CLIST_ITERATOR::cycled_list() {
|
||||
|
||||
inline int32_t CLIST_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::length", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return list->length();
|
||||
@ -709,8 +733,9 @@ inline void CLIST_ITERATOR::sort( // sort elements
|
||||
int comparator( // comparison routine
|
||||
const void *, const void *)) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::sort", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
list->sort(comparator);
|
||||
@ -732,10 +757,12 @@ inline void CLIST_ITERATOR::add_to_end( // element to add
|
||||
CLIST_LINK *new_element;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("CLIST_ITERATOR::add_to_end", ABORT, nullptr);
|
||||
if (!new_data)
|
||||
}
|
||||
if (!new_data) {
|
||||
BAD_PARAMETER.error("CLIST_ITERATOR::add_to_end", ABORT, "new_data is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this->at_last()) {
|
||||
|
@ -224,10 +224,12 @@ public:
|
||||
|
||||
ELIST_LINK *data() { // get current data
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::data", ABORT, nullptr);
|
||||
if (!current)
|
||||
}
|
||||
if (!current) {
|
||||
NULL_DATA.error("ELIST_ITERATOR::data", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return current;
|
||||
}
|
||||
@ -247,8 +249,9 @@ public:
|
||||
|
||||
bool empty() { // is list empty?
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::empty", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return list->empty();
|
||||
}
|
||||
@ -286,8 +289,9 @@ public:
|
||||
inline void ELIST_ITERATOR::set_to_list( // change list
|
||||
ELIST *list_to_iterate) {
|
||||
#ifndef NDEBUG
|
||||
if (!list_to_iterate)
|
||||
if (!list_to_iterate) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
list = list_to_iterate;
|
||||
@ -320,12 +324,15 @@ inline ELIST_ITERATOR::ELIST_ITERATOR(ELIST *list_to_iterate) {
|
||||
inline void ELIST_ITERATOR::add_after_then_move( // element to add
|
||||
ELIST_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_after_then_move", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST_ITERATOR::add_after_then_move", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -364,12 +371,15 @@ inline void ELIST_ITERATOR::add_after_then_move( // element to add
|
||||
inline void ELIST_ITERATOR::add_after_stay_put( // element to add
|
||||
ELIST_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_after_stay_put", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST_ITERATOR::add_after_stay_put", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -410,12 +420,15 @@ inline void ELIST_ITERATOR::add_after_stay_put( // element to add
|
||||
inline void ELIST_ITERATOR::add_before_then_move( // element to add
|
||||
ELIST_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_before_then_move", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST_ITERATOR::add_before_then_move", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -450,12 +463,15 @@ inline void ELIST_ITERATOR::add_before_then_move( // element to add
|
||||
inline void ELIST_ITERATOR::add_before_stay_put( // element to add
|
||||
ELIST_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST_ITERATOR::add_before_stay_put", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -491,10 +507,12 @@ inline void ELIST_ITERATOR::add_before_stay_put( // element to add
|
||||
|
||||
inline void ELIST_ITERATOR::add_list_after(ELIST *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_list_after", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -536,10 +554,12 @@ inline void ELIST_ITERATOR::add_list_after(ELIST *list_to_add) {
|
||||
|
||||
inline void ELIST_ITERATOR::add_list_before(ELIST *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_list_before", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -582,11 +602,13 @@ inline ELIST_LINK *ELIST_ITERATOR::extract() {
|
||||
ELIST_LINK *extracted_link;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::extract", ABORT, nullptr);
|
||||
if (!current) // list empty or
|
||||
// element extracted
|
||||
}
|
||||
if (!current) { // list empty or
|
||||
// element extracted
|
||||
NULL_CURRENT.error("ELIST_ITERATOR::extract", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->singleton()) {
|
||||
@ -617,8 +639,9 @@ inline ELIST_LINK *ELIST_ITERATOR::extract() {
|
||||
|
||||
inline ELIST_LINK *ELIST_ITERATOR::move_to_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::move_to_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
current = list->First();
|
||||
@ -640,8 +663,9 @@ inline ELIST_LINK *ELIST_ITERATOR::move_to_first() {
|
||||
|
||||
inline void ELIST_ITERATOR::mark_cycle_pt() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::mark_cycle_pt", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current) {
|
||||
@ -661,8 +685,9 @@ inline void ELIST_ITERATOR::mark_cycle_pt() {
|
||||
|
||||
inline bool ELIST_ITERATOR::at_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::at_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -680,8 +705,9 @@ inline bool ELIST_ITERATOR::at_first() {
|
||||
|
||||
inline bool ELIST_ITERATOR::at_last() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::at_last", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -699,8 +725,9 @@ inline bool ELIST_ITERATOR::at_last() {
|
||||
|
||||
inline bool ELIST_ITERATOR::cycled_list() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::cycled_list", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((list->empty()) || ((current == cycle_pt) && started_cycling));
|
||||
@ -715,8 +742,9 @@ inline bool ELIST_ITERATOR::cycled_list() {
|
||||
|
||||
inline int32_t ELIST_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::length", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return list->length();
|
||||
@ -733,8 +761,9 @@ inline void ELIST_ITERATOR::sort( // sort elements
|
||||
int comparator( // comparison routine
|
||||
const void *, const void *)) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::sort", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
list->sort(comparator);
|
||||
@ -754,12 +783,15 @@ inline void ELIST_ITERATOR::sort( // sort elements
|
||||
inline void ELIST_ITERATOR::add_to_end( // element to add
|
||||
ELIST_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST_ITERATOR::add_to_end", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST_ITERATOR::add_to_end", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this->at_last()) {
|
||||
|
@ -189,10 +189,12 @@ public:
|
||||
|
||||
ELIST2_LINK *data() { // get current data
|
||||
#ifndef NDEBUG
|
||||
if (!current)
|
||||
if (!current) {
|
||||
NULL_DATA.error("ELIST2_ITERATOR::data", ABORT, nullptr);
|
||||
if (!list)
|
||||
}
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::data", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return current;
|
||||
}
|
||||
@ -215,8 +217,9 @@ public:
|
||||
|
||||
bool empty() { // is list empty?
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::empty", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
return list->empty();
|
||||
}
|
||||
@ -258,8 +261,9 @@ private:
|
||||
inline void ELIST2_ITERATOR::set_to_list( // change list
|
||||
ELIST2 *list_to_iterate) {
|
||||
#ifndef NDEBUG
|
||||
if (!list_to_iterate)
|
||||
if (!list_to_iterate) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::set_to_list", ABORT, "list_to_iterate is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
list = list_to_iterate;
|
||||
@ -292,12 +296,15 @@ inline ELIST2_ITERATOR::ELIST2_ITERATOR(ELIST2 *list_to_iterate) {
|
||||
inline void ELIST2_ITERATOR::add_after_then_move( // element to add
|
||||
ELIST2_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_after_then_move", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_after_then_move", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST2_ITERATOR::add_after_then_move", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -340,12 +347,15 @@ inline void ELIST2_ITERATOR::add_after_then_move( // element to add
|
||||
inline void ELIST2_ITERATOR::add_after_stay_put( // element to add
|
||||
ELIST2_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_after_stay_put", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_after_stay_put", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST2_ITERATOR::add_after_stay_put", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -390,12 +400,15 @@ inline void ELIST2_ITERATOR::add_after_stay_put( // element to add
|
||||
inline void ELIST2_ITERATOR::add_before_then_move( // element to add
|
||||
ELIST2_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_before_then_move", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_before_then_move", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST2_ITERATOR::add_before_then_move", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -435,12 +448,15 @@ inline void ELIST2_ITERATOR::add_before_then_move( // element to add
|
||||
inline void ELIST2_ITERATOR::add_before_stay_put( // element to add
|
||||
ELIST2_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_before_stay_put", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_before_stay_put", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST2_ITERATOR::add_before_stay_put", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->empty()) {
|
||||
@ -481,10 +497,12 @@ inline void ELIST2_ITERATOR::add_before_stay_put( // element to add
|
||||
|
||||
inline void ELIST2_ITERATOR::add_list_after(ELIST2 *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_list_after", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_list_after", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -530,10 +548,12 @@ inline void ELIST2_ITERATOR::add_list_after(ELIST2 *list_to_add) {
|
||||
|
||||
inline void ELIST2_ITERATOR::add_list_before(ELIST2 *list_to_add) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_list_before", ABORT, nullptr);
|
||||
if (!list_to_add)
|
||||
}
|
||||
if (!list_to_add) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_list_before", ABORT, "list_to_add is nullptr");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!list_to_add->empty()) {
|
||||
@ -580,11 +600,13 @@ inline ELIST2_LINK *ELIST2_ITERATOR::extract() {
|
||||
ELIST2_LINK *extracted_link;
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::extract", ABORT, nullptr);
|
||||
if (!current) // list empty or
|
||||
// element extracted
|
||||
}
|
||||
if (!current) { // list empty or
|
||||
// element extracted
|
||||
NULL_CURRENT.error("ELIST2_ITERATOR::extract", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (list->singleton()) {
|
||||
@ -619,8 +641,9 @@ inline ELIST2_LINK *ELIST2_ITERATOR::extract() {
|
||||
|
||||
inline ELIST2_LINK *ELIST2_ITERATOR::move_to_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::move_to_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
current = list->First();
|
||||
@ -638,8 +661,9 @@ inline ELIST2_LINK *ELIST2_ITERATOR::move_to_first() {
|
||||
|
||||
inline ELIST2_LINK *ELIST2_ITERATOR::move_to_last() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::move_to_last", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
current = list->last;
|
||||
@ -661,8 +685,9 @@ inline ELIST2_LINK *ELIST2_ITERATOR::move_to_last() {
|
||||
|
||||
inline void ELIST2_ITERATOR::mark_cycle_pt() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::mark_cycle_pt", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current) {
|
||||
@ -682,8 +707,9 @@ inline void ELIST2_ITERATOR::mark_cycle_pt() {
|
||||
|
||||
inline bool ELIST2_ITERATOR::at_first() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::at_first", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -701,8 +727,9 @@ inline bool ELIST2_ITERATOR::at_first() {
|
||||
|
||||
inline bool ELIST2_ITERATOR::at_last() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::at_last", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// we're at a deleted
|
||||
@ -720,8 +747,9 @@ inline bool ELIST2_ITERATOR::at_last() {
|
||||
|
||||
inline bool ELIST2_ITERATOR::cycled_list() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::cycled_list", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ((list->empty()) || ((current == cycle_pt) && started_cycling));
|
||||
@ -736,8 +764,9 @@ inline bool ELIST2_ITERATOR::cycled_list() {
|
||||
|
||||
inline int32_t ELIST2_ITERATOR::length() {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::length", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return list->length();
|
||||
@ -754,8 +783,9 @@ inline void ELIST2_ITERATOR::sort( // sort elements
|
||||
int comparator( // comparison routine
|
||||
const void *, const void *)) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::sort", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
list->sort(comparator);
|
||||
@ -775,12 +805,15 @@ inline void ELIST2_ITERATOR::sort( // sort elements
|
||||
inline void ELIST2_ITERATOR::add_to_end( // element to add
|
||||
ELIST2_LINK *new_element) {
|
||||
#ifndef NDEBUG
|
||||
if (!list)
|
||||
if (!list) {
|
||||
NO_LIST.error("ELIST2_ITERATOR::add_to_end", ABORT, nullptr);
|
||||
if (!new_element)
|
||||
}
|
||||
if (!new_element) {
|
||||
BAD_PARAMETER.error("ELIST2_ITERATOR::add_to_end", ABORT, "new_element is nullptr");
|
||||
if (new_element->next)
|
||||
}
|
||||
if (new_element->next) {
|
||||
STILL_LINKED.error("ELIST2_ITERATOR::add_to_end", ABORT, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this->at_last()) {
|
||||
|
@ -66,10 +66,11 @@ protected:
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
if (line_mode)
|
||||
if (line_mode) {
|
||||
api_.SetVariable("tessedit_resegment_from_line_boxes", "1");
|
||||
else
|
||||
} else {
|
||||
api_.SetVariable("tessedit_resegment_from_boxes", "1");
|
||||
}
|
||||
api_.Recognize(nullptr);
|
||||
char *ocr_text = api_.GetUTF8Text();
|
||||
EXPECT_STREQ(truth_str, ocr_text);
|
||||
|
@ -308,8 +308,9 @@ TEST_F(TesseractTest, InitConfigOnlyTest) {
|
||||
// OEM_DEFAULT mode.
|
||||
TEST(TesseractInstanceTest, TestMultipleTessInstances) {
|
||||
int num_langs = 0;
|
||||
while (langs[num_langs] != nullptr)
|
||||
while (langs[num_langs] != nullptr) {
|
||||
++num_langs;
|
||||
}
|
||||
|
||||
const std::string kTessdataPath = TESSDATA_DIR;
|
||||
|
||||
@ -344,8 +345,9 @@ TEST(TesseractInstanceTest, TestMultipleTessInstances) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_langs; ++i)
|
||||
for (int i = 0; i < num_langs; ++i) {
|
||||
pixDestroy(&pix[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Tests whether Tesseract parameters are correctly set for the two instances.
|
||||
|
@ -167,8 +167,9 @@ static void VerifyTextResult(TessBaseAPI *tess, Pix *pix, const std::string &lan
|
||||
std::string ocr_text;
|
||||
GetCleanedText(tess_local, pix, &ocr_text);
|
||||
EXPECT_STREQ(expected_text.c_str(), ocr_text.c_str());
|
||||
if (tess_local != tess)
|
||||
if (tess_local != tess) {
|
||||
delete tess_local;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that Tesseract/Cube produce the correct results in single-threaded
|
||||
|
@ -38,13 +38,15 @@ public:
|
||||
TestAll(*map, false);
|
||||
map->SetBit(2);
|
||||
// Set all the odds to true.
|
||||
for (int i = 3; i <= kPrimeLimit; i += 2)
|
||||
for (int i = 3; i <= kPrimeLimit; i += 2) {
|
||||
map->SetValue(i, true);
|
||||
}
|
||||
int factor_limit = static_cast<int>(sqrt(1.0 + kPrimeLimit));
|
||||
for (int f = 3; f <= factor_limit; f += 2) {
|
||||
if (map->At(f)) {
|
||||
for (int m = 2; m * f <= kPrimeLimit; ++m)
|
||||
for (int m = 2; m * f <= kPrimeLimit; ++m) {
|
||||
map->ResetBit(f * m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,8 +57,9 @@ public:
|
||||
// of which is 997.
|
||||
int total_primes = 0;
|
||||
for (int i = 0; i <= kPrimeLimit; ++i) {
|
||||
if (map[i])
|
||||
if (map[i]) {
|
||||
++total_primes;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(168, total_primes);
|
||||
EXPECT_TRUE(map[997]);
|
||||
@ -77,8 +80,9 @@ public:
|
||||
bv->Init((end_byte - start_byte) * 8 * spacing);
|
||||
for (int byte_value = start_byte; byte_value < end_byte; ++byte_value) {
|
||||
for (int bit = 0; bit < 8; ++bit) {
|
||||
if (byte_value & (1 << bit))
|
||||
if (byte_value & (1 << bit)) {
|
||||
bv->SetBit((byte_value - start_byte) * 8 * spacing + bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,18 +28,20 @@ public:
|
||||
void ExpectCorrectTransform(const DENORM &denorm, const TPOINT &src, const TPOINT &result,
|
||||
bool local) {
|
||||
TPOINT normed;
|
||||
if (local)
|
||||
if (local) {
|
||||
denorm.LocalNormTransform(src, &normed);
|
||||
else
|
||||
} else {
|
||||
denorm.NormTransform(nullptr, src, &normed);
|
||||
}
|
||||
EXPECT_EQ(result.x, normed.x);
|
||||
EXPECT_EQ(result.y, normed.y);
|
||||
// Now undo
|
||||
TPOINT denormed;
|
||||
if (local)
|
||||
if (local) {
|
||||
denorm.LocalDenormTransform(normed, &denormed);
|
||||
else
|
||||
} else {
|
||||
denorm.DenormTransform(nullptr, normed, &denormed);
|
||||
}
|
||||
EXPECT_EQ(src.x, denormed.x);
|
||||
EXPECT_EQ(src.y, denormed.y);
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ TEST(FileTest, JoinPath) {
|
||||
TEST(OutputBufferTest, WriteString) {
|
||||
const int kMaxBufSize = 128;
|
||||
char buffer[kMaxBufSize];
|
||||
for (char &i : buffer)
|
||||
for (char &i : buffer) {
|
||||
i = '\0';
|
||||
}
|
||||
FILE *fp = tmpfile();
|
||||
CHECK(fp != nullptr);
|
||||
|
||||
|
@ -37,13 +37,15 @@ public:
|
||||
map->Init(kPrimeLimit + 1, false);
|
||||
map->SetMap(2, true);
|
||||
// Set all the odds to true.
|
||||
for (int i = 3; i <= kPrimeLimit; i += 2)
|
||||
for (int i = 3; i <= kPrimeLimit; i += 2) {
|
||||
map->SetMap(i, true);
|
||||
}
|
||||
int factor_limit = static_cast<int>(sqrt(1.0 + kPrimeLimit));
|
||||
for (int f = 3; f <= factor_limit; f += 2) {
|
||||
if (map->SparseToCompact(f) >= 0) {
|
||||
for (int m = 2; m * f <= kPrimeLimit; ++m)
|
||||
for (int m = 2; m * f <= kPrimeLimit; ++m) {
|
||||
map->SetMap(f * m, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
map->Setup();
|
||||
|
@ -90,8 +90,9 @@ TEST_F(IntFeatureMapTest, Exhaustive) {
|
||||
EXPECT_LE(abs(f.X - f2.X), dx);
|
||||
EXPECT_LE(abs(f.Y - f2.Y), dy);
|
||||
int theta_delta = abs(f.Theta - f2.Theta);
|
||||
if (theta_delta > kIntFeatureExtent / 2)
|
||||
if (theta_delta > kIntFeatureExtent / 2) {
|
||||
theta_delta = kIntFeatureExtent - theta_delta;
|
||||
}
|
||||
EXPECT_LE(theta_delta, dtheta);
|
||||
} else {
|
||||
++bad_offsets;
|
||||
|
@ -68,8 +68,9 @@ protected:
|
||||
std::vector<int8_t> u = RandomVector(num_in, matrix);
|
||||
std::vector<double> scales = RandomScales(num_out);
|
||||
int ro = num_out;
|
||||
if (IntSimdMatrix::intSimdMatrix)
|
||||
if (IntSimdMatrix::intSimdMatrix) {
|
||||
ro = IntSimdMatrix::intSimdMatrix->RoundOutputs(ro);
|
||||
}
|
||||
std::vector<double> base_result(ro);
|
||||
base_result.resize(num_out);
|
||||
IntSimdMatrix::MatrixDotVector(w, scales, u.data(), base_result.data());
|
||||
|
@ -102,10 +102,11 @@ TEST(LangModelTest, AddACharacter) {
|
||||
EXPECT_EQ(null1 + 1, null2);
|
||||
std::vector<int> labels1_v(labels1.size());
|
||||
for (int i = 0; i < labels1.size(); ++i) {
|
||||
if (labels1[i] == null1)
|
||||
if (labels1[i] == null1) {
|
||||
labels1_v[i] = null2;
|
||||
else
|
||||
} else {
|
||||
labels1_v[i] = labels1[i];
|
||||
}
|
||||
}
|
||||
EXPECT_THAT(labels1_v, testing::ElementsAreArray(&labels2[0], labels2.size()));
|
||||
// To make sure we we are not cheating somehow, we can now encode the Rupee
|
||||
@ -186,10 +187,11 @@ TEST(LangModelTest, AddACharacterHindi) {
|
||||
EXPECT_EQ(null1 + 1, null2);
|
||||
std::vector<int> labels1_v(labels1.size());
|
||||
for (int i = 0; i < labels1.size(); ++i) {
|
||||
if (labels1[i] == null1)
|
||||
if (labels1[i] == null1) {
|
||||
labels1_v[i] = null2;
|
||||
else
|
||||
} else {
|
||||
labels1_v[i] = labels1[i];
|
||||
}
|
||||
}
|
||||
EXPECT_THAT(labels1_v, testing::ElementsAreArray(&labels2[0], labels2.size()));
|
||||
// To make sure we we are not cheating somehow, we can now encode the Rupee
|
||||
|
@ -105,8 +105,9 @@ protected:
|
||||
}
|
||||
delete[] block_text;
|
||||
++block_index;
|
||||
if (strings[string_index] == nullptr)
|
||||
if (strings[string_index] == nullptr) {
|
||||
break;
|
||||
}
|
||||
} while (it->Next(tesseract::RIL_BLOCK));
|
||||
EXPECT_TRUE(strings[string_index] == nullptr);
|
||||
}
|
||||
@ -189,8 +190,9 @@ protected:
|
||||
// Tests that array sizes match their intended size.
|
||||
TEST_F(LayoutTest, ArraySizeTest) {
|
||||
int size = 0;
|
||||
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size)
|
||||
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size) {
|
||||
;
|
||||
}
|
||||
EXPECT_EQ(size, PT_COUNT);
|
||||
}
|
||||
|
||||
|
@ -85,10 +85,12 @@ protected:
|
||||
int net_mode = adam ? NF_ADAM : 0;
|
||||
// Adam needs a higher learning rate, due to not multiplying the effective
|
||||
// rate by 1/(1-momentum).
|
||||
if (adam)
|
||||
if (adam) {
|
||||
learning_rate *= 20.0f;
|
||||
if (layer_specific)
|
||||
}
|
||||
if (layer_specific) {
|
||||
net_mode |= NF_LAYER_SPECIFIC_LR;
|
||||
}
|
||||
EXPECT_TRUE(
|
||||
trainer_->InitNetwork(network_spec.c_str(), -1, net_mode, 0.1, learning_rate, 0.9, 0.999));
|
||||
std::vector<std::string> filenames;
|
||||
@ -114,8 +116,9 @@ protected:
|
||||
trainer_->MaintainCheckpoints(nullptr, log_str);
|
||||
iteration = trainer_->training_iteration();
|
||||
mean_error *= 100.0 / kBatchIterations;
|
||||
if (mean_error < best_error)
|
||||
if (mean_error < best_error) {
|
||||
best_error = mean_error;
|
||||
}
|
||||
} while (iteration < iteration_limit);
|
||||
LOG(INFO) << "Trainer error rate = " << best_error << "\n";
|
||||
return best_error;
|
||||
|
@ -85,8 +85,9 @@ public:
|
||||
std::vector<ShapeRating> *results) override {
|
||||
results->clear();
|
||||
// Everything except the first kNumNonReject is a reject.
|
||||
if (++num_done_ > kNumNonReject)
|
||||
if (++num_done_ > kNumNonReject) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int class_id = sample.class_id();
|
||||
int font_id = sample.font_id();
|
||||
@ -256,8 +257,9 @@ TEST_F(MasterTrainerTest, ErrorCounterTest) {
|
||||
LoadMasterTrainer();
|
||||
// Add the space character to the shape_table_ if not already present to
|
||||
// count junk.
|
||||
if (shape_table_->FindShape(0, -1) < 0)
|
||||
if (shape_table_->FindShape(0, -1) < 0) {
|
||||
shape_table_->AddShape(0, 0);
|
||||
}
|
||||
// Make a mock classifier.
|
||||
auto shape_classifier = std::make_unique<MockClassifier>(shape_table_);
|
||||
// Get the accuracy report.
|
||||
|
@ -38,8 +38,9 @@ protected:
|
||||
for (int i = 0; i < kInputSize_; ++i) {
|
||||
src_.put(0, i, i);
|
||||
}
|
||||
for (int i = 0; i < kNumDims_; ++i)
|
||||
for (int i = 0; i < kNumDims_; ++i) {
|
||||
dims_[i] = 5 - i;
|
||||
}
|
||||
}
|
||||
// Number of dimensions in src_.
|
||||
static const int kNumDims_ = 4;
|
||||
|
@ -64,8 +64,9 @@ void AsciiToRowInfo(const char *text, int row_number, RowInfo *info) {
|
||||
|
||||
std::vector<std::string> words = absl::StrSplit(text, ' ', absl::SkipEmpty());
|
||||
info->num_words = words.size();
|
||||
if (info->num_words < 1)
|
||||
if (info->num_words < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
info->lword_text = words[0].c_str();
|
||||
info->rword_text = words[words.size() - 1].c_str();
|
||||
@ -116,10 +117,12 @@ void EvaluateParagraphDetection(const TextAndModel *correct, int n,
|
||||
for (int i = 1; i < n; i++) {
|
||||
bool has_break = correct[i].model_type != PCONT;
|
||||
bool detected_break = (detector_output[i - 1] != detector_output[i]);
|
||||
if (has_break && !detected_break)
|
||||
if (has_break && !detected_break) {
|
||||
missed_breaks++;
|
||||
if (detected_break && !has_break)
|
||||
}
|
||||
if (detected_break && !has_break) {
|
||||
incorrect_breaks++;
|
||||
}
|
||||
if (has_break) {
|
||||
if (correct[i].model_type == PNONE) {
|
||||
if (detector_output[i]->model != nullptr) {
|
||||
|
@ -31,8 +31,9 @@ TEST(QRSequenceGenerator, GetBinaryReversedInteger) {
|
||||
const int kRangeSize = 8;
|
||||
TestableQRSequenceGenerator generator(kRangeSize);
|
||||
int reversed_vals[kRangeSize] = {0, 4, 2, 6, 1, 5, 3, 7};
|
||||
for (int i = 0; i < kRangeSize; ++i)
|
||||
for (int i = 0; i < kRangeSize; ++i) {
|
||||
EXPECT_EQ(reversed_vals[i], generator.GetBinaryReversedInteger(i));
|
||||
}
|
||||
}
|
||||
|
||||
// Trivial test fixture for a parameterized test.
|
||||
@ -49,8 +50,9 @@ TEST_P(QRSequenceGeneratorTest, GeneratesValidSequence) {
|
||||
std::vector<int> vals(kRangeSize);
|
||||
CycleTimer timer;
|
||||
timer.Restart();
|
||||
for (int i = 0; i < kRangeSize; ++i)
|
||||
for (int i = 0; i < kRangeSize; ++i) {
|
||||
vals[i] = generator.GetVal();
|
||||
}
|
||||
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());
|
||||
|
@ -139,8 +139,9 @@ protected:
|
||||
// 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
|
||||
// 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()) {
|
||||
decoded += ccutil_.unicharset.id_to_unichar(uni_id);
|
||||
}
|
||||
end = index;
|
||||
}
|
||||
EXPECT_EQ(truth_utf8, decoded);
|
||||
@ -162,8 +163,9 @@ protected:
|
||||
LOG(INFO) << absl::StrFormat("%d:u_id=%d=%s, c=%g, r=%g, r_sum=%g @%d", u, unichar_ids[u],
|
||||
str, certainties[u], ratings[u], total_rating, xcoords[u])
|
||||
<< "\n";
|
||||
if (str[0] == ' ')
|
||||
if (str[0] == ' ') {
|
||||
total_rating = 0.0f;
|
||||
}
|
||||
u_decoded += str;
|
||||
}
|
||||
}
|
||||
@ -177,8 +179,9 @@ protected:
|
||||
for (int w = 0; w < words->size(); ++w) {
|
||||
const WERD_RES *word = (*words)[w];
|
||||
if (w_decoded.size() < truth_utf8.size()) {
|
||||
if (!w_decoded.empty() && word->word->space())
|
||||
if (!w_decoded.empty() && word->word->space()) {
|
||||
w_decoded += " ";
|
||||
}
|
||||
w_decoded += word->best_choice->unichar_string().c_str();
|
||||
}
|
||||
LOG(INFO) << absl::StrFormat("Word:%d = %s, c=%g, r=%g, perm=%d", w,
|
||||
@ -207,8 +210,9 @@ protected:
|
||||
// Fill with random data.
|
||||
TRand random;
|
||||
for (int t = 0; t < width; ++t) {
|
||||
for (int i = 0; i < num_codes; ++i)
|
||||
for (int i = 0; i < num_codes; ++i) {
|
||||
outputs(t, i) = random.UnsignedRand(0.25);
|
||||
}
|
||||
}
|
||||
int t = 0;
|
||||
for (int unichar_id : unichar_ids) {
|
||||
@ -229,10 +233,12 @@ protected:
|
||||
// Normalize the probs.
|
||||
for (int t = 0; t < width; ++t) {
|
||||
double sum = 0.0;
|
||||
for (int i = 0; i < num_codes; ++i)
|
||||
for (int i = 0; i < num_codes; ++i) {
|
||||
sum += outputs(t, i);
|
||||
for (int i = 0; i < num_codes; ++i)
|
||||
}
|
||||
for (int i = 0; i < num_codes; ++i) {
|
||||
outputs(t, i) /= sum;
|
||||
}
|
||||
}
|
||||
|
||||
return outputs;
|
||||
@ -282,8 +288,9 @@ protected:
|
||||
const char *chars2[], const float scores2[],
|
||||
TRand *random) {
|
||||
int width = 0;
|
||||
while (chars1[width] != nullptr)
|
||||
while (chars1[width] != nullptr) {
|
||||
++width;
|
||||
}
|
||||
int padding = width * RecodedCharID::kMaxCodeLen;
|
||||
int num_codes = recoder_.code_range();
|
||||
GENERIC_2D_ARRAY<float> outputs(width + padding, num_codes, 0.0f);
|
||||
@ -297,8 +304,9 @@ protected:
|
||||
int max_t = std::max(end_t1, end_t2);
|
||||
while (t < max_t) {
|
||||
double total_score = 0.0;
|
||||
for (int j = 0; j < num_codes; ++j)
|
||||
for (int j = 0; j < num_codes; ++j) {
|
||||
total_score += outputs(t, j);
|
||||
}
|
||||
double null_remainder = (1.0 - total_score) / 2.0;
|
||||
double remainder = null_remainder / (num_codes - 2);
|
||||
if (outputs(t, encoded_null_char_) < null_remainder) {
|
||||
@ -307,8 +315,9 @@ protected:
|
||||
remainder += remainder;
|
||||
}
|
||||
for (int j = 0; j < num_codes; ++j) {
|
||||
if (outputs(t, j) == 0.0f)
|
||||
if (outputs(t, j) == 0.0f) {
|
||||
outputs(t, j) = remainder;
|
||||
}
|
||||
}
|
||||
++t;
|
||||
}
|
||||
@ -332,8 +341,9 @@ TEST_F(RecodeBeamTest, DoesChinese) {
|
||||
LoadUnicharset("chi_tra.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
LOG(INFO) << "Testing chi_sim"
|
||||
@ -341,8 +351,9 @@ TEST_F(RecodeBeamTest, DoesChinese) {
|
||||
LoadUnicharset("chi_sim.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
transcription.clear();
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -353,8 +364,9 @@ TEST_F(RecodeBeamTest, DoesJapanese) {
|
||||
LoadUnicharset("jpn.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -365,8 +377,9 @@ TEST_F(RecodeBeamTest, DoesKorean) {
|
||||
LoadUnicharset("kor.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -377,8 +390,9 @@ TEST_F(RecodeBeamTest, DoesKannada) {
|
||||
LoadUnicharset("kan.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -389,8 +403,9 @@ TEST_F(RecodeBeamTest, DoesMarathi) {
|
||||
LoadUnicharset("mar.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -401,8 +416,9 @@ TEST_F(RecodeBeamTest, DoesEnglish) {
|
||||
LoadUnicharset("eng.unicharset");
|
||||
// Correctly reproduce the first kNumchars characters from easy output.
|
||||
std::vector<int> transcription;
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i)
|
||||
for (int i = SPECIAL_UNICHAR_CODES_COUNT; i < kNumChars; ++i) {
|
||||
transcription.push_back(i);
|
||||
}
|
||||
GENERIC_2D_ARRAY<float> outputs = GenerateRandomPaddedOutputs(transcription, kPadding);
|
||||
ExpectCorrect(outputs, transcription);
|
||||
}
|
||||
@ -414,8 +430,9 @@ TEST_F(RecodeBeamTest, DISABLED_EngDictionary) {
|
||||
GENERIC_2D_ARRAY<float> outputs =
|
||||
GenerateSyntheticOutputs(kGWRTops, kGWRTopScores, kGWR2nds, kGWR2ndScores, nullptr);
|
||||
std::string default_str;
|
||||
for (int i = 0; kGWRTops[i] != nullptr; ++i)
|
||||
for (int i = 0; kGWRTops[i] != nullptr; ++i) {
|
||||
default_str += kGWRTops[i];
|
||||
}
|
||||
PointerVector<WERD_RES> words;
|
||||
ExpectCorrect(outputs, default_str, nullptr, &words);
|
||||
// Now try again with the dictionary.
|
||||
|
@ -54,8 +54,9 @@ protected:
|
||||
int depth = pixGetDepth(src_pix_);
|
||||
Pix *pix = pixCreate(width, height, depth);
|
||||
EXPECT_TRUE(depth == 1 || depth == 8);
|
||||
if (depth == 8)
|
||||
if (depth == 8) {
|
||||
pixSetAll(pix);
|
||||
}
|
||||
do {
|
||||
int left, top, right, bottom;
|
||||
PageIteratorLevel im_level = level;
|
||||
@ -121,8 +122,9 @@ protected:
|
||||
result += ' ';
|
||||
}
|
||||
if (it->IsAtFinalElement(tesseract::RIL_PARA, level) &&
|
||||
!(it->IsAtFinalElement(tesseract::RIL_BLOCK, level)))
|
||||
!(it->IsAtFinalElement(tesseract::RIL_BLOCK, level))) {
|
||||
result += '\n';
|
||||
}
|
||||
}
|
||||
} while (it->Next(level));
|
||||
EXPECT_STREQ(truth.c_str(), result.c_str()) << "Rebuild failed at Text Level " << level;
|
||||
@ -184,8 +186,9 @@ protected:
|
||||
std::sort(output_copy.begin(), output_copy.end());
|
||||
bool sane = true;
|
||||
int j = 0;
|
||||
while (j < output_copy.size() && output_copy[j] < 0)
|
||||
while (j < output_copy.size() && output_copy[j] < 0) {
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < num_words; i++, j++) {
|
||||
if (output_copy[j] != i) {
|
||||
sane = false;
|
||||
@ -380,8 +383,9 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) {
|
||||
EXPECT_TRUE(smallcaps) << word_str;
|
||||
++found_smallcaps;
|
||||
} else {
|
||||
if (smallcaps)
|
||||
if (smallcaps) {
|
||||
++false_positives;
|
||||
}
|
||||
}
|
||||
// No symbol other than the first of any word should be dropcap.
|
||||
ResultIterator s_it(*r_it);
|
||||
@ -530,11 +534,12 @@ TEST_F(ResultIteratorTest, DISABLED_NonNullChoicesTest) {
|
||||
tesseract::ChoiceIterator c_it(s_it);
|
||||
do {
|
||||
const char *char_str = c_it.GetUTF8Text();
|
||||
if (char_str == nullptr)
|
||||
if (char_str == nullptr) {
|
||||
LOG(INFO) << "Null char choice"
|
||||
<< "\n";
|
||||
else
|
||||
} else {
|
||||
LOG(INFO) << "Char choice " << char_str << "\n";
|
||||
}
|
||||
CHECK(char_str != nullptr);
|
||||
} while (c_it.Next());
|
||||
} while (!s_it.IsAtFinalElement(tesseract::RIL_WORD, tesseract::RIL_SYMBOL) &&
|
||||
|
@ -94,8 +94,9 @@ TEST_F(ScanutilsTest, DoesScanf) {
|
||||
r1 = fscanf(fp1, "%f %f %f %f", &f1[0], &f1[1], &f1[2], &f1[3]);
|
||||
r2 = tfscanf(fp2, "%f %f %f %f", &f2[0], &f2[1], &f2[2], &f2[3]);
|
||||
EXPECT_EQ(r1, r2);
|
||||
for (int i = 0; i < kNumFloats; ++i)
|
||||
for (int i = 0; i < kNumFloats; ++i) {
|
||||
EXPECT_FLOAT_EQ(f1[i], f2[i]);
|
||||
}
|
||||
// Test the * for field suppression.
|
||||
r1 = fscanf(fp1, "%d %*s %*d %*f %*f", &i1[0]);
|
||||
r2 = tfscanf(fp2, "%d %*s %*d %*f %*f", &i2[0]);
|
||||
|
@ -23,8 +23,9 @@ public:
|
||||
void SetUp() override {
|
||||
std::locale::global(std::locale(""));
|
||||
stats_.set_range(0, 16);
|
||||
for (size_t i = 0; i < countof(kTestData); ++i)
|
||||
for (size_t i = 0; i < countof(kTestData); ++i) {
|
||||
stats_.add(i, kTestData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {}
|
||||
|
@ -62,13 +62,15 @@ protected:
|
||||
}
|
||||
|
||||
void DisplayClusterBoxes(Pix *pix) {
|
||||
if (!FLAGS_display)
|
||||
if (!FLAGS_display) {
|
||||
return;
|
||||
}
|
||||
const std::vector<BoxChar *> &boxchars = renderer_->GetBoxes();
|
||||
Boxa *boxes = boxaCreate(0);
|
||||
for (const auto &boxchar : boxchars) {
|
||||
if (boxchar->box())
|
||||
if (boxchar->box()) {
|
||||
boxaAddBox(boxes, const_cast<Box *>(boxchar->box()), L_CLONE);
|
||||
}
|
||||
}
|
||||
Pix *box_pix = pixDrawBoxaRandom(pix, boxes, 1);
|
||||
boxaDestroy(&boxes);
|
||||
@ -194,8 +196,9 @@ TEST_F(StringRendererTest, DoesRenderLigatures) {
|
||||
|
||||
static int FindBoxCharXCoord(const std::vector<BoxChar *> &boxchars, const std::string &ch) {
|
||||
for (const auto &boxchar : boxchars) {
|
||||
if (boxchar->ch() == ch)
|
||||
if (boxchar->ch() == ch) {
|
||||
return boxchar->box()->x;
|
||||
}
|
||||
}
|
||||
return INT_MAX;
|
||||
}
|
||||
@ -397,8 +400,9 @@ TEST_F(StringRendererTest, DoesRenderAllFontsToImage) {
|
||||
EXPECT_TRUE(pix != nullptr);
|
||||
EXPECT_STRNE("", font_used.c_str());
|
||||
}
|
||||
if (FLAGS_display)
|
||||
if (FLAGS_display) {
|
||||
pixDisplay(pix, 0, 0);
|
||||
}
|
||||
pixDestroy(&pix);
|
||||
} while (offset < strlen(kEngText));
|
||||
}
|
||||
|
@ -71,8 +71,9 @@ protected:
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
if (partition_.get() != nullptr)
|
||||
if (partition_.get() != nullptr) {
|
||||
partition_->DeleteBoxes();
|
||||
}
|
||||
DeletePartitionListBoxes();
|
||||
finder_.reset(nullptr);
|
||||
}
|
||||
@ -83,8 +84,9 @@ protected:
|
||||
|
||||
void MakePartition(int x_min, int y_min, int x_max, int y_max, int first_column,
|
||||
int last_column) {
|
||||
if (partition_.get() != nullptr)
|
||||
if (partition_.get() != nullptr) {
|
||||
partition_->DeleteBoxes();
|
||||
}
|
||||
TBOX box;
|
||||
box.set_to_given_coords(x_min, y_min, x_max, y_max);
|
||||
partition_.reset(ColPartition::FakePartition(box, PT_UNKNOWN, BRT_UNKNOWN, BTFT_NONE));
|
||||
@ -130,30 +132,37 @@ private:
|
||||
|
||||
TEST_F(TableFinderTest, GapInXProjectionNoGap) {
|
||||
int data[100];
|
||||
for (int &i : data)
|
||||
for (int &i : data) {
|
||||
i = 10;
|
||||
}
|
||||
EXPECT_FALSE(finder_->GapInXProjection(data, 100));
|
||||
}
|
||||
|
||||
TEST_F(TableFinderTest, GapInXProjectionEdgeGap) {
|
||||
int data[100];
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
data[i] = 2;
|
||||
for (int i = 10; i < 90; ++i)
|
||||
}
|
||||
for (int i = 10; i < 90; ++i) {
|
||||
data[i] = 10;
|
||||
for (int i = 90; i < 100; ++i)
|
||||
}
|
||||
for (int i = 90; i < 100; ++i) {
|
||||
data[i] = 2;
|
||||
}
|
||||
EXPECT_FALSE(finder_->GapInXProjection(data, 100));
|
||||
}
|
||||
|
||||
TEST_F(TableFinderTest, GapInXProjectionExists) {
|
||||
int data[100];
|
||||
for (int i = 0; i < 10; ++i)
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
data[i] = 10;
|
||||
for (int i = 10; i < 90; ++i)
|
||||
}
|
||||
for (int i = 10; i < 90; ++i) {
|
||||
data[i] = 2;
|
||||
for (int i = 90; i < 100; ++i)
|
||||
}
|
||||
for (int i = 90; i < 100; ++i) {
|
||||
data[i] = 10;
|
||||
}
|
||||
EXPECT_TRUE(finder_->GapInXProjection(data, 100));
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,11 @@ protected:
|
||||
}
|
||||
|
||||
void InsertPartitions() {
|
||||
for (int row = 0; row < 800; row += 20)
|
||||
for (int col = 0; col < 500; col += 25)
|
||||
for (int row = 0; row < 800; row += 20) {
|
||||
for (int col = 0; col < 500; col += 25) {
|
||||
InsertPartition(col + 1, row + 1, col + 24, row + 19);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InsertPartition(int left, int bottom, int right, int top) {
|
||||
@ -101,13 +103,16 @@ protected:
|
||||
void InsertLines() {
|
||||
line_box_.set_to_given_coords(100 - line_grid_->gridsize(), 10 - line_grid_->gridsize(),
|
||||
450 + line_grid_->gridsize(), 50 + line_grid_->gridsize());
|
||||
for (int i = 10; i <= 50; i += 10)
|
||||
for (int i = 10; i <= 50; i += 10) {
|
||||
InsertHorizontalLine(100, 450, i);
|
||||
for (int i = 100; i <= 450; i += 50)
|
||||
}
|
||||
for (int i = 100; i <= 450; i += 50) {
|
||||
InsertVerticalLine(i, 10, 50);
|
||||
}
|
||||
|
||||
for (int i = 100; i <= 200; i += 20)
|
||||
for (int i = 100; i <= 200; i += 20) {
|
||||
InsertHorizontalLine(0, 100, i);
|
||||
}
|
||||
}
|
||||
|
||||
void InsertHorizontalLine(int left, int right, int y) {
|
||||
@ -128,9 +133,11 @@ protected:
|
||||
}
|
||||
|
||||
void InsertCellsInLines() {
|
||||
for (int y = 10; y <= 50; y += 10)
|
||||
for (int x = 100; x <= 450; x += 50)
|
||||
for (int y = 10; y <= 50; y += 10) {
|
||||
for (int x = 100; x <= 450; x += 50) {
|
||||
InsertPartition(x + 1, y + 1, x + 49, y + 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBOX line_box_;
|
||||
@ -263,10 +270,12 @@ TEST_F(StructuredTableTest, CountHorizontalIntersectionsAll) {
|
||||
}
|
||||
|
||||
TEST_F(StructuredTableTest, VerifyLinedTableBasicPass) {
|
||||
for (int y = 10; y <= 50; y += 10)
|
||||
for (int y = 10; y <= 50; y += 10) {
|
||||
table_->InjectCellY(y);
|
||||
for (int x = 100; x <= 450; x += 50)
|
||||
}
|
||||
for (int x = 100; x <= 450; x += 50) {
|
||||
table_->InjectCellX(x);
|
||||
}
|
||||
InsertLines();
|
||||
InsertCellsInLines();
|
||||
table_->set_bounding_box(line_box_);
|
||||
@ -274,10 +283,12 @@ TEST_F(StructuredTableTest, VerifyLinedTableBasicPass) {
|
||||
}
|
||||
|
||||
TEST_F(StructuredTableTest, VerifyLinedTableHorizontalFail) {
|
||||
for (int y = 10; y <= 50; y += 10)
|
||||
for (int y = 10; y <= 50; y += 10) {
|
||||
table_->InjectCellY(y);
|
||||
for (int x = 100; x <= 450; x += 50)
|
||||
}
|
||||
for (int x = 100; x <= 450; x += 50) {
|
||||
table_->InjectCellX(x);
|
||||
}
|
||||
InsertLines();
|
||||
InsertCellsInLines();
|
||||
InsertPartition(101, 11, 299, 19);
|
||||
@ -286,10 +297,12 @@ TEST_F(StructuredTableTest, VerifyLinedTableHorizontalFail) {
|
||||
}
|
||||
|
||||
TEST_F(StructuredTableTest, VerifyLinedTableVerticalFail) {
|
||||
for (int y = 10; y <= 50; y += 10)
|
||||
for (int y = 10; y <= 50; y += 10) {
|
||||
table_->InjectCellY(y);
|
||||
for (int x = 100; x <= 450; x += 50)
|
||||
}
|
||||
for (int x = 100; x <= 450; x += 50) {
|
||||
table_->InjectCellX(x);
|
||||
}
|
||||
InsertLines();
|
||||
InsertCellsInLines();
|
||||
InsertPartition(151, 21, 199, 39);
|
||||
|
@ -103,8 +103,9 @@ TEST_F(TatweelTest, UnicharsetLoadKeepsTatweel) {
|
||||
int num_tatweel = 0;
|
||||
for (int i = 0; i < unicharset_.size(); ++i) {
|
||||
const char *utf8 = unicharset_.id_to_unichar(i);
|
||||
if (strstr(utf8, reinterpret_cast<const char *>(u8"\u0640")) != nullptr)
|
||||
if (strstr(utf8, reinterpret_cast<const char *>(u8"\u0640")) != nullptr) {
|
||||
++num_tatweel;
|
||||
}
|
||||
}
|
||||
LOG(INFO) << "Num tatweels in unicharset=" << num_tatweel;
|
||||
EXPECT_EQ(num_tatweel, 4);
|
||||
|
@ -184,8 +184,9 @@ protected:
|
||||
TBOX lower_box = word_box;
|
||||
lower_box.set_top(word_box.bottom());
|
||||
lower_box.set_bottom(word_box.bottom() - padding);
|
||||
if (tall_word)
|
||||
if (tall_word) {
|
||||
lower_box.move(ICOORD(0, padding / 2));
|
||||
}
|
||||
EvaluateBox(lower_box, false, kMinStrongTextValue, text, "Lower Word");
|
||||
EvaluateBox(lower_box, true, -1, text, "Lower Word not vertical");
|
||||
|
||||
@ -215,8 +216,9 @@ protected:
|
||||
upper_challenger.set_bottom(upper_box.top());
|
||||
upper_challenger.set_top(upper_box.top() + word_box.height());
|
||||
EvaluateDistance(upper_box, target_box, upper_challenger, text, "Upper Word");
|
||||
if (tall_word)
|
||||
if (tall_word) {
|
||||
lower_box.move(ICOORD(0, padding / 2));
|
||||
}
|
||||
lower_box.set_bottom(lower_box.top() - padding);
|
||||
target_box = word_box;
|
||||
target_box.set_bottom(lower_box.top());
|
||||
|
@ -32,83 +32,108 @@ protected:
|
||||
MathData() : num_squares_(0), num_triangles_(0) {}
|
||||
void Setup() {
|
||||
// Setup some data.
|
||||
for (int s = 0; s < 42; ++s)
|
||||
for (int s = 0; s < 42; ++s) {
|
||||
squares_.push_back(s * s);
|
||||
}
|
||||
num_squares_ = squares_.size();
|
||||
for (int t = 0; t < 52; ++t)
|
||||
for (int t = 0; t < 52; ++t) {
|
||||
triangles_.push_back(t * (t + 1) / 2);
|
||||
}
|
||||
num_triangles_ = triangles_.size();
|
||||
}
|
||||
void ExpectEq(const MathData &other) {
|
||||
// Check the data.
|
||||
EXPECT_EQ(num_squares_, other.num_squares_);
|
||||
for (int s = 0; s < squares_.size(); ++s)
|
||||
for (int s = 0; s < squares_.size(); ++s) {
|
||||
EXPECT_EQ(squares_[s], other.squares_[s]);
|
||||
}
|
||||
EXPECT_EQ(num_triangles_, other.num_triangles_);
|
||||
for (int s = 0; s < triangles_.size(); ++s)
|
||||
for (int s = 0; s < triangles_.size(); ++s) {
|
||||
EXPECT_EQ(triangles_[s], other.triangles_[s]);
|
||||
}
|
||||
}
|
||||
bool Serialize(TFile *fp) {
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1)
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->Serialize(squares_))
|
||||
}
|
||||
if (!fp->Serialize(squares_)) {
|
||||
return false;
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1)
|
||||
}
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->Serialize(triangles_))
|
||||
}
|
||||
if (!fp->Serialize(triangles_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool DeSerialize(TFile *fp) {
|
||||
if (fp->FReadEndian(&num_squares_, sizeof(num_squares_), 1) != 1)
|
||||
if (fp->FReadEndian(&num_squares_, sizeof(num_squares_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->DeSerialize(squares_))
|
||||
}
|
||||
if (!fp->DeSerialize(squares_)) {
|
||||
return false;
|
||||
if (fp->FReadEndian(&num_triangles_, sizeof(num_triangles_), 1) != 1)
|
||||
}
|
||||
if (fp->FReadEndian(&num_triangles_, sizeof(num_triangles_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->DeSerialize(triangles_))
|
||||
}
|
||||
if (!fp->DeSerialize(triangles_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool SerializeBigEndian(TFile *fp) {
|
||||
ReverseN(&num_squares_, sizeof(num_squares_));
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1)
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1) {
|
||||
return false;
|
||||
}
|
||||
// Write an additional reversed size before the vector, which will get
|
||||
// used as its size on reading.
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1)
|
||||
if (fp->FWrite(&num_squares_, sizeof(num_squares_), 1) != 1) {
|
||||
return false;
|
||||
for (int &square : squares_)
|
||||
}
|
||||
for (int &square : squares_) {
|
||||
ReverseN(&square, sizeof(square));
|
||||
if (!fp->Serialize(squares_))
|
||||
}
|
||||
if (!fp->Serialize(squares_)) {
|
||||
return false;
|
||||
}
|
||||
ReverseN(&num_triangles_, sizeof(num_triangles_));
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1)
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1) {
|
||||
return false;
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1)
|
||||
}
|
||||
if (fp->FWrite(&num_triangles_, sizeof(num_triangles_), 1) != 1) {
|
||||
return false;
|
||||
for (auto &triangle : triangles_)
|
||||
}
|
||||
for (auto &triangle : triangles_) {
|
||||
ReverseN(&triangle, sizeof(triangles_[0]));
|
||||
}
|
||||
return fp->Serialize(triangles_);
|
||||
}
|
||||
bool DeSerializeBigEndian(TFile *fp) {
|
||||
if (fp->FReadEndian(&num_squares_, sizeof(num_squares_), 1) != 1)
|
||||
if (fp->FReadEndian(&num_squares_, sizeof(num_squares_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->DeSerialize(squares_))
|
||||
}
|
||||
if (!fp->DeSerialize(squares_)) {
|
||||
return false;
|
||||
}
|
||||
// The first element is the size that was written, so we will delete it
|
||||
// and read the last element separately.
|
||||
int last_element;
|
||||
if (fp->FReadEndian(&last_element, sizeof(last_element), 1) != 1)
|
||||
if (fp->FReadEndian(&last_element, sizeof(last_element), 1) != 1) {
|
||||
return false;
|
||||
}
|
||||
squares_.erase(squares_.begin());
|
||||
squares_.push_back(last_element);
|
||||
if (fp->FReadEndian(&num_triangles_, sizeof(num_triangles_), 1) != 1)
|
||||
if (fp->FReadEndian(&num_triangles_, sizeof(num_triangles_), 1) != 1) {
|
||||
return false;
|
||||
if (!fp->DeSerialize(triangles_))
|
||||
}
|
||||
if (!fp->DeSerialize(triangles_)) {
|
||||
return false;
|
||||
if (fp->FReadEndian(&last_element, sizeof(last_element), 1) != 1)
|
||||
}
|
||||
if (fp->FReadEndian(&last_element, sizeof(last_element), 1) != 1) {
|
||||
return false;
|
||||
}
|
||||
triangles_.erase(triangles_.begin());
|
||||
triangles_.push_back(last_element);
|
||||
return true;
|
||||
|
@ -79,8 +79,9 @@ protected:
|
||||
// Count the number of times each code is used in each element of
|
||||
// RecodedCharID.
|
||||
RecodedCharID zeros;
|
||||
for (int i = 0; i < RecodedCharID::kMaxCodeLen; ++i)
|
||||
for (int i = 0; i < RecodedCharID::kMaxCodeLen; ++i) {
|
||||
zeros.Set(i, 0);
|
||||
}
|
||||
int code_range = compressed_.code_range();
|
||||
std::vector<RecodedCharID> times_seen(code_range, zeros);
|
||||
for (int u = 0; u <= unicharset_.size(); ++u) {
|
||||
@ -112,8 +113,9 @@ protected:
|
||||
for (int c = 0; c < code_range; ++c) {
|
||||
int num_used = 0;
|
||||
for (int i = 0; i < RecodedCharID::kMaxCodeLen; ++i) {
|
||||
if (times_seen[c](i) != 0)
|
||||
if (times_seen[c](i) != 0) {
|
||||
++num_used;
|
||||
}
|
||||
}
|
||||
EXPECT_GE(num_used, 1) << "c=" << c << "/" << code_range;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user