onnxruntime/objectivec/test/assertion_utils.h
Vrajang Parikh 960e320dff
Objective C Training API: TrainingSession (#16374)
### Description
- Implement Objective-C binding for `ORTTrainingSession`
- Add `ORTUtils` utility class to handle conversion between C++ and
Objective-C types
- Add test case for saving checkpoint
- Add unit test cases for `ORTTrainingSession`

### Motivation and Context
This PR is part of implementing Objective-C bindings for training API.
It implements objective-c binding for training session. The objective-C
API closely resembles the C++ API.

---------

Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
2023-06-28 09:13:56 -07:00

46 lines
2.4 KiB
Objective-C

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <XCTest/XCTest.h>
NS_ASSUME_NONNULL_BEGIN
#define ORTAssertNullableResultSuccessful(result, error) \
do { \
XCTAssertNotNil(result, @"Expected non-nil result but got nil. Error: %@", error); \
XCTAssertNil(error); \
} while (0)
#define ORTAssertBoolResultSuccessful(result, error) \
do { \
XCTAssertTrue(result, @"Expected true result but got false. Error: %@", error); \
XCTAssertNil(error); \
} while (0)
#define ORTAssertNullableResultUnsuccessful(result, error) \
do { \
XCTAssertNil(result); \
XCTAssertNotNil(error); \
} while (0)
#define ORTAssertBoolResultUnsuccessful(result, error) \
do { \
XCTAssertFalse(result); \
XCTAssertNotNil(error); \
} while (0)
#define ORTAssertEqualFloatAndNoError(expected, result, error) \
do { \
XCTAssertEqualWithAccuracy(expected, result, 1e-3f, @"Expected %f but got %f. Error:%@", expected, result, error); \
XCTAssertNil(error); \
} while (0)
#define ORTAssertEqualFloatArrays(expected, result) \
do { \
XCTAssertEqual(expected.count, result.count); \
for (size_t i = 0; i < expected.count; ++i) { \
XCTAssertEqualWithAccuracy([expected[i] floatValue], [result[i] floatValue], 1e-3f); \
} \
} while (0)
NS_ASSUME_NONNULL_END