bool FingerAngles::Compare(const FingerAngles &other, float tolerance) const { bool status = true; status = status && CompareValues(Finger1, other.Finger1, tolerance); status = status && CompareValues(Finger2, other.Finger2, tolerance); status = status && CompareValues(Finger3, other.Finger3, tolerance); return status; }
// Note: As long as frame durations and reconstructed frames are identical, it // is OK for other aspects like offsets, dispose/blend method to vary. static int CompareAnimatedImagePair(const AnimatedImage* const img1, const AnimatedImage* const img2, int premultiply, double min_psnr) { int ok = 1; const int is_multi_frame_image = (img1->num_frames > 1); uint32_t i; ok = CompareValues(img1->canvas_width, img2->canvas_width, "Canvas width mismatch") && ok; ok = CompareValues(img1->canvas_height, img2->canvas_height, "Canvas height mismatch") && ok; ok = CompareValues(img1->num_frames, img2->num_frames, "Frame count mismatch") && ok; if (!ok) return 0; // These are fatal failures, can't proceed. if (is_multi_frame_image) { // Checks relevant for multi-frame images only. ok = CompareValues(img1->loop_count, img2->loop_count, "Loop count mismatch") && ok; ok = CompareBackgroundColor(img1->bgcolor, img2->bgcolor, premultiply) && ok; } for (i = 0; i < img1->num_frames; ++i) { // Pixel-by-pixel comparison. const uint8_t* const rgba1 = img1->frames[i].rgba; const uint8_t* const rgba2 = img2->frames[i].rgba; int max_diff; double psnr; if (is_multi_frame_image) { // Check relevant for multi-frame images only. const char format[] = "Frame #%d, duration mismatch"; char tmp[sizeof(format) + 8]; ok = ok && (snprintf(tmp, sizeof(tmp), format, i) >= 0); ok = ok && CompareValues(img1->frames[i].duration, img2->frames[i].duration, tmp); } GetDiffAndPSNR(rgba1, rgba2, img1->canvas_width, img1->canvas_height, premultiply, &max_diff, &psnr); if (min_psnr > 0.) { if (psnr < min_psnr) { fprintf(stderr, "Frame #%d, psnr = %.2lf (min_psnr = %f)\n", i, psnr, min_psnr); ok = 0; } } else { if (max_diff != 0) { fprintf(stderr, "Frame #%d, max pixel diff: %d\n", i, max_diff); ok = 0; } } } return ok; }
bool BigNumValue::Compare (Value *v, CSSM_DB_OPERATOR op) { if (v->GetValueType () != mBaseFormat) CSSMError::ThrowCSSMError (CSSMERR_DL_INCOMPATIBLE_FIELD_FORMAT); BigNumValue* sv = (BigNumValue*) v; int result; if (!CompareSignBits (sv, result)) if (!CompareLengths (sv, result)) CompareValues (sv, result); switch (op) { case CSSM_DB_EQUAL: return result == 0; case CSSM_DB_NOT_EQUAL: return result != 0; case CSSM_DB_LESS_THAN: return result < 0; case CSSM_DB_GREATER_THAN: return result > 0; } CSSMError::ThrowCSSMError (CSSMERR_DL_UNSUPPORTED_OPERATOR); }
void PropertyConstructionTest::TestProperty( BPropertyInfo *propTest, const property_info *prop_list, const value_info *value_list, int32 prop_count, int32 value_count, ssize_t flat_size, const char *lflat_data, const char *bflat_data) { assert(propTest->CountProperties() == prop_count); assert(propTest->CountValues() == value_count); CompareProperties(propTest->Properties(), prop_list, prop_count); CompareValues(propTest->Values(), value_list, value_count); }
/* Function LListSearch * -------------------- * Searches for node_value in linked list. Returns pointer to value * of node. * * *root: LList_Node pointer to start of linked list. * *node_value: Pointer to value to be removed from list. * *CompareValues: Pointer to function which compares values. Returns * 1 if values are the same, 0 otherwise. * * Returns: Pointer to value of removed node, or NULL if * value not found. */ void *LListSearch( LList_Node *root, const void *node_value, int(*CompareValues)(const void *value1, const void *value2)) { LList_Node *curr; if (LListIsEmpty(root)) return NULL; curr = root; /* Look for node value. */ while (CompareValues(curr->node_value, node_value) != 1) { if (curr->next == NULL) /* Value not found. */ return NULL; curr = curr->next; } return curr->node_value; }
bool JacoAngles::Compare(const JacoAngles &other, float tolerance) const { bool status = true; status = status && CompareValues(Actuator1, other.Actuator1, tolerance); status = status && CompareValues(Actuator2, other.Actuator2, tolerance); status = status && CompareValues(Actuator3, other.Actuator3, tolerance); status = status && CompareValues(Actuator4, other.Actuator4, tolerance); status = status && CompareValues(Actuator5, other.Actuator5, tolerance); status = status && CompareValues(Actuator6, other.Actuator6, tolerance); return status; }
bool JacoPose::Compare(const JacoPose &other, float tolerance) const { bool status = true; status = status && CompareValues(X, other.X, tolerance); status = status && CompareValues(Y, other.Y, tolerance); status = status && CompareValues(Z, other.Z, tolerance); status = status && CompareValues(ThetaX, other.ThetaX, tolerance); status = status && CompareValues(ThetaY, other.ThetaY, tolerance); status = status && CompareValues(ThetaZ, other.ThetaZ, tolerance); return status; }
/* Function LListPop * ----------------- * Pops (i.e. removes from list and returns) node_value. * CompareValues is used to compare node values and node_value. * If node_value is NULL, the last node of the list is popped. * Returns a pointer to the value of the removed node, or NULL if * no matching node is found. * * *root: LList_Node pointer to start of linked list. * *node_value: Pointer to value to be removed from list. * *CompareValues: Pointer to function which compares values. Returns * 1 if values are the same, 0 otherwise. * * Returns: Pointer to value of removed node, or NULL if * value not found. */ void *LListPop( LList_Node *root, const void *node_value, int (*CompareValues)(const void *value1, const void *value2)) { LList_Node *prev, *curr; void *found_node_value; prev = root; curr = root; if (LListIsEmpty(curr)) return NULL; if (node_value == NULL) { /* Pop last node. */ while (curr->next != NULL) { prev = curr; curr = curr->next; } found_node_value = curr->node_value; curr->node_value = NULL; if (curr == root) { /* Only one node in list. */ return found_node_value; } free(curr); prev->next = NULL; return found_node_value; } /* Look for node_value. */ while (CompareValues(curr->node_value, node_value) != 1) { if (curr->next == NULL) /* Value not found in list. */ return NULL; prev = curr; curr = curr->next; } if (curr->next != NULL) { /* Value found in list and not last node. */ found_node_value = curr->node_value; curr->node_value = NULL; if (curr == root) { /* First node contains value, set root to contain next node value. */ curr = root->next; root->node_value = root->next->node_value; root->next = root->next->next; free(curr); return found_node_value; } /* Remove node containing value. */ prev->next = curr->next; free(curr); return found_node_value; } else { /* Value found in last node of list.*/ found_node_value = curr->node_value; curr->node_value = NULL; if (curr == prev) { /* Only one node in list. */ return found_node_value; } /* Remove node containing value. */ prev->next = NULL; free(curr); return found_node_value; } }