sdk_version_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. package android
  15. import (
  16. "testing"
  17. )
  18. func TestSdkSpecFrom(t *testing.T) {
  19. testCases := []struct {
  20. input string
  21. expected string
  22. }{
  23. {
  24. input: "",
  25. expected: "private_current",
  26. },
  27. {
  28. input: "none",
  29. expected: "none_(no version)",
  30. },
  31. {
  32. input: "core_platform",
  33. expected: "core_platform_current",
  34. },
  35. {
  36. input: "_",
  37. expected: "invalid__",
  38. },
  39. {
  40. input: "_31",
  41. expected: "invalid__31",
  42. },
  43. {
  44. input: "system_R",
  45. expected: "system_30",
  46. },
  47. {
  48. input: "test_31",
  49. expected: "test_31",
  50. },
  51. {
  52. input: "module_current",
  53. expected: "module-lib_current",
  54. },
  55. {
  56. input: "31",
  57. expected: "public_31",
  58. },
  59. {
  60. input: "S",
  61. expected: "public_31",
  62. },
  63. {
  64. input: "current",
  65. expected: "public_current",
  66. },
  67. {
  68. input: "Tiramisu",
  69. expected: "public_Tiramisu",
  70. },
  71. }
  72. config := NullConfig("", "")
  73. config.productVariables = productVariables{
  74. Platform_sdk_version: intPtr(31),
  75. Platform_sdk_codename: stringPtr("Tiramisu"),
  76. Platform_version_active_codenames: []string{"Tiramisu"},
  77. }
  78. for _, tc := range testCases {
  79. if got := SdkSpecFromWithConfig(config, tc.input).String(); tc.expected != got {
  80. t.Errorf("Expected %v, got %v", tc.expected, got)
  81. }
  82. }
  83. }