File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,12 @@ cc_binary(
31
31
"@com_github_google_benchmark//:benchmark_main" ],
32
32
copts = COPTS
33
33
)
34
+
35
+ cc_binary (
36
+ name = "tests" ,
37
+ srcs = ["tests.cc" ],
38
+ deps = [
39
+ ":soa" ,
40
+ "@com_google_googletest//:gtest_main" ,
41
+ ],
42
+ copts = COPTS )
Original file line number Diff line number Diff line change @@ -6,3 +6,10 @@ http_archive(
6
6
name = "com_github_google_benchmark" ,
7
7
url = "https://github.com/google/benchmark/archive/refs/tags/v1.6.1.zip" ,
8
8
strip_prefix = "benchmark-1.6.1" )
9
+
10
+ http_archive (
11
+ name = "com_google_googletest" ,
12
+ urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip" ],
13
+ strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5" ,
14
+ sha256 = "5cf189eb6847b4f8fc603a3ffff3b0771c08eec7dd4bd961bfd45477dd13eb73"
15
+ )
Original file line number Diff line number Diff line change
1
+ #include < gtest/gtest.h>
2
+ #include < iostream>
3
+ #include " vapid/soa.h"
4
+
5
+ template <typename T>
6
+ bool is_sorted (const std::vector<T>& l) {
7
+ for (size_t idx = 1 ; idx < l.size (); ++idx) {
8
+ if (l[idx] < l[idx-1 ]) {
9
+ return false ;
10
+ }
11
+ }
12
+ return true ;
13
+ }
14
+
15
+ TEST (SortA, Sorting) {
16
+ vapid::soa<int , int > soa;
17
+ soa.insert (0 , 1 );
18
+ soa.insert (2 , 5 );
19
+ soa.insert (4 , 9 );
20
+ soa.insert (1 , 0 );
21
+ soa.sort_by_field <0 >();
22
+ EXPECT_TRUE (is_sorted (soa.get_column <0 >()));
23
+ }
You can’t perform that action at this time.
0 commit comments