forked from apache/arrow-adbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadbc_version_100_compatibility_test.cc
More file actions
113 lines (93 loc) · 4.03 KB
/
Copy pathadbc_version_100_compatibility_test.cc
File metadata and controls
113 lines (93 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include "adbc_version_100.h"
#include "arrow-adbc/adbc.h"
#include "arrow-adbc/adbc_driver_manager.h"
#include "validation/adbc_validation_util.h"
namespace adbc {
using adbc_validation::IsOkStatus;
using adbc_validation::IsStatus;
class AdbcVersion : public ::testing::Test {
public:
void SetUp() override {
std::memset(&driver, 0, sizeof(driver));
std::memset(&error, 0, sizeof(error));
}
void TearDown() override {
if (error.release) {
error.release(&error);
}
if (driver.release) {
ASSERT_THAT(driver.release(&driver, &error), IsOkStatus(&error));
ASSERT_EQ(driver.private_data, nullptr);
ASSERT_EQ(driver.private_manager, nullptr);
}
}
protected:
struct AdbcDriver driver = {};
struct AdbcError error = {};
};
TEST_F(AdbcVersion, StructSize) {
ASSERT_EQ(sizeof(AdbcErrorVersion100), ADBC_ERROR_1_0_0_SIZE);
ASSERT_EQ(sizeof(AdbcError), ADBC_ERROR_1_1_0_SIZE);
ASSERT_EQ(sizeof(AdbcError), ADBC_ERROR_1_2_0_SIZE);
ASSERT_EQ(sizeof(AdbcDriverVersion100), ADBC_DRIVER_1_0_0_SIZE);
ASSERT_EQ(offsetof(struct AdbcDriver, StatementExecuteMulti), ADBC_DRIVER_1_1_0_SIZE);
ASSERT_EQ(sizeof(AdbcDriver), ADBC_DRIVER_1_2_0_SIZE);
}
// Initialize a version 1.0.0 driver with the version 1.1.0 driver struct.
TEST_F(AdbcVersion, OldDriverNewLayout) {
ASSERT_THAT(Version100DriverInit(ADBC_VERSION_1_1_0, &driver, &error),
IsStatus(ADBC_STATUS_NOT_IMPLEMENTED, &error));
ASSERT_THAT(Version100DriverInit(ADBC_VERSION_1_0_0, &driver, &error),
IsOkStatus(&error));
}
// Initialize a version 1.0.0 driver with the new driver manager/new version.
TEST_F(AdbcVersion, OldDriverNewManager) {
ASSERT_THAT(AdbcLoadDriverFromInitFunc(&Version100DriverInit, ADBC_VERSION_1_1_0,
&driver, &error),
IsOkStatus(&error));
EXPECT_NE(driver.ErrorGetDetailCount, nullptr);
EXPECT_NE(driver.ErrorGetDetail, nullptr);
EXPECT_NE(driver.DatabaseGetOption, nullptr);
EXPECT_NE(driver.DatabaseGetOptionBytes, nullptr);
EXPECT_NE(driver.DatabaseGetOptionDouble, nullptr);
EXPECT_NE(driver.DatabaseGetOptionInt, nullptr);
EXPECT_NE(driver.DatabaseSetOptionInt, nullptr);
EXPECT_NE(driver.DatabaseSetOptionDouble, nullptr);
EXPECT_NE(driver.ConnectionCancel, nullptr);
EXPECT_NE(driver.ConnectionGetOption, nullptr);
EXPECT_NE(driver.ConnectionGetOptionBytes, nullptr);
EXPECT_NE(driver.ConnectionGetOptionDouble, nullptr);
EXPECT_NE(driver.ConnectionGetOptionInt, nullptr);
EXPECT_NE(driver.ConnectionSetOptionInt, nullptr);
EXPECT_NE(driver.ConnectionSetOptionDouble, nullptr);
EXPECT_NE(driver.StatementCancel, nullptr);
EXPECT_NE(driver.StatementExecuteSchema, nullptr);
EXPECT_NE(driver.StatementGetOption, nullptr);
EXPECT_NE(driver.StatementGetOptionBytes, nullptr);
EXPECT_NE(driver.StatementGetOptionDouble, nullptr);
EXPECT_NE(driver.StatementGetOptionInt, nullptr);
EXPECT_NE(driver.StatementSetOptionInt, nullptr);
EXPECT_NE(driver.StatementSetOptionDouble, nullptr);
}
// N.B. see postgresql_test.cc for backwards compatibility test of AdbcError
// N.B. see postgresql_test.cc for backwards compatibility test of AdbcDriver
} // namespace adbc