Chromium Code Reviews| Index: sandbox/linux/seccomp-bpf-helpers/cons_unittest.cc |
| diff --git a/sandbox/linux/seccomp-bpf-helpers/cons_unittest.cc b/sandbox/linux/seccomp-bpf-helpers/cons_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..93d1fbb1cea05b3b3aeec5f439f47c767ce374da |
| --- /dev/null |
| +++ b/sandbox/linux/seccomp-bpf-helpers/cons_unittest.cc |
| @@ -0,0 +1,36 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "sandbox/linux/seccomp-bpf-helpers/cons.h" |
| + |
| +#include <string> |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace sandbox { |
| + |
| +namespace { |
| + |
| +std::string Join(Cons<char>::List char_list) { |
| + std::string res; |
| + for (Cons<char>::List it = char_list; it; it = it->tail()) { |
| + res.push_back(it->head()); |
| + } |
| + return res; |
| +} |
| + |
| +} // namespace |
|
jln (very slow on Chromium)
2014/06/27 01:45:50
It's perfectly ok to have TEST() in the anonymous
mdempsky
2014/06/28 00:36:42
Oops, done.
|
| + |
| +TEST(ConsListTest, Basic) { |
| + Cons<char>::List ba = |
| + Cons<char>::Make('b', Cons<char>::Make('a', Cons<char>::List())); |
| + EXPECT_EQ("ba", Join(ba)); |
| + |
| + Cons<char>::List cba = Cons<char>::Make('c', ba); |
| + Cons<char>::List dba = Cons<char>::Make('d', ba); |
| + EXPECT_EQ("cba", Join(cba)); |
| + EXPECT_EQ("dba", Join(dba)); |
| +} |
| + |
| +} // namespace sandbox |