@@ -32,13 +32,27 @@ void test_halfvec() {
3232 assert (vec.dimensions () == 3 );
3333}
3434
35+ #if __cplusplus >= 202002L
36+ void test_halfvec_span () {
37+ auto vec = HalfVector (std::span<const float >({1 , 2 , 3 }));
38+ assert (vec.dimensions () == 3 );
39+ }
40+ #endif
41+
3542void test_sparsevec () {
3643 auto vec = SparseVector ({1 , 0 , 2 , 0 , 3 , 0 });
3744 assert (vec.dimensions () == 6 );
3845 assert (vec.indices () == (std::vector<int >{0 , 2 , 4 }));
3946 assert (vec.values () == (std::vector<float >{1 , 2 , 3 }));
4047}
4148
49+ #if __cplusplus >= 202002L
50+ void test_sparsevec_span () {
51+ auto vec = SparseVector (std::span<const float >({1 , 0 , 2 , 0 , 3 , 0 }));
52+ assert (vec.dimensions () == 6 );
53+ }
54+ #endif
55+
4256void test_sparsevec_map () {
4357 std::unordered_map<int , float > map = {{2 , 2 }, {4 , 3 }, {3 , 0 }, {0 , 1 }};
4458 auto vec = SparseVector (map, 6 );
@@ -54,6 +68,12 @@ int main() {
5468 test_vector_span ();
5569#endif
5670 test_halfvec ();
71+ #if __cplusplus >= 202002L
72+ test_halfvec_span ();
73+ #endif
5774 test_sparsevec ();
75+ #if __cplusplus >= 202002L
76+ test_sparsevec_span ();
77+ #endif
5878 return 0 ;
5979}
0 commit comments