Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 1.14 KB

how_to_write_unit_test.md

File metadata and controls

18 lines (11 loc) · 1.14 KB

How to Write Unit Test for C API

To ensure the accuracy of C API, all interfaces need to implement function level unit test at least. According to the object define, all implemented unit test cases are located in this folder.

The generated binary ov_capi_test included the unit cases about all implemented C API interfaces.

If developer wrap new interfaces from OpenVINO C++, you also need to add the unit test case in the correct location. Here is an example wrap C++ interface to C wrap core.

Create unit test case for this interface. At first, this interface is for core operation so the location should at ov_core_test.cpp. Also, the interface has default parameter so need to make unit test case for parameter missing. The final based function level test like:

TEST(ov_core, ov_core_read_model) {
ov_core_t* core = nullptr;
OV_EXPECT_OK(ov_core_create(&core));
EXPECT_NE(nullptr, core);
ov_model_t* model = nullptr;
OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model));
EXPECT_NE(nullptr, model);
ov_model_free(model);
ov_core_free(core);
}
TEST(ov_core, ov_core_read_model_no_bin) {
ov_core_t* core = nullptr;
OV_EXPECT_OK(ov_core_create(&core));
EXPECT_NE(nullptr, core);
ov_model_t* model = nullptr;
OV_EXPECT_OK(ov_core_read_model(core, xml, nullptr, &model));
EXPECT_NE(nullptr, model);
ov_model_free(model);
ov_core_free(core);
}

See also