#include "TestLib.h"
int dpiTest_100_validMajorMinor(dpiTestCase *testCase, dpiTestParams *params)
{
dpiErrorInfo errorInfo;
dpiContext *context;
if (dpiContext_create(DPI_MAJOR_VERSION, DPI_MINOR_VERSION, &context,
&errorInfo) < 0)
return dpiTestCase_setFailedFromErrorInfo(testCase, &errorInfo);
if (dpiContext_destroy(context) < 0) {
dpiContext_getError(context, &errorInfo);
return dpiTestCase_setFailedFromErrorInfo(testCase, &errorInfo);
}
return DPI_SUCCESS;
}
int dpiTest_101_diffMajor(dpiTestCase *testCase, dpiTestParams *params)
{
dpiErrorInfo errorInfo;
dpiContext *context;
dpiContext_create(DPI_MAJOR_VERSION + 1, DPI_MINOR_VERSION, &context,
&errorInfo);
return dpiTestCase_expectError(testCase, "DPI-1020:");
}
int dpiTest_102_diffMinor(dpiTestCase *testCase, dpiTestParams *params)
{
dpiErrorInfo errorInfo;
dpiContext *context;
dpiContext_create(DPI_MAJOR_VERSION, DPI_MINOR_VERSION + 1, &context,
&errorInfo);
return dpiTestCase_expectError(testCase, "DPI-1020:");
}
int dpiTest_103_createWithNull(dpiTestCase *testCase, dpiTestParams *params)
{
dpiErrorInfo errorInfo;
dpiContext_create(DPI_MAJOR_VERSION, DPI_MINOR_VERSION, NULL, &errorInfo);
return dpiTestCase_expectError(testCase, "DPI-1046:");
}
int dpiTest_104_destroyWithNull(dpiTestCase *testCase, dpiTestParams *params)
{
dpiContext_destroy(NULL);
return dpiTestCase_expectError(testCase, "DPI-1002:");
}
int dpiTest_105_destroyTwice(dpiTestCase *testCase, dpiTestParams *params)
{
dpiErrorInfo errorInfo;
dpiContext *context;
if (dpiContext_create(DPI_MAJOR_VERSION, DPI_MINOR_VERSION, &context,
&errorInfo) < 0)
return dpiTestCase_setFailedFromErrorInfo(testCase, &errorInfo);
if (dpiContext_destroy(context) < 0)
return dpiTestCase_setFailedFromErrorInfo(testCase, &errorInfo);
dpiContext_destroy(context);
return dpiTestCase_expectError(testCase, "DPI-1002:");
}
int main(int argc, char **argv)
{
dpiTestSuite_initialize(100);
dpiTestSuite_addCase(dpiTest_100_validMajorMinor,
"dpiContext_create() with valid major/minor versions");
dpiTestSuite_addCase(dpiTest_101_diffMajor,
"dpiContext_create() with invalid major version");
dpiTestSuite_addCase(dpiTest_102_diffMinor,
"dpiContext_create() with invalid minor version");
dpiTestSuite_addCase(dpiTest_103_createWithNull,
"dpiContext_create() with NULL pointer");
dpiTestSuite_addCase(dpiTest_104_destroyWithNull,
"dpiContext_destroy() with NULL pointer");
dpiTestSuite_addCase(dpiTest_105_destroyTwice,
"dpiContext_destroy() called twice on same pointer");
return dpiTestSuite_run();
}