OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "sandbox/linux/bpf_dsl/cons.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace sandbox { | |
12 namespace { | |
13 | |
14 std::string Join(Cons<char>::List char_list) { | |
15 std::string res; | |
16 for (Cons<char>::List it = char_list; it; it = it->tail()) { | |
17 res.push_back(it->head()); | |
18 } | |
19 return res; | |
20 } | |
21 | |
22 TEST(ConsListTest, Basic) { | |
23 Cons<char>::List ba = | |
24 Cons<char>::Make('b', Cons<char>::Make('a', Cons<char>::List())); | |
25 EXPECT_EQ("ba", Join(ba)); | |
26 | |
27 Cons<char>::List cba = Cons<char>::Make('c', ba); | |
28 Cons<char>::List dba = Cons<char>::Make('d', ba); | |
29 EXPECT_EQ("cba", Join(cba)); | |
30 EXPECT_EQ("dba", Join(dba)); | |
31 } | |
32 | |
33 } // namespace | |
34 } // namespace sandbox | |
OLD | NEW |