From 4101c71e63793b9a82427c550026d49a4f07e190 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Wed, 9 Feb 2022 11:54:35 -0800 Subject: Support multiple library names per target. The prior interface to make supported only a single package name per target; although, a target might have multiple licenses each with its own package name. Bug: 151177513 Bug: 210912771 Test: m all dist Test: flash; About Phone -> Legal Information -> Third-party licenses Change-Id: I1db5fcfd4c066afd162adb4eb4177960c7a503bd --- android/module_test.go | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) (limited to 'android/module_test.go') diff --git a/android/module_test.go b/android/module_test.go index c35e66ed6..a1bab6d01 100644 --- a/android/module_test.go +++ b/android/module_test.go @@ -816,3 +816,120 @@ test { }) } } + +func TestSortedUniqueNamedPaths(t *testing.T) { + type np struct { + path, name string + } + makePaths := func(l []np) NamedPaths { + result := make(NamedPaths, 0, len(l)) + for _, p := range l { + result = append(result, NamedPath{PathForTesting(p.path), p.name}) + } + return result + } + + tests := []struct { + name string + in []np + expectedOut []np + }{ + { + name: "empty", + in: []np{}, + expectedOut: []np{}, + }, + { + name: "all_same", + in: []np{ + {"a.txt", "A"}, + {"a.txt", "A"}, + {"a.txt", "A"}, + {"a.txt", "A"}, + {"a.txt", "A"}, + }, + expectedOut: []np{ + {"a.txt", "A"}, + }, + }, + { + name: "same_path_different_names", + in: []np{ + {"a.txt", "C"}, + {"a.txt", "A"}, + {"a.txt", "D"}, + {"a.txt", "B"}, + {"a.txt", "E"}, + }, + expectedOut: []np{ + {"a.txt", "A"}, + {"a.txt", "B"}, + {"a.txt", "C"}, + {"a.txt", "D"}, + {"a.txt", "E"}, + }, + }, + { + name: "different_paths_same_name", + in: []np{ + {"b/b.txt", "A"}, + {"a/a.txt", "A"}, + {"a/txt", "A"}, + {"b", "A"}, + {"a/b/d", "A"}, + }, + expectedOut: []np{ + {"a/a.txt", "A"}, + {"a/b/d", "A"}, + {"a/txt", "A"}, + {"b/b.txt", "A"}, + {"b", "A"}, + }, + }, + { + name: "all_different", + in: []np{ + {"b/b.txt", "A"}, + {"a/a.txt", "B"}, + {"a/txt", "D"}, + {"b", "C"}, + {"a/b/d", "E"}, + }, + expectedOut: []np{ + {"a/a.txt", "B"}, + {"a/b/d", "E"}, + {"a/txt", "D"}, + {"b/b.txt", "A"}, + {"b", "C"}, + }, + }, + { + name: "some_different", + in: []np{ + {"b/b.txt", "A"}, + {"a/a.txt", "B"}, + {"a/txt", "D"}, + {"a/b/d", "E"}, + {"b", "C"}, + {"a/a.txt", "B"}, + {"a/b/d", "E"}, + }, + expectedOut: []np{ + {"a/a.txt", "B"}, + {"a/b/d", "E"}, + {"a/txt", "D"}, + {"b/b.txt", "A"}, + {"b", "C"}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + actual := SortedUniqueNamedPaths(makePaths(tt.in)) + expected := makePaths(tt.expectedOut) + t.Logf("actual: %v", actual) + t.Logf("expected: %v", expected) + AssertDeepEquals(t, "SortedUniqueNamedPaths ", expected, actual) + }) + } +} -- cgit v1.2.3-59-g8ed1b