| 1 | package spdxexpscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.24 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/" |
| 7 | ) |
| 8 | |
| 9 | func TestActiveLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/TestActiveLicense().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | inputID string |
| 13 | outputID string |
| 14 | result bool |
| 15 | }{ |
| 16 | {"active license - direct match", "Apache-2.0", "Apache-2.0", true}, |
| 17 | {"active license - all upper", "APACHE-2.0", "Apache-2.0", true}, |
| 18 | {"active license - all lower", "apache-2.0", "Apache-2.0", true}, |
| 19 | {"active license - mixed case", "apACHe-2.0", "Apache-2.0", true}, |
| 20 | {"deprecated license - direct match", "eCos-2.0", "eCos-2.0", false}, |
| 21 | {"deprecated license - all upper", "ECOS-2.0", "eCos-2.0", false}, |
| 22 | {"deprecated license - all lower", "ecos-2.0", "eCos-2.0", false}, |
| 23 | {"deprecated license - mixed case", "ECos-2.0", "eCos-2.0", false}, |
| 24 | {"exception license - direct match", "Bison-exception-2.2", "Bison-exception-2.2", false}, |
| 25 | {"exception license - all upper", "BISON-EXCEPTION-2.2", "Bison-exception-2.2", false}, |
| 26 | {"exception license - all lower", "bison-exception-2.2", "Bison-exception-2.2", false}, |
| 27 | {"exception license - mixed case", "BisoN-Exception-2.2", "Bison-exception-2.2", false}, |
| 28 | } |
| 29 | |
| 30 | for _, test := range tests { |
| 31 | test := test |
| 32 | t.Runscip-go gomod github.com/golang/go/src go1.24 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 33 | result, license := activeLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/activeLicense().((test.inputID)) |
| 34 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.result, result) |
| 35 | if result { |
| 36 | // updated to the proper case if found |
| 37 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.outputID, license) |
| 38 | } else { |
| 39 | // no change in case if not found |
| 40 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.inputID, license) |
| 41 | } |
| 42 | }) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | func TestDeprecatedLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/TestDeprecatedLicense().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 47 | tests := []struct { |
| 48 | name string |
| 49 | inputID string |
| 50 | outputID string |
| 51 | result bool |
| 52 | }{ |
| 53 | {"active license - direct match", "Apache-2.0", "Apache-2.0", false}, |
| 54 | {"active license - all upper", "APACHE-2.0", "Apache-2.0", false}, |
| 55 | {"active license - all lower", "apache-2.0", "Apache-2.0", false}, |
| 56 | {"active license - mixed case", "apACHe-2.0", "Apache-2.0", false}, |
| 57 | {"deprecated license - direct match", "eCos-2.0", "eCos-2.0", true}, |
| 58 | {"deprecated license - all upper", "ECOS-2.0", "eCos-2.0", true}, |
| 59 | {"deprecated license - all lower", "ecos-2.0", "eCos-2.0", true}, |
| 60 | {"deprecated license - mixed case", "ECos-2.0", "eCos-2.0", true}, |
| 61 | {"exception license - direct match", "Bison-exception-2.2", "Bison-exception-2.2", false}, |
| 62 | {"exception license - all upper", "BISON-EXCEPTION-2.2", "Bison-exception-2.2", false}, |
| 63 | {"exception license - all lower", "bison-exception-2.2", "Bison-exception-2.2", false}, |
| 64 | {"exception license - mixed case", "BisoN-Exception-2.2", "Bison-exception-2.2", false}, |
| 65 | } |
| 66 | |
| 67 | for _, test := range tests { |
| 68 | test := test |
| 69 | t.Runscip-go gomod github.com/golang/go/src go1.24 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 70 | result, license := deprecatedLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/deprecatedLicense().((test.inputID)) |
| 71 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.result, result) |
| 72 | if result { |
| 73 | // updated to the proper case if found |
| 74 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.outputID, license) |
| 75 | } else { |
| 76 | // no change in case if not found |
| 77 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.inputID, license) |
| 78 | } |
| 79 | }) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | func TestExceptionLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/TestExceptionLicense().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 84 | tests := []struct { |
| 85 | name string |
| 86 | inputID string |
| 87 | outputID string |
| 88 | result bool |
| 89 | }{ |
| 90 | {"active license - direct match", "Apache-2.0", "Apache-2.0", false}, |
| 91 | {"active license - all upper", "APACHE-2.0", "Apache-2.0", false}, |
| 92 | {"active license - all lower", "apache-2.0", "Apache-2.0", false}, |
| 93 | {"active license - mixed case", "apACHe-2.0", "Apache-2.0", false}, |
| 94 | {"deprecated license - direct match", "eCos-2.0", "eCos-2.0", false}, |
| 95 | {"deprecated license - all upper", "ECOS-2.0", "eCos-2.0", false}, |
| 96 | {"deprecated license - all lower", "ecos-2.0", "eCos-2.0", false}, |
| 97 | {"deprecated license - mixed case", "ECos-2.0", "eCos-2.0", false}, |
| 98 | {"exception license - direct match", "Bison-exception-2.2", "Bison-exception-2.2", true}, |
| 99 | {"exception license - all upper", "BISON-EXCEPTION-2.2", "Bison-exception-2.2", true}, |
| 100 | {"exception license - all lower", "bison-exception-2.2", "Bison-exception-2.2", true}, |
| 101 | {"exception license - mixed case", "BisoN-Exception-2.2", "Bison-exception-2.2", true}, |
| 102 | } |
| 103 | |
| 104 | for _, test := range tests { |
| 105 | test := test |
| 106 | t.Runscip-go gomod github.com/golang/go/src go1.24 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 107 | result, license := exceptionLicensescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/exceptionLicense().((test.inputID)) |
| 108 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.result, result) |
| 109 | if result { |
| 110 | // updated to the proper case if found |
| 111 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.outputID, license) |
| 112 | } else { |
| 113 | // no change in case if not found |
| 114 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.inputID, license) |
| 115 | } |
| 116 | }) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | func TestGetLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/TestGetLicenseRange().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 121 | tests := []struct { |
| 122 | name string |
| 123 | id string |
| 124 | licenseRange *licenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange# |
| 125 | }{ |
| 126 | {"no multi-element ranges", "Apache-2.0", &licenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#{ |
| 127 | licensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#licenses.: []string{"Apache-2.0"}, |
| 128 | locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.: map[uint8]int{licenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseGroup.: 2, versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.: 2, licenseIndexscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseIndex.: 0}}}, |
| 129 | {"multi-element ranges", "GFDL-1.2-only", &licenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#{ |
| 130 | licensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#licenses.: []string{"GFDL-1.2", "GFDL-1.2-only"}, |
| 131 | locationscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseRange#location.: map[uint8]int{licenseGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseGroup.: 21, versionGroupscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/versionGroup.: 1, licenseIndexscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/licenseIndex.: 1}}}, |
| 132 | {"no range", "Bison-exception-2.2", nil}, |
| 133 | } |
| 134 | |
| 135 | for _, test := range tests { |
| 136 | test := test |
| 137 | t.Runscip-go gomod github.com/golang/go/src go1.24 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) { |
| 138 | licenseRange := getLicenseRangescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/getLicenseRange().(test.id) |
| 139 | assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/Equal().(t, test.licenseRange, licenseRange) |
| 140 | }) |
| 141 | } |
| 142 | } |