github.com/google/osv-scalibr@v0.4.1/converter/spdx/common_names_test.go (about) 1 // Copyright 2025 Google LLC 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 spdx_test 16 17 import ( 18 "testing" 19 20 "github.com/google/osv-scalibr/converter/spdx" 21 ) 22 23 func TestCommonLicenseNames(t *testing.T) { 24 tests := []struct{ commonName, shortIdentifier string }{ 25 {"0bsd", "0BSD"}, 26 {"ASWFDA1", "ASWF-Digital-Assets-1.0"}, 27 {"AdobeDP", ""}, 28 {"AdobeD-PostScript", "Adobe-Display-PostScript"}, 29 {"ARTISTIC1.0-PERL", "Artistic-1.0-Perl"}, 30 {"ARTISTIC1.0P", "Artistic-1.0-Perl"}, 31 {"ARTISTIC1.0PERL", "Artistic-1.0-Perl"}, 32 {"Artistic1P", "Artistic-1.0-Perl"}, 33 {"Artistic1Perl", "Artistic-1.0-Perl"}, 34 {"BSDSC", "BSD-Source-Code"}, 35 {"BSDS-beginning-file", "BSD-Source-beginning-file"}, 36 {"CC0-1", "CC0-1.0"}, 37 {"CC0-1.0", "CC0-1.0"}, 38 {"CC01", "CC0-1.0"}, 39 {"CC01.0", "CC0-1.0"}, 40 {"CC-BY3", "CC-BY-3.0"}, 41 {"CC-BY3.0", "CC-BY-3.0"}, 42 {"CCBY3", "CC-BY-3.0"}, 43 {"CCBY3.0", "CC-BY-3.0"}, 44 {"CECILLB", "CECILL-B"}, 45 {"CECILLC", "CECILL-C"}, 46 {"CERNOHL1.1", "CERN-OHL-1.1"}, 47 {"CMU", ""}, 48 {"CMUM", "CMU-Mach"}, 49 {"CMUMach", "CMU-Mach"}, 50 {"CNRIJ", "CNRI-Jython"}, 51 {"CNRIP", "CNRI-Python"}, 52 {"cornelll-jpeg", "Cornell-Lossless-JPEG"}, 53 {"DocBookS", "DocBook-Schema"}, 54 {"FSFAPnowarrantydisclaimer", "FSFAP-no-warranty-disclaimer"}, 55 {"FSFAPnwd", ""}, 56 {"GPL2-with-GCC-exception", "GPL-2.0-with-GCC-exception"}, 57 {"GPL2.0-with-GCC-exception", "GPL-2.0-with-GCC-exception"}, 58 {"GPL2with-GCC-exception", "GPL-2.0-with-GCC-exception"}, 59 {"GPL2.0with-GCC-exception", "GPL-2.0-with-GCC-exception"}, 60 {"GPL2withGCCexception", "GPL-2.0-with-GCC-exception"}, 61 {"GPL2.0withGCCexception", "GPL-2.0-with-GCC-exception"}, 62 {"GPL2withGCCexception", "GPL-2.0-with-GCC-exception"}, 63 {"GPL2.0withGCCexception", "GPL-2.0-with-GCC-exception"}, 64 {"GraphicsG", "Graphics-Gems"}, 65 {"HPNDFL", "HPND-Fenneberg-Livingston"}, 66 {"IECcc-Eula", "IEC-Code-Components-EULA"}, 67 {"LGPL2", "LGPL-2.0-only"}, 68 {"LGPL2+", "LGPL-2.0-or-later"}, 69 {"MartinB", "Martin-Birgmeier"}, 70 {"MSPL", "MS-PL"}, 71 {"MSRL", "MS-RL"}, 72 {"MIT0", "MIT-0"}, 73 {"MITCMU", "MIT-CMU"}, 74 {"PHP3", "PHP-3.0"}, 75 {"PolyForm-Noncommercial1", "PolyForm-Noncommercial-1.0.0"}, 76 {"PolyForm-Noncommercial1.0", "PolyForm-Noncommercial-1.0.0"}, 77 {"PolyForm-Noncommercial1.0.0", "PolyForm-Noncommercial-1.0.0"}, 78 {"PolyFormN1", "PolyForm-Noncommercial-1.0.0"}, 79 {"PolyFormN1.0", "PolyForm-Noncommercial-1.0.0"}, 80 {"PolyFormN1.0.0", "PolyForm-Noncommercial-1.0.0"}, 81 {"PolyForm-Small-Business1", "PolyForm-Small-Business-1.0.0"}, 82 {"PolyForm-Small-Business1.0", "PolyForm-Small-Business-1.0.0"}, 83 {"PolyForm-Small-Business1.0.0", "PolyForm-Small-Business-1.0.0"}, 84 {"PolyFormSB1", "PolyForm-Small-Business-1.0.0"}, 85 {"PolyFormSB1.0", "PolyForm-Small-Business-1.0.0"}, 86 {"PolyFormSB1.0.0", "PolyForm-Small-Business-1.0.0"}, 87 {"QPL1.0I2004", ""}, 88 {"QPL1I2004", ""}, 89 {"QPL1.0INRIA2004", "QPL-1.0-INRIA-2004"}, 90 {"QPL1INRIA2004", "QPL-1.0-INRIA-2004"}, 91 {"RHeCos1", ""}, 92 {"RHeCos1.1", "RHeCos-1.1"}, 93 {"RHeCos11", ""}, 94 } 95 96 for _, tc := range tests { 97 t.Run(tc.commonName, func(t *testing.T) { 98 got, ok := spdx.ShortIdentifier(tc.commonName) 99 if got == "" && ok { 100 t.Fatalf("spdx.ShortIdentifier(%q) found empty short identifier (%q): got ok==%v, want ok==false", tc.commonName, got, ok) 101 } 102 if got != tc.shortIdentifier { 103 t.Errorf("spdx.ShortIdentifier(%q) got %q, want %q", tc.commonName, got, tc.shortIdentifier) 104 } 105 }) 106 } 107 }