Skip to content

Commit 5d6a52f

Browse files
committed
Improved tests
1 parent 3b8850a commit 5d6a52f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/pqxx_test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ void test_vector(pqxx::connection &conn) {
3434
assert(res[0][0].as<pgvector::Vector>() == embedding2);
3535
assert(res[1][0].as<pgvector::Vector>() == embedding);
3636
assert(!res[2][0].as<std::optional<pgvector::Vector>>().has_value());
37+
38+
assert(pqxx::to_string(embedding) == "[1,2,3]");
39+
assert(pqxx::from_string<pgvector::Vector>("[1,2,3]") == embedding);
3740
}
3841

3942
void test_halfvec(pqxx::connection &conn) {
@@ -51,6 +54,9 @@ void test_halfvec(pqxx::connection &conn) {
5154
assert(res[0][0].as<pgvector::HalfVector>() == embedding2);
5255
assert(res[1][0].as<pgvector::HalfVector>() == embedding);
5356
assert(!res[2][0].as<std::optional<pgvector::HalfVector>>().has_value());
57+
58+
assert(pqxx::to_string(embedding) == "[1,2,3]");
59+
assert(pqxx::from_string<pgvector::HalfVector>("[1,2,3]") == embedding);
5460
}
5561

5662
void test_bit(pqxx::connection &conn) {
@@ -81,6 +87,10 @@ void test_sparsevec(pqxx::connection &conn) {
8187
assert(res[0][0].as<std::string>() == "{1:4,2:5,3:6}/3");
8288
assert(res[1][0].as<std::string>() == "{1:1,2:2,3:3}/3");
8389
assert(!res[2][0].as<std::optional<std::string>>().has_value());
90+
91+
assert(pqxx::to_string(embedding) == "{1:1,2:2,3:3}/3");
92+
// TODO add
93+
// assert(pqxx::from_string<pgvector::SparseVector>("{1:1,2:2,3:3}/3") == embedding);
8494
}
8595

8696
void test_sparsevec_nnz(pqxx::connection &conn) {

0 commit comments

Comments
 (0)