blob: 20937688b44d334198bf4c4966f79e261fc824b4 [file] [log] [blame]
Jeff Sharkey95440eb2017-09-18 18:19:28 -06001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <gtest/gtest.h>
18
19#include "../cryptfs.h"
20
21namespace android {
22
23class CryptfsTest : public testing::Test {
Paul Crowley14c8c072018-09-18 13:30:21 -070024 protected:
25 virtual void SetUp() {}
Jeff Sharkey95440eb2017-09-18 18:19:28 -060026
Paul Crowley14c8c072018-09-18 13:30:21 -070027 virtual void TearDown() {}
Jeff Sharkey95440eb2017-09-18 18:19:28 -060028};
29
30TEST_F(CryptfsTest, MatchMultiEntryTest) {
31 ASSERT_NE(0, match_multi_entry("foo", "foo", 0));
32 ASSERT_NE(0, match_multi_entry("foo_0", "foo", 0));
33 ASSERT_NE(0, match_multi_entry("foo_1", "foo", 0));
34 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 0));
35
36 ASSERT_EQ(0, match_multi_entry("foo", "foo", 1));
37 ASSERT_EQ(0, match_multi_entry("foo_0", "foo", 1));
38 ASSERT_NE(0, match_multi_entry("foo_1", "foo", 1));
39 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 1));
40
41 ASSERT_EQ(0, match_multi_entry("foo", "foo", 2));
42 ASSERT_EQ(0, match_multi_entry("foo_0", "foo", 2));
43 ASSERT_EQ(0, match_multi_entry("foo_1", "foo", 2));
44 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 2));
45
46 ASSERT_EQ(0, match_multi_entry("food", "foo", 0));
47 ASSERT_EQ(0, match_multi_entry("foo", "food", 0));
48 ASSERT_EQ(0, match_multi_entry("foo", "bar", 0));
49 ASSERT_EQ(0, match_multi_entry("foo_2", "bar", 0));
50}
51
Paul Crowley14c8c072018-09-18 13:30:21 -070052} // namespace android