diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 0000000..2032a49 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,41 @@ +name: .NET + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ${{ matrix.dotnet.os }}-latest + + strategy: + matrix: + dotnet: [ + { os: 'windows', version: '2', tfm: 'net20' }, + { os: 'windows', version: '4', tfm: 'net40' }, + { os: 'ubuntu', version: '6', tfm: 'net6.0' }, + { os: 'ubuntu', version: '8', tfm: 'net8.0' }, + ] + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + if: endsWith(matrix.dotnet.tfm, '.0') # only for .NET core + uses: actions/setup-dotnet@v4 + id: stepid + with: + dotnet-version: ${{ matrix.dotnet.version }} + # Without global.json, tests will be executed under the latest installed version! + - name: Create temporary global.json + if: endsWith(matrix.dotnet.tfm, '.0') # only for .NET core + run: echo '{"sdk":{"version":"${{steps.stepid.outputs.dotnet-version}}"}}' > ./global.json + - name: Restore packages + run: dotnet restore UrlBase64/UrlBase64.csproj -p:Configuration=Release -p:TargetFrameworks="${{ matrix.dotnet.tfm }}" -p:LangVersion="latest" --verbosity normal + - name: Build solution + run: dotnet build UrlBase64/UrlBase64.csproj -p:Configuration=Release -p:TargetFrameworks="${{ matrix.dotnet.tfm }}" -p:LangVersion="latest" --verbosity normal + - name: Run tests + if: endsWith(matrix.dotnet.tfm, '.0') # only for .NET core + run: dotnet test -p:Configuration=Release --verbosity normal -p:TargetFrameworks="${{ matrix.dotnet.tfm }}" -p:LangVersion="latest" diff --git a/Benchmark/Benchmark.csproj b/Benchmark/Benchmark.csproj index acea364..9867a4d 100644 --- a/Benchmark/Benchmark.csproj +++ b/Benchmark/Benchmark.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net8.0 enable enable diff --git a/Tests/EncodeDecode.cs b/Tests/EncodeDecode.cs index 04df335..5476dcb 100644 --- a/Tests/EncodeDecode.cs +++ b/Tests/EncodeDecode.cs @@ -177,13 +177,13 @@ public void DecodeNonUrlSafeBase64() { // Decoding regular base64 input with + instead of - var input = "Q29udGFpbnMgYSBwbHVzIMOlw6bDn+KApuKIgsuaxpLiiIY="; - byte[] expected = [0x43, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x20, 0x61, 0x20, 0x70, 0x6C, 0x75, 0x73, 0x20, 0xC3, 0xA5, 0xC3, 0xA6, 0xC3, 0x9F, 0xE2, 0x80, 0xA6, 0xE2, 0x88, 0x82, 0xCB, 0x9A, 0xC6, 0x92, 0xE2, 0x88, 0x86]; + byte[] expected = new byte[] { 0x43, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x20, 0x61, 0x20, 0x70, 0x6C, 0x75, 0x73, 0x20, 0xC3, 0xA5, 0xC3, 0xA6, 0xC3, 0x9F, 0xE2, 0x80, 0xA6, 0xE2, 0x88, 0x82, 0xCB, 0x9A, 0xC6, 0x92, 0xE2, 0x88, 0x86 }; var actual = UrlBase64.Decode(input); CollectionAssert.AreEqual(expected, actual, "Mismatch in comparison results!"); // Decoding regular base64 input with / instead of _ input = "Q29udGFpbnMgYSBzbGFzaCDDuOKImsucw5/iiILiiJrLmsOn4oiC4omkw58="; - expected = [0x43, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x20, 0x61, 0x20, 0x73, 0x6C, 0x61, 0x73, 0x68, 0x20, 0xC3, 0xB8, 0xE2, 0x88, 0x9A, 0xCB, 0x9C, 0xC3, 0x9F, 0xE2, 0x88, 0x82, 0xE2, 0x88, 0x9A, 0xCB, 0x9A, 0xC3, 0xA7, 0xE2, 0x88, 0x82, 0xE2, 0x89, 0xA4, 0xC3, 0x9F]; + expected = new byte[] { 0x43, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x20, 0x61, 0x20, 0x73, 0x6C, 0x61, 0x73, 0x68, 0x20, 0xC3, 0xB8, 0xE2, 0x88, 0x9A, 0xCB, 0x9C, 0xC3, 0x9F, 0xE2, 0x88, 0x82, 0xE2, 0x88, 0x9A, 0xCB, 0x9A, 0xC3, 0xA7, 0xE2, 0x88, 0x82, 0xE2, 0x89, 0xA4, 0xC3, 0x9F }; actual = UrlBase64.Decode(input); CollectionAssert.AreEqual(expected, actual, "Mismatch in comparison results!"); } @@ -196,7 +196,7 @@ public void DecodeInvalid() Assert.ThrowsException(() => UrlBase64.Decode("!!")); // ...and this doesn't - UrlBase64.Decode(UrlBase64.Encode([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])); + UrlBase64.Decode(UrlBase64.Encode(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF })); } } diff --git a/UrlBase64/UrlBase64.csproj b/UrlBase64/UrlBase64.csproj index 058f2c3..56083ce 100644 --- a/UrlBase64/UrlBase64.csproj +++ b/UrlBase64/UrlBase64.csproj @@ -57,7 +57,7 @@ - + $(DefineConstants);WITH_SPAN @@ -74,4 +74,4 @@ 10.0 - \ No newline at end of file +