1 /*
2  * Copyright (C) 2019 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 "linkerconfig/configwriter.h"
20 #include "linkerconfig/variables.h"
21 
22 constexpr const char* kSampleContent = "Lorem ipsum dolor sit amet";
23 
TEST(linkerconfig_configwriter,write_line)24 TEST(linkerconfig_configwriter, write_line) {
25   android::linkerconfig::modules::ConfigWriter writer;
26 
27   writer.WriteLine(kSampleContent);
28 
29   ASSERT_EQ(writer.ToString(), "Lorem ipsum dolor sit amet\n");
30 }
31 
TEST(linkerconfig_configwriter,WriteVars)32 TEST(linkerconfig_configwriter, WriteVars) {
33   android::linkerconfig::modules::ConfigWriter writer;
34 
35   writer.WriteVars("var1", {"value1", "value2"});
36   writer.WriteVars("var2", {"value1"});
37   writer.WriteVars("var3", {});
38 
39   ASSERT_EQ(
40       "var1 = value1\n"
41       "var1 += value2\n"
42       "var2 = value1\n",
43       writer.ToString());
44 }