blob: 9cf462ce9f2aad33c38f87f5fc71bfed6d8ea8c5 [file] [log] [blame]
Jiyong Park22b4ecd2018-07-23 23:34:42 +09001/*
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
22using android::aidl::CodeWriter;
23using std::string;
24using std::unique_ptr;
25
26namespace android {
27namespace aidl {
28
29TEST(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
38TEST(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