File tree Expand file tree Collapse file tree 5 files changed +47
-14
lines changed
Expand file tree Collapse file tree 5 files changed +47
-14
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,18 @@ jobs:
2222 make
2323 sudo make install
2424
25- - run : g++ -std=c++17 -Wall -Wextra -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
26- - run : test/pqxx
25+ - run : g++ -std=c++17 -Wall -Wextra -Werror -o test/main test/main.cpp test/pqxx_test.cpp -lpqxx -lpq
26+ - run : test/main
2727
28- - run : g++ -std=c++20 -Wall -Wextra -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
29- - run : test/pqxx
28+ - run : g++ -std=c++20 -Wall -Wextra -Werror -o test/main test/main.cpp test/pqxx_test.cpp -lpqxx -lpq
29+ - run : test/main
3030
31- - run : g++ -std=c++23 -Wall -Wextra -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
32- - run : test/pqxx
31+ - run : g++ -std=c++23 -Wall -Wextra -Werror -o test/main test/main.cpp test/pqxx_test.cpp -lpqxx -lpq
32+ - run : test/main
3333
3434 - run : |
3535 sudo apt-get install valgrind
36- valgrind --leak-check=yes test/pqxx
36+ valgrind --leak-check=yes test/main
3737
3838 # test install
3939 - run : cmake -S . -B build
Original file line number Diff line number Diff line change 11build
2- /test /pqxx
2+ /test /main
Original file line number Diff line number Diff line change @@ -107,8 +107,8 @@ To get started with development:
107107git clone https://github.com/pgvector/pgvector-cpp.git
108108cd pgvector-cpp
109109createdb pgvector_cpp_test
110- g++ -std=c++17 -Wall -Wextra -Wno-unknown-attributes -Werror -o test/pqxx test/pqxx_test.cpp -lpqxx -lpq
111- test/pqxx
110+ g++ -std=c++17 -Wall -Wextra -Wno-unknown-attributes -Werror -o test/main test/main.cpp test/pqxx_test.cpp -lpqxx -lpq
111+ test/main
112112```
113113
114114To run an example:
Original file line number Diff line number Diff line change 1+ #include < cassert>
2+
3+ #include " ../include/pgvector/halfvec.hpp"
4+ #include " ../include/pgvector/sparsevec.hpp"
5+ #include " ../include/pgvector/vector.hpp"
6+
7+ using pgvector::HalfVector;
8+ using pgvector::SparseVector;
9+ using pgvector::Vector;
10+
11+ void test_pqxx ();
12+
13+ void test_vector () {
14+ auto vec = Vector ({1 , 2 , 3 });
15+ assert (vec.dimensions () == 3 );
16+ }
17+
18+ void test_halfvec () {
19+ auto vec = HalfVector ({1 , 2 , 3 });
20+ assert (vec.dimensions () == 3 );
21+ }
22+
23+ void test_sparsevec () {
24+ auto vec = SparseVector ({1 , 2 , 3 });
25+ assert (vec.dimensions () == 3 );
26+ }
27+
28+ int main () {
29+ test_pqxx ();
30+ test_vector ();
31+ test_halfvec ();
32+ test_sparsevec ();
33+ return 0 ;
34+ }
Original file line number Diff line number Diff line change 1- #include " ../include/pgvector/pqxx.hpp"
21#include < cassert>
32#include < optional>
43#include < pqxx/pqxx>
54
5+ #include " ../include/pgvector/pqxx.hpp"
6+
67void setup (pqxx::connection &conn) {
78 pqxx::nontransaction tx (conn);
89 tx.exec (" CREATE EXTENSION IF NOT EXISTS vector" );
@@ -131,7 +132,7 @@ void test_precision(pqxx::connection &conn) {
131132 assert (res[0 ][0 ].as <pgvector::Vector>() == embedding);
132133}
133134
134- int main () {
135+ void test_pqxx () {
135136 pqxx::connection conn (" dbname=pgvector_cpp_test" );
136137 setup (conn);
137138
@@ -143,6 +144,4 @@ int main() {
143144 test_stream (conn);
144145 test_stream_to (conn);
145146 test_precision (conn);
146-
147- return 0 ;
148147}
You can’t perform that action at this time.
0 commit comments