blob: 6875c0f81763334ced92e4ef88e606cac013410b [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 {
24protected:
25 virtual void SetUp() {
26 }
27
28 virtual void TearDown() {
29 }
30};
31
32TEST_F(CryptfsTest, MatchMultiEntryTest) {
33 ASSERT_NE(0, match_multi_entry("foo", "foo", 0));
34 ASSERT_NE(0, match_multi_entry("foo_0", "foo", 0));
35 ASSERT_NE(0, match_multi_entry("foo_1", "foo", 0));
36 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 0));
37
38 ASSERT_EQ(0, match_multi_entry("foo", "foo", 1));
39 ASSERT_EQ(0, match_multi_entry("foo_0", "foo", 1));
40 ASSERT_NE(0, match_multi_entry("foo_1", "foo", 1));
41 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 1));
42
43 ASSERT_EQ(0, match_multi_entry("foo", "foo", 2));
44 ASSERT_EQ(0, match_multi_entry("foo_0", "foo", 2));
45 ASSERT_EQ(0, match_multi_entry("foo_1", "foo", 2));
46 ASSERT_NE(0, match_multi_entry("foo_2", "foo", 2));
47
48 ASSERT_EQ(0, match_multi_entry("food", "foo", 0));
49 ASSERT_EQ(0, match_multi_entry("foo", "food", 0));
50 ASSERT_EQ(0, match_multi_entry("foo", "bar", 0));
51 ASSERT_EQ(0, match_multi_entry("foo_2", "bar", 0));
52}
53
54}