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