Lines Matching +full:gpl +full:- +full:2
1 // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 // ===== 2.1 Searcher top-level function tests =====
14 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
22 t.Fatalf("expected non-nil Document, got nil")
29 t.Fatalf("expected non-nil Packages, got nil")
36 t.Fatalf("expected non-nil pkg, got nil")
40 t.Fatalf("expected non-nil Files, got nil")
48 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
62 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
67 if fileTrailingComment.LicenseInfoInFiles[0] != "GPL-2.0-or-later" {
68 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseInfoInFiles[0])
70 if fileTrailingComment.LicenseConcluded != "GPL-2.0-or-later" {
71 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseConcluded)
74 fileHasDuplicateID := pkg.Files[2]
76 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
90 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
92 if len(fileHasID.LicenseInfoInFiles) != 2 {
93 t.Fatalf("expected LicenseInfoInFiles len to be 2, got %d", len(fileHasID.LicenseInfoInFiles))
95 if fileHasID.LicenseInfoInFiles[0] != "Apache-2.0" {
96 t.Errorf("expected %v, got %v", "Apache-2.0", fileHasID.LicenseInfoInFiles[0])
98 if fileHasID.LicenseInfoInFiles[1] != "GPL-2.0-or-later" {
99 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileHasID.LicenseInfoInFiles[1])
101 if fileHasID.LicenseConcluded != "Apache-2.0 OR GPL-2.0-or-later" {
102 t.Errorf("expected %v, got %v", "Apache-2.0 OR GPL-2.0-or-later", fileHasID.LicenseConcluded)
107 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
112 if fileMultipleIDs.LicenseInfoInFiles[0] != "BSD-2-Clause" {
113 t.Errorf("expected %v, got %v", "BSD-2-Clause", fileMultipleIDs.LicenseInfoInFiles[0])
115 if fileMultipleIDs.LicenseInfoInFiles[1] != "BSD-3-Clause" {
116 t.Errorf("expected %v, got %v", "BSD-3-Clause", fileMultipleIDs.LicenseInfoInFiles[1])
119 if fileMultipleIDs.LicenseInfoInFiles[2] != "EPL-1.0" {
120 t.Errorf("expected %v, got %v", "EPL-1.0", fileMultipleIDs.LicenseInfoInFiles[2])
128 …if fileMultipleIDs.LicenseConcluded != "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1…
129 …t.Errorf("expected %v, got %v", "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1.0+", f…
134 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
148 t.Fatalf("expected non-nil PackageLicenseInfoFromFiles, got nil")
153 if pkg.PackageLicenseInfoFromFiles[0] != "Apache-2.0" {
154 t.Errorf("expected %v, got %v", "Apache-2.0", pkg.PackageLicenseInfoFromFiles[0])
156 if pkg.PackageLicenseInfoFromFiles[1] != "BSD-2-Clause" {
157 t.Errorf("expected %v, got %v", "BSD-2-Clause", pkg.PackageLicenseInfoFromFiles[1])
159 if pkg.PackageLicenseInfoFromFiles[2] != "BSD-3-Clause" {
160 t.Errorf("expected %v, got %v", "BSD-3-Clause", pkg.PackageLicenseInfoFromFiles[2])
163 if pkg.PackageLicenseInfoFromFiles[3] != "EPL-1.0" {
164 t.Errorf("expected %v, got %v", "EPL-1.0", pkg.PackageLicenseInfoFromFiles[3])
166 if pkg.PackageLicenseInfoFromFiles[4] != "GPL-2.0-or-later" {
167 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", pkg.PackageLicenseInfoFromFiles[4])
182 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
199 t.Fatalf("expected non-nil Document, got nil")
208 t.Fatalf("expected non-nil pkg, got nil")
242 f = pkg.Files[2]
294 t.Fatalf("expected non-nil error, got nil")
298 // ===== 2.2 Searcher top-level function tests =====
303 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
311 t.Fatalf("expected non-nil Document, got nil")
318 t.Fatalf("expected non-nil Packages, got nil")
325 t.Fatalf("expected non-nil pkg, got nil")
329 t.Fatalf("expected non-nil Files, got nil")
337 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
351 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
356 if fileTrailingComment.LicenseInfoInFiles[0] != "GPL-2.0-or-later" {
357 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseInfoInFiles[0])
359 if fileTrailingComment.LicenseConcluded != "GPL-2.0-or-later" {
360 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseConcluded)
363 fileHasDuplicateID := pkg.Files[2]
365 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
379 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
381 if len(fileHasID.LicenseInfoInFiles) != 2 {
382 t.Fatalf("expected LicenseInfoInFiles len to be 2, got %d", len(fileHasID.LicenseInfoInFiles))
384 if fileHasID.LicenseInfoInFiles[0] != "Apache-2.0" {
385 t.Errorf("expected %v, got %v", "Apache-2.0", fileHasID.LicenseInfoInFiles[0])
387 if fileHasID.LicenseInfoInFiles[1] != "GPL-2.0-or-later" {
388 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileHasID.LicenseInfoInFiles[1])
390 if fileHasID.LicenseConcluded != "Apache-2.0 OR GPL-2.0-or-later" {
391 t.Errorf("expected %v, got %v", "Apache-2.0 OR GPL-2.0-or-later", fileHasID.LicenseConcluded)
396 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
401 if fileMultipleIDs.LicenseInfoInFiles[0] != "BSD-2-Clause" {
402 t.Errorf("expected %v, got %v", "BSD-2-Clause", fileMultipleIDs.LicenseInfoInFiles[0])
404 if fileMultipleIDs.LicenseInfoInFiles[1] != "BSD-3-Clause" {
405 t.Errorf("expected %v, got %v", "BSD-3-Clause", fileMultipleIDs.LicenseInfoInFiles[1])
408 if fileMultipleIDs.LicenseInfoInFiles[2] != "EPL-1.0" {
409 t.Errorf("expected %v, got %v", "EPL-1.0", fileMultipleIDs.LicenseInfoInFiles[2])
417 …if fileMultipleIDs.LicenseConcluded != "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1…
418 …t.Errorf("expected %v, got %v", "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1.0+", f…
423 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
437 t.Fatalf("expected non-nil PackageLicenseInfoFromFiles, got nil")
442 if pkg.PackageLicenseInfoFromFiles[0] != "Apache-2.0" {
443 t.Errorf("expected %v, got %v", "Apache-2.0", pkg.PackageLicenseInfoFromFiles[0])
445 if pkg.PackageLicenseInfoFromFiles[1] != "BSD-2-Clause" {
446 t.Errorf("expected %v, got %v", "BSD-2-Clause", pkg.PackageLicenseInfoFromFiles[1])
448 if pkg.PackageLicenseInfoFromFiles[2] != "BSD-3-Clause" {
449 t.Errorf("expected %v, got %v", "BSD-3-Clause", pkg.PackageLicenseInfoFromFiles[2])
452 if pkg.PackageLicenseInfoFromFiles[3] != "EPL-1.0" {
453 t.Errorf("expected %v, got %v", "EPL-1.0", pkg.PackageLicenseInfoFromFiles[3])
455 if pkg.PackageLicenseInfoFromFiles[4] != "GPL-2.0-or-later" {
456 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", pkg.PackageLicenseInfoFromFiles[4])
471 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
488 t.Fatalf("expected non-nil Document, got nil")
497 t.Fatalf("expected non-nil pkg, got nil")
531 f = pkg.Files[2]
583 t.Fatalf("expected non-nil error, got nil")
587 // ===== 2.3 Searcher top-level function tests =====
592 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
600 t.Fatalf("expected non-nil Document, got nil")
607 t.Fatalf("expected non-nil Packages, got nil")
614 t.Fatalf("expected non-nil pkg, got nil")
618 t.Fatalf("expected non-nil Files, got nil")
626 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
640 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
645 if fileTrailingComment.LicenseInfoInFiles[0] != "GPL-2.0-or-later" {
646 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseInfoInFiles[0])
648 if fileTrailingComment.LicenseConcluded != "GPL-2.0-or-later" {
649 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileTrailingComment.LicenseConcluded)
652 fileHasDuplicateID := pkg.Files[2]
654 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
668 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
670 if len(fileHasID.LicenseInfoInFiles) != 2 {
671 t.Fatalf("expected LicenseInfoInFiles len to be 2, got %d", len(fileHasID.LicenseInfoInFiles))
673 if fileHasID.LicenseInfoInFiles[0] != "Apache-2.0" {
674 t.Errorf("expected %v, got %v", "Apache-2.0", fileHasID.LicenseInfoInFiles[0])
676 if fileHasID.LicenseInfoInFiles[1] != "GPL-2.0-or-later" {
677 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", fileHasID.LicenseInfoInFiles[1])
679 if fileHasID.LicenseConcluded != "Apache-2.0 OR GPL-2.0-or-later" {
680 t.Errorf("expected %v, got %v", "Apache-2.0 OR GPL-2.0-or-later", fileHasID.LicenseConcluded)
685 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
690 if fileMultipleIDs.LicenseInfoInFiles[0] != "BSD-2-Clause" {
691 t.Errorf("expected %v, got %v", "BSD-2-Clause", fileMultipleIDs.LicenseInfoInFiles[0])
693 if fileMultipleIDs.LicenseInfoInFiles[1] != "BSD-3-Clause" {
694 t.Errorf("expected %v, got %v", "BSD-3-Clause", fileMultipleIDs.LicenseInfoInFiles[1])
697 if fileMultipleIDs.LicenseInfoInFiles[2] != "EPL-1.0" {
698 t.Errorf("expected %v, got %v", "EPL-1.0", fileMultipleIDs.LicenseInfoInFiles[2])
706 …if fileMultipleIDs.LicenseConcluded != "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1…
707 …t.Errorf("expected %v, got %v", "((MIT AND BSD-3-Clause) OR ISC) AND BSD-2-Clause AND EPL-1.0+", f…
712 t.Fatalf("expected non-nil LicenseInfoInFiles, got nil")
726 t.Fatalf("expected non-nil PackageLicenseInfoFromFiles, got nil")
731 if pkg.PackageLicenseInfoFromFiles[0] != "Apache-2.0" {
732 t.Errorf("expected %v, got %v", "Apache-2.0", pkg.PackageLicenseInfoFromFiles[0])
734 if pkg.PackageLicenseInfoFromFiles[1] != "BSD-2-Clause" {
735 t.Errorf("expected %v, got %v", "BSD-2-Clause", pkg.PackageLicenseInfoFromFiles[1])
737 if pkg.PackageLicenseInfoFromFiles[2] != "BSD-3-Clause" {
738 t.Errorf("expected %v, got %v", "BSD-3-Clause", pkg.PackageLicenseInfoFromFiles[2])
741 if pkg.PackageLicenseInfoFromFiles[3] != "EPL-1.0" {
742 t.Errorf("expected %v, got %v", "EPL-1.0", pkg.PackageLicenseInfoFromFiles[3])
744 if pkg.PackageLicenseInfoFromFiles[4] != "GPL-2.0-or-later" {
745 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", pkg.PackageLicenseInfoFromFiles[4])
760 NamespacePrefix: "https://github.com/swinslow/spdx-docs/spdx-go/testdata-",
777 t.Fatalf("expected non-nil Document, got nil")
786 t.Fatalf("expected non-nil pkg, got nil")
820 f = pkg.Files[2]
872 t.Fatalf("expected non-nil error, got nil")
878 filePath := "../testdata/project2/has-id.txt"
889 if ids[0] != "Apache-2.0 OR GPL-2.0-or-later" {
890 t.Errorf("expected %v, got %v", "Apache-2.0 OR GPL-2.0-or-later", ids[0])
895 filePath := "../testdata/project2/has-multiple-ids.txt"
906 if ids[0] != "(MIT AND BSD-3-Clause) OR ISC" {
907 t.Errorf("expected %v, got %v", "(MIT AND BSD-3-Clause) OR ISC", ids[0])
909 if ids[1] != "BSD-2-Clause" {
910 t.Errorf("expected %v, got %v", "BSD-2-Clause", ids[1])
912 if ids[2] != "EPL-1.0+" {
913 t.Errorf("expected %v, got %v", "EPL-1.0+", ids[2])
918 filePath := "../testdata/project2/has-duplicate-ids.txt"
935 filePath := "../testdata/project2/folder/has-trailing-comment-marker.c"
946 if ids[0] != "GPL-2.0-or-later" {
947 t.Errorf("expected %v, got %v", "GPL-2.0-or-later", ids[0])
952 filePath := "../testdata/project4/has-id-to-ignore.txt"
965 filePath := "../testdata/project4/has-mix-of-ids.txt"
982 filePath := "../testdata/project2/no-id.txt"
995 lid := "Apac\",he-2.0"
996 want := "Apache-2.0"
1002 lid = "Apache-2.0"
1003 want = "Apache-2.0"
1015 t.Fatalf("expected non-nil error, got nil")
1020 licID := "MIT OR BSD-3-Clause"
1022 if retval != "(MIT OR BSD-3-Clause)" {
1023 t.Errorf("expected %v, got %v", "(MIT OR BSD-3-Clause)", retval)
1040 lic = "GPL-2.0-only WITH Classpath-exception-2.0"
1042 if retval != "GPL-2.0-only WITH Classpath-exception-2.0" {
1043 t.Errorf("expected %v, got %v", "GPL-2.0-only WITH Classpath-exception-2.0", retval)
1052 t.Fatalf("expected non-nil lics, got nil")
1061 // two-license combo
1062 lic = "ISC AND BSD-3-Clause"
1065 t.Fatalf("expected non-nil lics, got nil")
1067 if len(lics) != 2 {
1068 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1071 if lics[0] != "BSD-3-Clause" {
1072 t.Errorf("expected %v, got %v", "BSD-3-Clause", lics[0])
1079 lic = "GPL-2.0-only WITH Classpath-exception-2.0"
1082 t.Fatalf("expected non-nil lics, got nil")
1084 if len(lics) != 2 {
1085 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1088 if lics[0] != "Classpath-exception-2.0" {
1089 t.Errorf("expected %v, got %v", "Classpath-exception-2.0", lics[0])
1091 if lics[1] != "GPL-2.0-only" {
1092 t.Errorf("expected %v, got %v", "GPL-2.0-only", lics[1])
1095 // two-license combo with parens
1096 lic = "(JSON OR BSD-2-Clause)"
1099 t.Fatalf("expected non-nil lics, got nil")
1101 if len(lics) != 2 {
1102 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1105 if lics[0] != "BSD-2-Clause" {
1106 t.Errorf("expected %v, got %v", "BSD-2-Clause", lics[0])
1112 // multi-license combo with nested parens
1113 lic = "GPL-2.0-only AND ((EPL-1.0 AND BSD-4-Clause) OR MIT)"
1116 t.Fatalf("expected non-nil lics, got nil")
1121 if lics[0] != "BSD-4-Clause" {
1122 t.Errorf("expected %v, got %v", "BSD-4-Clause", lics[0])
1124 if lics[1] != "EPL-1.0" {
1125 t.Errorf("expected %v, got %v", "EPL-1.0", lics[1])
1127 if lics[2] != "GPL-2.0-only" {
1128 t.Errorf("expected %v, got %v", "GPL-2.0-only", lics[2])
1136 // two-license combo with lowercase 'and'
1137 lic := "ISC and BSD-3-Clause"
1140 t.Fatalf("expected non-nil lics, got nil")
1143 if len(lics) != 2 {
1144 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1146 if lics[0] != "BSD-3-Clause" {
1147 t.Errorf("expected %v, got %v", "BSD-3-Clause", lics[0])
1153 // two-license combo with lowercase 'or'
1154 lic = "ISC or BSD-3-Clause"
1157 t.Fatalf("expected non-nil lics, got nil")
1160 if len(lics) != 2 {
1161 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1163 if lics[0] != "BSD-3-Clause" {
1164 t.Errorf("expected %v, got %v", "BSD-3-Clause", lics[0])
1170 // two-license combo with lowercase 'with'
1171 lic = "GPL-2.0-only with Classpath-exception-2.0"
1174 t.Fatalf("expected non-nil lics, got nil")
1177 if len(lics) != 2 {
1178 t.Fatalf("expected lics to have len 2, got %d", len(lics))
1180 if lics[0] != "Classpath-exception-2.0" {
1181 t.Errorf("expected %v, got %v", "Classpath-exception-2.0", lics[0])
1183 if lics[1] != "GPL-2.0-only" {
1184 t.Errorf("expected %v, got %v", "GPL-2.0-only", lics[1])