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:
22
22
make
23
23
sudo make install
24
24
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
27
27
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
30
30
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
33
33
34
34
- run : |
35
35
sudo apt-get install valgrind
36
- valgrind --leak-check=yes test/pqxx
36
+ valgrind --leak-check=yes test/main
37
37
38
38
# test install
39
39
- run : cmake -S . -B build
Original file line number Diff line number Diff line change 1
1
build
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:
107
107
git clone https://github.com/pgvector/pgvector-cpp.git
108
108
cd pgvector-cpp
109
109
createdb 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
112
112
```
113
113
114
114
To 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"
2
1
#include < cassert>
3
2
#include < optional>
4
3
#include < pqxx/pqxx>
5
4
5
+ #include " ../include/pgvector/pqxx.hpp"
6
+
6
7
void setup (pqxx::connection &conn) {
7
8
pqxx::nontransaction tx (conn);
8
9
tx.exec (" CREATE EXTENSION IF NOT EXISTS vector" );
@@ -131,7 +132,7 @@ void test_precision(pqxx::connection &conn) {
131
132
assert (res[0 ][0 ].as <pgvector::Vector>() == embedding);
132
133
}
133
134
134
- int main () {
135
+ void test_pqxx () {
135
136
pqxx::connection conn (" dbname=pgvector_cpp_test" );
136
137
setup (conn);
137
138
@@ -143,6 +144,4 @@ int main() {
143
144
test_stream (conn);
144
145
test_stream_to (conn);
145
146
test_precision (conn);
146
-
147
- return 0 ;
148
147
}
You can’t perform that action at this time.
0 commit comments