MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / testWriteToOutputArray

Function testWriteToOutputArray

test/arrayfire_test.cpp:731–769  ·  view source on GitHub ↗

Partner function of genTestOutputArray. This uses the same "special" array that genTestOutputArray generates, and checks whether the af_* function wrote to that array correctly

Source from the content-addressed store, hash-verified

729// array that genTestOutputArray generates, and checks whether the
730// af_* function wrote to that array correctly
731::testing::AssertionResult testWriteToOutputArray(
732 std::string gold_name, std::string result_name, const af_array gold,
733 const af_array out, TestOutputArrayInfo *metadata) {
734 // In the case of NULL_ARRAY, the output array starts out as null.
735 // After the af_* function is called, it shouldn't be null anymore
736 if (metadata->getOutputArrayType() == NULL_ARRAY) {
737 if (out == 0) {
738 return ::testing::AssertionFailure()
739 << "Output af_array " << result_name << " is null";
740 }
741 metadata->setOutput(out);
742 }
743 // For every other case, must check if the af_array generated by
744 // genTestOutputArray was used by the af_* function as its output array
745 else {
746 if (metadata->getOutput() != out) {
747 return ::testing::AssertionFailure()
748 << "af_array POINTER MISMATCH:\n"
749 << " Actual: " << out << "\n"
750 << "Expected: " << metadata->getOutput();
751 }
752 }
753
754 if (metadata->getOutputArrayType() == SUB_ARRAY) {
755 // There are two full arrays. One will be injected with the gold
756 // subarray, the other should have already been injected with the
757 // af_* function's output. Then we compare the two full arrays
758 af_array gold_full_array = metadata->getFullOutputCopy();
759 af_assign_seq(&gold_full_array, gold_full_array,
760 metadata->getSubArrayNumDims(),
761 metadata->getSubArrayIdxs(), gold);
762
763 return assertArrayEq(gold_name, result_name,
764 metadata->getFullOutputCopy(),
765 metadata->getFullOutput());
766 } else {
767 return assertArrayEq(gold_name, result_name, gold, out);
768 }
769}
770
771// Called by ASSERT_SPECIAL_ARRAYS_EQ
772::testing::AssertionResult assertArrayEq(std::string aName, std::string bName,

Callers 1

assertArrayEqFunction · 0.85

Calls 9

assertArrayEqFunction · 0.85
getOutputArrayTypeMethod · 0.80
setOutputMethod · 0.80
getOutputMethod · 0.80
getFullOutputCopyMethod · 0.80
getSubArrayNumDimsMethod · 0.80
getSubArrayIdxsMethod · 0.80
getFullOutputMethod · 0.80
af_assign_seqFunction · 0.50

Tested by

no test coverage detected