satayev | 0ee2f91 | 2021-12-01 17:39:48 +0000 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package android |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | func TestSdkSpecFrom(t *testing.T) { |
| 22 | testCases := []struct { |
| 23 | input string |
| 24 | expected string |
| 25 | }{ |
| 26 | { |
| 27 | input: "", |
| 28 | expected: "private_current", |
| 29 | }, |
| 30 | { |
| 31 | input: "none", |
| 32 | expected: "none_(no version)", |
| 33 | }, |
| 34 | { |
| 35 | input: "core_platform", |
| 36 | expected: "core_platform_current", |
| 37 | }, |
| 38 | { |
| 39 | input: "_", |
| 40 | expected: "invalid_(no version)", |
| 41 | }, |
| 42 | { |
| 43 | input: "_31", |
| 44 | expected: "invalid_(no version)", |
| 45 | }, |
| 46 | { |
| 47 | input: "system_R", |
| 48 | expected: "system_30", |
| 49 | }, |
| 50 | { |
| 51 | input: "test_31", |
| 52 | expected: "test_31", |
| 53 | }, |
| 54 | { |
| 55 | input: "module_current", |
| 56 | expected: "module-lib_current", |
| 57 | }, |
| 58 | { |
| 59 | input: "31", |
| 60 | expected: "public_31", |
| 61 | }, |
| 62 | { |
| 63 | input: "S", |
| 64 | expected: "public_31", |
| 65 | }, |
| 66 | { |
| 67 | input: "current", |
| 68 | expected: "public_current", |
| 69 | }, |
| 70 | { |
| 71 | input: "Tiramisu", |
| 72 | expected: "public_Tiramisu", |
| 73 | }, |
| 74 | } |
| 75 | |
| 76 | config := NullConfig("", "") |
| 77 | |
| 78 | config.productVariables = productVariables{ |
| 79 | Platform_sdk_version: intPtr(31), |
| 80 | Platform_sdk_codename: stringPtr("Tiramisu"), |
| 81 | Platform_version_active_codenames: []string{"Tiramisu"}, |
| 82 | } |
| 83 | |
| 84 | for _, tc := range testCases { |
| 85 | if got := SdkSpecFromWithConfig(config, tc.input).String(); tc.expected != got { |
| 86 | t.Errorf("Expected %v, got %v", tc.expected, got) |
| 87 | } |
| 88 | } |
| 89 | } |