Skip to content

Commit

Permalink
X
Browse files Browse the repository at this point in the history
  • Loading branch information
mewim committed Apr 19, 2023
1 parent a4d394a commit f61bac8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/c_api/prepared_statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ void kuzu_prepared_statement_bind_value(
kuzu_prepared_statement* prepared_statement, char* param_name, kuzu_value* value) {
auto value_ptr = std::make_shared<Value>(*static_cast<Value*>(value->_value));
kuzu_prepared_statement_bind_cpp_value(prepared_statement, param_name, value_ptr);
}
}
1 change: 0 additions & 1 deletion src/c_api/query_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ bool kuzu_query_result_has_next(kuzu_query_result* query_result) {
kuzu_flat_tuple* kuzu_query_result_get_next(kuzu_query_result* query_result) {
auto flat_tuple = static_cast<QueryResult*>(query_result->_query_result)->getNext();
auto* flat_tuple_c = (kuzu_flat_tuple*)malloc(sizeof(kuzu_flat_tuple));
// TODO: Check if this design is correct?
flat_tuple_c->_flat_tuple = new std::shared_ptr<FlatTuple>(flat_tuple);
return flat_tuple_c;
}
Expand Down
16 changes: 11 additions & 5 deletions test/c_api/database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ class CApiDatabaseTest : public EmptyDBTest {
TEST_F(CApiDatabaseTest, CreationAndDestroy) {
auto databasePath = TestHelper::getTmpTestDir();
auto databasePathCStr = databasePath.c_str();
auto cDatabase = kuzu_database_init(databasePathCStr, 0);
ASSERT_NE(cDatabase, nullptr);
ASSERT_NE(cDatabase->_database, nullptr);
auto databaseCpp = static_cast<Database*>(cDatabase->_database);
auto database = kuzu_database_init(databasePathCStr, 0);
ASSERT_NE(database, nullptr);
ASSERT_NE(database->_database, nullptr);
auto databaseCpp = static_cast<Database*>(database->_database);
ASSERT_NE(databaseCpp, nullptr);
kuzu_database_destroy(cDatabase);
kuzu_database_destroy(database);
}

TEST_F(CApiDatabaseTest, CreationInvalidPath) {
auto databasePathCStr = (char*)"";
auto database = kuzu_database_init(databasePathCStr, 0);
ASSERT_EQ(database, nullptr);
}

TEST_F(CApiDatabaseTest, SetLoggingLevel) {
Expand Down
3 changes: 3 additions & 0 deletions test/c_api/value_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ TEST_F(CApiValueTest, GetRelVal) {
auto propertiesSize = kuzu_rel_val_get_property_size(rel);
ASSERT_EQ(propertiesSize, 5);
free(relLabel);
kuzu_rel_val_destroy(rel);
kuzu_value_destroy(value);
kuzu_flat_tuple_destroy(flatTuple);
kuzu_query_result_destroy(result);
Expand Down Expand Up @@ -715,6 +716,7 @@ TEST_F(CApiValueTest, RelValClone) {
auto dstID = kuzu_internal_id_t{2, 456};
auto relVal = kuzu_rel_val_create(srcID, dstID, (char*)"knows");
auto relValClone = kuzu_rel_val_clone(relVal);
kuzu_rel_val_destroy(relVal);
auto srcIDVal = kuzu_rel_val_get_src_id_val(relValClone);
auto dstIDVal = kuzu_rel_val_get_dst_id_val(relValClone);
auto srcIDClone = kuzu_value_get_internal_id(srcIDVal);
Expand Down Expand Up @@ -795,4 +797,5 @@ TEST_F(CApiValueTest, RelValToString) {
ASSERT_STREQ(str, "(1:123)-[label:knows, {fName:Alice, age:10}]->(2:456)");

kuzu_rel_val_destroy(relVal);
free(str);
}

0 comments on commit f61bac8

Please sign in to comment.