1 /*
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 
21 namespace android {
22 
23 class CryptfsTest : public testing::Test {
24   protected:
SetUp()25     virtual void SetUp() {}
26 
TearDown()27     virtual void TearDown() {}
28 };
29 
TEST_F(CryptfsTest,MatchMultiEntryTest)30 TEST_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 
52 }  // namespace android
53