blob: 31dfb5a15fdeca3c71fe58915850ba18a1b9a2c1 [file] [log] [blame]
Christopher Wileyfdeb0f42015-09-11 15:38:22 -07001/*
2 * Copyright (C) 2015, 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 <string>
18
19#include <gtest/gtest.h>
20
21#include "Type.h"
22#include "ast_java.h"
23#include "code_writer.h"
24
25namespace android {
26namespace aidl {
27namespace {
28
29const char kExpectedClassOutput[] =
30R"(// class comment
31final class TestClass extends SuperClass
32{
33}
34)";
35
36} // namespace
37
38TEST(AstJavaTests, GeneratesClass) {
39 Type class_type("TestClass", Type::GENERATED, false, false);
40 Type extend_type("SuperClass", Type::BUILT_IN, false, false);
41 Class a_class;
42 a_class.comment = "// class comment";
43 a_class.modifiers = FINAL;
44 a_class.what = Class::CLASS;
45 a_class.type = &class_type;
46 a_class.extends = &extend_type;
47
48 string actual_output;
Christopher Wiley413e0422015-09-18 10:54:51 -070049 CodeWriterPtr writer = GetStringWriter(&actual_output);
Christopher Wileyfdeb0f42015-09-11 15:38:22 -070050 a_class.Write(writer.get());
51 EXPECT_EQ(string(kExpectedClassOutput), actual_output);
52}
53
54} // namespace aidl
55} // namespace android