• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018, 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 "code_writer.h"
18 
19 #include <gtest/gtest.h>
20 #include <string>
21 
22 using android::aidl::CodeWriter;
23 using std::string;
24 using std::unique_ptr;
25 
26 namespace android {
27 namespace aidl {
28 
TEST(CodeWriterTest,AppendOperator)29 TEST(CodeWriterTest, AppendOperator) {
30   string str;
31   CodeWriterPtr ptr = CodeWriter::ForString(&str);
32   CodeWriter& writer = *ptr;
33   writer << "Write this";
34   writer.Close();
35   EXPECT_EQ(str, "Write this");
36 }
37 
TEST(CodeWriterTest,AppendOperatorCascade)38 TEST(CodeWriterTest, AppendOperatorCascade) {
39   string str;
40   CodeWriterPtr ptr = CodeWriter::ForString(&str);
41   CodeWriter& writer = *ptr;
42   writer << "Write this " << "and that";
43   writer.Close();
44   EXPECT_EQ(str, "Write this and that");
45 }
46 
47 }  // namespace aidl
48 }  // namespace android
49