Added category indices in iOS failure description
This commit is contained in:
parent
cf945d3aeb
commit
67735a6fd3
|
@ -32,13 +32,16 @@ static NSString *const kExpectedErrorDomain = @"com.google.mediapipe.tasks";
|
|||
[error.localizedDescription rangeOfString:expectedError.localizedDescription].location, \
|
||||
NSNotFound)
|
||||
|
||||
#define AssertEqualCategoryArrays(categories, expectedCategories) \
|
||||
XCTAssertEqual(categories.count, expectedCategories.count); \
|
||||
for (int i = 0; i < categories.count; i++) { \
|
||||
XCTAssertEqual(categories[i].index, expectedCategories[i].index); \
|
||||
XCTAssertEqualWithAccuracy(categories[i].score, expectedCategories[i].score, 1e-6); \
|
||||
XCTAssertEqualObjects(categories[i].categoryName, expectedCategories[i].categoryName); \
|
||||
XCTAssertEqualObjects(categories[i].displayName, expectedCategories[i].displayName); \
|
||||
#define AssertEqualCategoryArrays(categories, expectedCategories) \
|
||||
XCTAssertEqual(categories.count, expectedCategories.count); \
|
||||
for (int i = 0; i < categories.count; i++) { \
|
||||
XCTAssertEqual(categories[i].index, expectedCategories[i].index, @"index i = %d", i); \
|
||||
XCTAssertEqualWithAccuracy(categories[i].score, expectedCategories[i].score, 1e-6, \
|
||||
@"index i = %d", i); \
|
||||
XCTAssertEqualObjects(categories[i].categoryName, expectedCategories[i].categoryName, \
|
||||
@"index i = %d", i); \
|
||||
XCTAssertEqualObjects(categories[i].displayName, expectedCategories[i].displayName, \
|
||||
@"index i = %d", i); \
|
||||
}
|
||||
|
||||
#define AssertTextClassifierResultHasOneHead(textClassifierResult) \
|
||||
|
|
|
@ -60,33 +60,55 @@ class TextClassifierTests: XCTestCase {
|
|||
|
||||
func assertCategoriesAreEqual(
|
||||
category: ResultCategory,
|
||||
expectedCategory: ResultCategory) {
|
||||
expectedCategory: ResultCategory,
|
||||
indexInCategoryList: Int) {
|
||||
XCTAssertEqual(
|
||||
category.index,
|
||||
expectedCategory.index)
|
||||
expectedCategory.index,
|
||||
String(
|
||||
format: """
|
||||
category[%d].index and expectedCategory[%d].index are not equal.
|
||||
""", indexInCategoryList))
|
||||
XCTAssertEqual(
|
||||
category.score,
|
||||
expectedCategory.score,
|
||||
accuracy:1e-6)
|
||||
accuracy:1e-6,
|
||||
String(
|
||||
format: """
|
||||
category[%d].score and expectedCategory[%d].score are not equal.
|
||||
""", indexInCategoryList))
|
||||
XCTAssertEqual(
|
||||
category.categoryName,
|
||||
expectedCategory.categoryName)
|
||||
expectedCategory.categoryName,
|
||||
String(
|
||||
format: """
|
||||
category[%d].categoryName and expectedCategory[%d].categoryName are \
|
||||
not equal.
|
||||
""", indexInCategoryList))
|
||||
XCTAssertEqual(
|
||||
category.displayName,
|
||||
expectedCategory.displayName)
|
||||
expectedCategory.displayName,
|
||||
String(
|
||||
format: """
|
||||
category[%d].displayName and expectedCategory[%d].displayName are \
|
||||
not equal.
|
||||
""", indexInCategoryList))
|
||||
}
|
||||
|
||||
func assertEqualCategoryArrays(
|
||||
categoryArray: [ResultCategory],
|
||||
expectedCategoryArray:[ResultCategory]) {
|
||||
|
||||
XCTAssertEqual(categoryArray.count, expectedCategoryArray.count)
|
||||
XCTAssertEqual(
|
||||
categoryArray.count,
|
||||
expectedCategoryArray.count)
|
||||
|
||||
for (category, expectedCategory) in
|
||||
zip(categoryArray, expectedCategoryArray) {
|
||||
for (index, (category, expectedCategory)) in
|
||||
zip(categoryArray, expectedCategoryArray).enumerated() {
|
||||
assertCategoriesAreEqual(
|
||||
category:category,
|
||||
expectedCategory:expectedCategory)
|
||||
expectedCategory:expectedCategory,
|
||||
indexInCategoryList:index)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user