Christopher Wiley | a25d351 | 2015-09-01 11:07:48 -0700 | [diff] [blame] | 1 | /* |
| 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 | #include <vector> |
| 19 | |
| 20 | #include <gtest/gtest.h> |
| 21 | |
| 22 | #include "options.h" |
| 23 | |
| 24 | using std::vector; |
| 25 | using std::string; |
| 26 | |
| 27 | const char kPreprocessCommandOutputFile[] = "output_file_name"; |
| 28 | const char kPreprocessCommandInput1[] = "input1"; |
| 29 | const char kPreprocessCommandInput2[] = "input2"; |
| 30 | const char kPreprocessCommandInput3[] = "input3"; |
| 31 | const char* kPreprocessCommand[] = { |
| 32 | "aidl", "--preprocess", |
| 33 | kPreprocessCommandOutputFile, |
| 34 | kPreprocessCommandInput1, |
| 35 | kPreprocessCommandInput2, |
| 36 | kPreprocessCommandInput3, |
| 37 | }; |
| 38 | |
| 39 | TEST(OptionsTests, ParsesPreprocess) { |
| 40 | Options options; |
| 41 | const int argc = sizeof(kPreprocessCommand) / sizeof(*kPreprocessCommand); |
| 42 | EXPECT_EQ(parse_options(argc, kPreprocessCommand, &options), 0); |
| 43 | EXPECT_EQ(options.task, PREPROCESS_AIDL); |
| 44 | EXPECT_EQ(options.failOnParcelable, false); |
| 45 | EXPECT_EQ(options.importPaths.size(), 0u); |
| 46 | EXPECT_EQ(options.preprocessedFiles.size(), 0u); |
| 47 | EXPECT_EQ(options.inputFileName, string{""}); |
| 48 | EXPECT_EQ(options.outputFileName, string{kPreprocessCommandOutputFile}); |
| 49 | EXPECT_EQ(options.autoDepFile, false); |
| 50 | const vector<string> expected_input{kPreprocessCommandInput1, |
| 51 | kPreprocessCommandInput2, |
| 52 | kPreprocessCommandInput3}; |
| 53 | EXPECT_EQ(options.filesToPreprocess, expected_input); |
| 54 | } |