Skip to content

Commit 9de20b8

Browse files
committed
Added more tests
1 parent bfa1b09 commit 9de20b8

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

test/halfvec_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ static void test_constructor_empty() {
2323
assert_equal(vec.dimensions(), 0u);
2424
}
2525

26+
static void test_dimensions() {
27+
HalfVector vec{{1, 2, 3}};
28+
assert_equal(vec.dimensions(), 3u);
29+
}
30+
2631
static void test_values() {
2732
HalfVector vec{{1, 2, 3}};
2833
assert_equal(vec.values() == std::vector<pgvector::Half>{1, 2, 3}, true);
@@ -39,6 +44,7 @@ void test_halfvec() {
3944
test_constructor_vector();
4045
test_constructor_span();
4146
test_constructor_empty();
47+
test_dimensions();
4248
test_values();
4349
test_string();
4450
}

test/sparsevec_test.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ static void test_constructor_empty() {
5050
assert_equal(vec2.dimensions(), 0);
5151
}
5252

53+
static void test_dimensions() {
54+
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
55+
assert_equal(vec.dimensions(), 6);
56+
}
57+
58+
static void test_indices() {
59+
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
60+
assert_equal(vec.indices() == std::vector<int>{0, 2, 4}, true);
61+
}
62+
63+
static void test_values() {
64+
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
65+
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
66+
}
67+
5368
static void test_string() {
5469
SparseVector vec{std::vector<float>{1, 0, 2, 0, 3, 0}};
5570
std::ostringstream oss;
@@ -62,5 +77,8 @@ void test_sparsevec() {
6277
test_constructor_span();
6378
test_constructor_empty();
6479
test_constructor_map();
80+
test_dimensions();
81+
test_indices();
82+
test_values();
6583
test_string();
6684
}

test/vector_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ static void test_constructor_empty() {
2323
assert_equal(vec.dimensions(), 0u);
2424
}
2525

26+
static void test_dimensions() {
27+
Vector vec{{1, 2, 3}};
28+
assert_equal(vec.dimensions(), 3u);
29+
}
30+
2631
static void test_values() {
2732
Vector vec{{1, 2, 3}};
2833
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
@@ -39,6 +44,7 @@ void test_vector() {
3944
test_constructor_vector();
4045
test_constructor_span();
4146
test_constructor_empty();
47+
test_dimensions();
4248
test_values();
4349
test_string();
4450
}

0 commit comments

Comments
 (0)