@@ -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
3942void 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
5662void 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
8696void test_sparsevec_nnz (pqxx::connection &conn) {
0 commit comments