diff --git a/SimpleBase.sln b/SimpleBase.sln
index 4d0447d..a313e50 100644
--- a/SimpleBase.sln
+++ b/SimpleBase.sln
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
+ global.json = global.json
LICENSE.txt = LICENSE.txt
pack.cmd = pack.cmd
pack.sh = pack.sh
diff --git a/global.json b/global.json
new file mode 100644
index 0000000..72ca315
--- /dev/null
+++ b/global.json
@@ -0,0 +1,6 @@
+{
+ "sdk": {
+ "version": "8.0.100",
+ "rollForward": "latestMinor"
+ }
+}
\ No newline at end of file
diff --git a/src/Base16.cs b/src/Base16.cs
index 6c2e5b2..899c928 100644
--- a/src/Base16.cs
+++ b/src/Base16.cs
@@ -13,21 +13,16 @@ namespace SimpleBase;
///
/// Base16 encoding/decoding.
///
-public sealed class Base16 : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder
+///
+/// Initializes a new instance of the class.
+///
+/// Alphabet to use.
+public sealed class Base16(Base16Alphabet alphabet) : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder
{
private static readonly Lazy upperCase = new(() => new Base16(Base16Alphabet.UpperCase));
private static readonly Lazy lowerCase = new(() => new Base16(Base16Alphabet.LowerCase));
private static readonly Lazy modHex = new(() => new Base16(Base16Alphabet.ModHex));
- ///
- /// Initializes a new instance of the class.
- ///
- /// Alphabet to use.
- public Base16(Base16Alphabet alphabet)
- {
- Alphabet = alphabet;
- }
-
///
/// Gets upper case Base16 encoder. Decoding is case-insensitive.
///
@@ -46,7 +41,7 @@ public Base16(Base16Alphabet alphabet)
///
/// Gets the alphabet used by the encoder.
///
- public Base16Alphabet Alphabet { get; }
+ public Base16Alphabet Alphabet { get; } = alphabet;
///
/// Decode Upper/Lowercase Base16 text into bytes.
@@ -146,7 +141,7 @@ public byte[] Decode(ReadOnlySpan text)
int textLen = text.Length;
if (textLen == 0)
{
- return Array.Empty();
+ return [];
}
byte[] output = new byte[GetSafeByteCountForDecoding(text)];
diff --git a/src/Base32.cs b/src/Base32.cs
index 54fa1a3..177695d 100644
--- a/src/Base32.cs
+++ b/src/Base32.cs
@@ -196,7 +196,7 @@ public byte[] Decode(ReadOnlySpan text)
int outputLen = getAllocationByteCountForDecoding(textLen);
if (outputLen == 0)
{
- return Array.Empty();
+ return [];
}
var outputBuffer = new byte[outputLen];
diff --git a/src/Base58.cs b/src/Base58.cs
index 873a433..b7319ac 100644
--- a/src/Base58.cs
+++ b/src/Base58.cs
@@ -16,7 +16,12 @@ namespace SimpleBase;
/// Base58 doesn't implement a Stream-based interface because it's not feasible to use
/// on large buffers.
///
-public sealed class Base58 : IBaseCoder, INonAllocatingBaseCoder
+///
+/// Initializes a new instance of the class
+/// using a custom alphabet.
+///
+/// Alphabet to use.
+public sealed class Base58(Base58Alphabet alphabet) : IBaseCoder, INonAllocatingBaseCoder
{
private const int reductionFactor = 733; // https://github.com/bitcoin/bitcoin/blob/master/src/base58.cpp#L48
private const int divisor = 58;
@@ -27,17 +32,6 @@ public sealed class Base58 : IBaseCoder, INonAllocatingBaseCoder
private static readonly Lazy ripple = new(() => new Base58(Base58Alphabet.Ripple));
private static readonly Lazy flickr = new(() => new Base58(Base58Alphabet.Flickr));
- ///
- /// Initializes a new instance of the class
- /// using a custom alphabet.
- ///
- /// Alphabet to use.
- public Base58(Base58Alphabet alphabet)
- {
- Alphabet = alphabet;
- ZeroChar = alphabet.Value[0];
- }
-
///
/// Gets Bitcoin flavor.
///
@@ -56,12 +50,12 @@ public Base58(Base58Alphabet alphabet)
///
/// Gets the encoding alphabet.
///
- public Base58Alphabet Alphabet { get; }
+ public Base58Alphabet Alphabet { get; } = alphabet;
///
/// Gets the character for zero.
///
- public char ZeroChar { get; }
+ public char ZeroChar { get; } = alphabet.Value[0];
///
/// Retrieve safe byte count while avoiding multiple counting operations.
@@ -246,7 +240,7 @@ public byte[] Decode(ReadOnlySpan text)
{
if (text.Length == 0)
{
- return Array.Empty();
+ return [];
}
char zeroChar = ZeroChar;
diff --git a/src/Base58Alphabet.cs b/src/Base58Alphabet.cs
index 2902e90..c917b51 100644
--- a/src/Base58Alphabet.cs
+++ b/src/Base58Alphabet.cs
@@ -10,7 +10,12 @@ namespace SimpleBase;
///
/// Base58 alphabet.
///
-public sealed class Base58Alphabet : CodingAlphabet
+///
+/// Initializes a new instance of the class
+/// using a custom alphabet.
+///
+/// Alphabet to use.
+public sealed class Base58Alphabet(string alphabet) : CodingAlphabet(58, alphabet)
{
private static readonly Lazy bitcoinAlphabet = new(()
=> new Base58Alphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));
@@ -21,16 +26,6 @@ public sealed class Base58Alphabet : CodingAlphabet
private static readonly Lazy flickrAlphabet = new(()
=> new Base58Alphabet("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"));
- ///
- /// Initializes a new instance of the class
- /// using a custom alphabet.
- ///
- /// Alphabet to use.
- public Base58Alphabet(string alphabet)
- : base(58, alphabet)
- {
- }
-
///
/// Gets Bitcoin alphabet.
///
diff --git a/src/Base85.cs b/src/Base85.cs
index 24858b7..ba5c27a 100644
--- a/src/Base85.cs
+++ b/src/Base85.cs
@@ -14,7 +14,12 @@ namespace SimpleBase;
///
/// Base58 encoding/decoding class.
///
-public class Base85 : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder
+///
+/// Initializes a new instance of the class
+/// using a custom alphabet.
+///
+/// Alphabet to use.
+public class Base85(Base85Alphabet alphabet) : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder
{
private const int baseLength = 85;
private const int byteBlockSize = 4;
@@ -25,16 +30,6 @@ public class Base85 : IBaseCoder, IBaseStreamCoder, INonAllocatingBaseCoder
private static readonly Lazy ascii85 = new(() => new Base85(Base85Alphabet.Ascii85));
private static readonly Lazy rfc1924 = new(() => new Base85Ipv6(Base85Alphabet.Rfc1924));
- ///
- /// Initializes a new instance of the class
- /// using a custom alphabet.
- ///
- /// Alphabet to use.
- public Base85(Base85Alphabet alphabet)
- {
- Alphabet = alphabet;
- }
-
///
/// Gets Z85 flavor of Base85.
///
@@ -53,7 +48,7 @@ public Base85(Base85Alphabet alphabet)
///
/// Gets the encoding alphabet.
///
- public Base85Alphabet Alphabet { get; }
+ public Base85Alphabet Alphabet { get; } = alphabet;
///
public int GetSafeByteCountForDecoding(ReadOnlySpan text)
@@ -154,7 +149,7 @@ public byte[] Decode(ReadOnlySpan text)
{
if (text.Length == 0)
{
- return Array.Empty();
+ return [];
}
// allocate a larger buffer if we're using shortcuts
diff --git a/src/Base85Alphabet.cs b/src/Base85Alphabet.cs
index 23a89e3..c0c7c63 100644
--- a/src/Base85Alphabet.cs
+++ b/src/Base85Alphabet.cs
@@ -10,7 +10,17 @@ namespace SimpleBase;
///
/// Base85 Alphabet.
///
-public sealed class Base85Alphabet : CodingAlphabet
+///
+/// Initializes a new instance of the class
+/// using custom settings.
+///
+/// Alphabet to use.
+/// Character to substitute for all zero.
+/// Character to substitute for all space.
+public sealed class Base85Alphabet(
+ string alphabet,
+ char? allZeroShortcut = null,
+ char? allSpaceShortcut = null) : CodingAlphabet(85, alphabet)
{
private static readonly Lazy z85 = new(() => new Base85Alphabet(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"));
@@ -23,23 +33,6 @@ public sealed class Base85Alphabet : CodingAlphabet
private static readonly Lazy rfc1924 = new(() => new Base85Alphabet(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"));
- ///
- /// Initializes a new instance of the class
- /// using custom settings.
- ///
- /// Alphabet to use.
- /// Character to substitute for all zero.
- /// Character to substitute for all space.
- public Base85Alphabet(
- string alphabet,
- char? allZeroShortcut = null,
- char? allSpaceShortcut = null)
- : base(85, alphabet)
- {
- AllZeroShortcut = allZeroShortcut;
- AllSpaceShortcut = allSpaceShortcut;
- }
-
///
/// Gets ZeroMQ Z85 Alphabet.
///
@@ -59,12 +52,12 @@ public Base85Alphabet(
///
/// Gets the character to be used for "all zeros".
///
- public char? AllZeroShortcut { get; }
+ public char? AllZeroShortcut { get; } = allZeroShortcut;
///
/// Gets the character to be used for "all spaces".
///
- public char? AllSpaceShortcut { get; }
+ public char? AllSpaceShortcut { get; } = allSpaceShortcut;
///
/// Gets a value indicating whether the alphabet uses one of shortcut characters for all spaces
diff --git a/src/Base85Ipv6.cs b/src/Base85Ipv6.cs
index fa15c7c..51d360a 100644
--- a/src/Base85Ipv6.cs
+++ b/src/Base85Ipv6.cs
@@ -22,21 +22,16 @@ namespace SimpleBase;
/// So, that's why I only included a proof of concept implementation instead of working on optimizing it.
/// RFC 1924 should die, and this code should only be used to support some obscure standard or code somewhere.
///
-public class Base85Ipv6 : Base85
+///
+/// Initializes a new instance of the class.
+///
+/// Coding alphabet.
+public class Base85Ipv6(Base85Alphabet alphabet) : Base85(alphabet)
{
private const int ipv6bytes = 16;
private const int ipv6chars = 20;
private static readonly BigInteger divisor = new(85);
- ///
- /// Initializes a new instance of the class.
- ///
- /// Coding alphabet.
- public Base85Ipv6(Base85Alphabet alphabet)
- : base(alphabet)
- {
- }
-
///
/// Encode IPv6 address into RFC 1924 Base85 text.
///
diff --git a/src/SimpleBase.csproj b/src/SimpleBase.csproj
index 8f819a0..ac577ba 100644
--- a/src/SimpleBase.csproj
+++ b/src/SimpleBase.csproj
@@ -74,10 +74,6 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
- all
- runtime; build; native; contentfiles; analyzers
-
all
diff --git a/test/Base16/Base16Test.cs b/test/Base16/Base16Test.cs
index 13e60c7..b21ebfd 100644
--- a/test/Base16/Base16Test.cs
+++ b/test/Base16/Base16Test.cs
@@ -12,22 +12,22 @@ namespace SimpleBaseTest.Base16Test;
[Parallelizable]
internal class Base16Test
{
- private static readonly Base16[] encoders = new[]
- {
+ private static readonly Base16[] encoders =
+ [
Base16.LowerCase,
Base16.UpperCase,
Base16.ModHex
- };
-
- private static readonly object[][] testCases = new[]
- { // LowerCase // UpperCase // ModHex
- new object[] { Array.Empty(), "", "", "" },
- new object[] { new byte[] { 0xAB }, "ab", "AB", "ln" },
- new object[] { new byte[] { 0x00, 0x01, 0x02, 0x03 }, "00010203", "00010203", "cccbcdce" },
- new object[] { new byte[] { 0x10, 0x11, 0x12, 0x13 }, "10111213", "10111213", "bcbbbdbe" },
- new object[] { new byte[] { 0xAB, 0xCD, 0xEF, 0xBA }, "abcdefba", "ABCDEFBA", "lnrtuvnl" },
- new object[] { new byte[] { 0xAB, 0xCD, 0xEF, 0xBA, 0xAB, 0xCD, 0xEF, 0xBA }, "abcdefbaabcdefba", "ABCDEFBAABCDEFBA", "lnrtuvnllnrtuvnl" },
- };
+ ];
+
+ private static readonly object[][] testCases =
+ [ // LowerCase // UpperCase // ModHex
+ [Array.Empty(), "", "", ""],
+ [new byte[] { 0xAB }, "ab", "AB", "ln"],
+ [new byte[] { 0x00, 0x01, 0x02, 0x03 }, "00010203", "00010203", "cccbcdce"],
+ [new byte[] { 0x10, 0x11, 0x12, 0x13 }, "10111213", "10111213", "bcbbbdbe"],
+ [new byte[] { 0xAB, 0xCD, 0xEF, 0xBA }, "abcdefba", "ABCDEFBA", "lnrtuvnl"],
+ [new byte[] { 0xAB, 0xCD, 0xEF, 0xBA, 0xAB, 0xCD, 0xEF, 0xBA }, "abcdefbaabcdefba", "ABCDEFBAABCDEFBA", "lnrtuvnllnrtuvnl"],
+ ];
private static IEnumerable testData
{
diff --git a/test/Base32/Bech32Test.cs b/test/Base32/Bech32Test.cs
index 5852dbc..243f1fe 100644
--- a/test/Base32/Bech32Test.cs
+++ b/test/Base32/Bech32Test.cs
@@ -9,21 +9,21 @@ namespace SimpleBaseTest.Base32Test;
class Bech32Test
{
// test data was genereated with cryptii.com with a custom alphabet
- private static readonly string[][] testData = new[]
- {
- new[] { "", "" },
- new[] {"f", "vc======" },
- new[] {"fo", "vehs====" },
- new[] {"foo", "vehk7===" },
- new[] {"foob", "vehk7cs=" },
- new[] {"fooba", "vehk7cnp" },
- new[] {"foobar", "vehk7cnpwg======" },
- new[] {"foobar1", "vehk7cnpwgcs====" },
- new[] {"foobar12", "vehk7cnpwgcny===" },
- new[] {"foobar123", "vehk7cnpwgcnyvc=" },
- new[] {"foobar1234", "vehk7cnpwgcnyve5" },
- new[] {"1234567890123456789012345678901234567890", "xyerxdp4xcmnswfsxyerxdp4xcmnswfsxyerxdp4xcmnswfsxyerxdp4xcmnswfs" },
- };
+ private static readonly string[][] testData =
+ [
+ ["", ""],
+ ["f", "vc======"],
+ ["fo", "vehs===="],
+ ["foo", "vehk7==="],
+ ["foob", "vehk7cs="],
+ ["fooba", "vehk7cnp"],
+ ["foobar", "vehk7cnpwg======"],
+ ["foobar1", "vehk7cnpwgcs===="],
+ ["foobar12", "vehk7cnpwgcny==="],
+ ["foobar123", "vehk7cnpwgcnyvc="],
+ ["foobar1234", "vehk7cnpwgcnyve5"],
+ ["1234567890123456789012345678901234567890", "xyerxdp4xcmnswfsxyerxdp4xcmnswfsxyerxdp4xcmnswfsxyerxdp4xcmnswfs"],
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base32/CrockfordTest.cs b/test/Base32/CrockfordTest.cs
index 9187581..67cda58 100644
--- a/test/Base32/CrockfordTest.cs
+++ b/test/Base32/CrockfordTest.cs
@@ -26,30 +26,30 @@ namespace SimpleBaseTest.Base32Test;
[TestFixture]
class CrockfordTest
{
- private static readonly object[][] testData = {
- new object[] { "", "", false },
- new object[] { "f", "CR", false },
- new object[] { "f", "CR======", true },
- new object[] { "fo", "CSQG", false },
- new object[] { "fo", "CSQG====", true },
- new object[] { "foo", "CSQPY", false },
- new object[] { "foo", "CSQPY===", true },
- new object[] { "foob", "CSQPYRG", false },
- new object[] { "foob", "CSQPYRG=", true },
- new object[] { "fooba", "CSQPYRK1", false },
- new object[] { "fooba", "CSQPYRK1", true },
- new object[] { "foobar", "CSQPYRK1E8", false },
- new object[] { "foobar", "CSQPYRK1E8======", true },
- new object[] { "123456789012345678901234567890123456789", "64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE8", false },
- new object[] { "123456789012345678901234567890123456789", "64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE8=", true }
- };
+ private static readonly object[][] testData = [
+ ["", "", false],
+ ["f", "CR", false],
+ ["f", "CR======", true],
+ ["fo", "CSQG", false],
+ ["fo", "CSQG====", true],
+ ["foo", "CSQPY", false],
+ ["foo", "CSQPY===", true],
+ ["foob", "CSQPYRG", false],
+ ["foob", "CSQPYRG=", true],
+ ["fooba", "CSQPYRK1", false],
+ ["fooba", "CSQPYRK1", true],
+ ["foobar", "CSQPYRK1E8", false],
+ ["foobar", "CSQPYRK1E8======", true],
+ ["123456789012345678901234567890123456789", "64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE8", false],
+ ["123456789012345678901234567890123456789", "64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE9G64S36D1N6RVKGE8=", true]
+ ];
[Test]
public void Encode_SampleInterface_Compiles()
{
// this source code exists in samples and just needs to be compiled and run without errors.
// do not edit/refactor the code below
- byte[] myBuffer = Array.Empty();
+ byte[] myBuffer = [];
string result = Base32.Crockford.Encode(myBuffer, padding: true);
Assert.That(result, Is.Empty);
}
diff --git a/test/Base32/ExtendedHexTest.cs b/test/Base32/ExtendedHexTest.cs
index a1b9ef2..81f7933 100644
--- a/test/Base32/ExtendedHexTest.cs
+++ b/test/Base32/ExtendedHexTest.cs
@@ -24,17 +24,17 @@ namespace SimpleBaseTest.Base32Test;
[TestFixture]
class ExtendedHexTest
{
- private static readonly string[][] testData = new[]
- {
- new[] { "", "" },
- new[] { "f", "CO======" },
- new[] { "fo", "CPNG====" },
- new[] { "foo", "CPNMU===" },
- new[] { "foob", "CPNMUOG=" },
- new[] { "fooba", "CPNMUOJ1" },
- new[] { "foobar", "CPNMUOJ1E8======" },
- new[] { "1234567890123456789012345678901234567890", "64P36D1L6ORJGE9G64P36D1L6ORJGE9G64P36D1L6ORJGE9G64P36D1L6ORJGE9G" },
- };
+ private static readonly string[][] testData =
+ [
+ ["", ""],
+ ["f", "CO======"],
+ ["fo", "CPNG===="],
+ ["foo", "CPNMU==="],
+ ["foob", "CPNMUOG="],
+ ["fooba", "CPNMUOJ1"],
+ ["foobar", "CPNMUOJ1E8======"],
+ ["1234567890123456789012345678901234567890", "64P36D1L6ORJGE9G64P36D1L6ORJGE9G64P36D1L6ORJGE9G64P36D1L6ORJGE9G"],
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base32/FileCoinTest.cs b/test/Base32/FileCoinTest.cs
index c334765..97cd9ad 100644
--- a/test/Base32/FileCoinTest.cs
+++ b/test/Base32/FileCoinTest.cs
@@ -9,25 +9,25 @@ namespace SimpleBaseTest.Base32Test;
[TestFixture]
class FileCoinTest
{
- private static readonly string[][] testData = new[]
- {
- new[] { "", "" },
- new[] {"f", "my======" },
- new[] {"fo", "mzxq====" },
- new[] {"foo", "mzxw6===" },
- new[] {"foob", "mzxw6yq=" },
- new[] {"fooba", "mzxw6ytb" },
- new[] {"foobar", "mzxw6ytboi======" },
- new[] {"foobar1", "mzxw6ytboiyq====" },
- new[] {"foobar12", "mzxw6ytboiyte===" },
- new[] {"foobar123", "mzxw6ytboiytemy=" },
- new[] {"1234567890123456789012345678901234567890", "gezdgnbvgy3tqojqgezdgnbvgy3tqojqgezdgnbvgy3tqojqgezdgnbvgy3tqojq" }
- };
+ private static readonly string[][] testData =
+ [
+ ["", ""],
+ ["f", "my======"],
+ ["fo", "mzxq===="],
+ ["foo", "mzxw6==="],
+ ["foob", "mzxw6yq="],
+ ["fooba", "mzxw6ytb"],
+ ["foobar", "mzxw6ytboi======"],
+ ["foobar1", "mzxw6ytboiyq===="],
+ ["foobar12", "mzxw6ytboiyte==="],
+ ["foobar123", "mzxw6ytboiytemy="],
+ ["1234567890123456789012345678901234567890", "gezdgnbvgy3tqojqgezdgnbvgy3tqojqgezdgnbvgy3tqojqgezdgnbvgy3tqojq"]
+ ];
- private static readonly object[] byteTestData = new object[]
- {
+ private static readonly object[] byteTestData =
+ [
new object[] { new byte[] { 245, 202, 80, 149, 94, 201, 222, 50, 17, 198, 138, 104, 32, 183, 131, 33, 139, 208, 203, 211, 197, 191, 92, 194 }, "6xffbfk6zhpdeeogrjucbn4degf5bs6tyw7vzqq", false },
- };
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base32/Rfc4648Test.cs b/test/Base32/Rfc4648Test.cs
index ccbee10..c503a3b 100644
--- a/test/Base32/Rfc4648Test.cs
+++ b/test/Base32/Rfc4648Test.cs
@@ -23,20 +23,20 @@ namespace SimpleBaseTest.Base32Test;
[TestFixture]
class Rfc4648Test
{
- private static readonly string[][] testData = new[]
- {
- new[] { "", "" },
- new[] {"f", "MY======" },
- new[] {"fo", "MZXQ====" },
- new[] {"foo", "MZXW6===" },
- new[] {"foob", "MZXW6YQ=" },
- new[] {"fooba", "MZXW6YTB" },
- new[] {"foobar", "MZXW6YTBOI======" },
- new[] {"foobar1", "MZXW6YTBOIYQ====" },
- new[] {"foobar12", "MZXW6YTBOIYTE===" },
- new[] {"foobar123", "MZXW6YTBOIYTEMY=" },
- new[] {"1234567890123456789012345678901234567890", "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ" },
- };
+ private static readonly string[][] testData =
+ [
+ ["", ""],
+ ["f", "MY======"],
+ ["fo", "MZXQ===="],
+ ["foo", "MZXW6==="],
+ ["foob", "MZXW6YQ="],
+ ["fooba", "MZXW6YTB"],
+ ["foobar", "MZXW6YTBOI======"],
+ ["foobar1", "MZXW6YTBOIYQ===="],
+ ["foobar12", "MZXW6YTBOIYTE==="],
+ ["foobar123", "MZXW6YTBOIYTEMY="],
+ ["1234567890123456789012345678901234567890", "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ"],
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base32/ZBase32Test.cs b/test/Base32/ZBase32Test.cs
index b8ac7da..b80917f 100644
--- a/test/Base32/ZBase32Test.cs
+++ b/test/Base32/ZBase32Test.cs
@@ -23,13 +23,13 @@ namespace SimpleBaseTest.Base32Test;
[TestFixture]
class ZBase32Test
{
- private static readonly string[][] testData = new[]
- {
- new[] { "", "" },
- new[] { "dCode z-base-32", "ctbs63dfrb7n4aubqp114c31" },
- new[] { "Never did sun more beautifully steep",
- "j31zc3m1rb1g13byqp4shedpp73gkednciozk7djc34sa5d3rb3ze3mfqy" },
- };
+ private static readonly string[][] testData =
+ [
+ ["", ""],
+ ["dCode z-base-32", "ctbs63dfrb7n4aubqp114c31"],
+ [ "Never did sun more beautifully steep",
+ "j31zc3m1rb1g13byqp4shedpp73gkednciozk7djc34sa5d3rb3ze3mfqy" ],
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base58/Base58CheckTest.cs b/test/Base58/Base58CheckTest.cs
index 0b1b2f7..20936ca 100644
--- a/test/Base58/Base58CheckTest.cs
+++ b/test/Base58/Base58CheckTest.cs
@@ -25,8 +25,8 @@ public class Base58CheckTest
//WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
//ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
//OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- private static readonly object[] testData = new object[]
- {
+ private static readonly object[] testData =
+ [
new object[] { 20, "", "3MNQE1X"},
new object[] { 20, " ", "B2Kr6dBE"},
new object[] { 20, "-", "B3jv1Aft"},
@@ -38,7 +38,7 @@ public class Base58CheckTest
new object[] { 20, "1234598760", "ZmNb8uQn5zvnUohNCEPP"},
new object[] { 20, "abcdefghijklmnopqrstuvwxyz", "K2RYDcKfupxwXdWhSAxQPCeiULntKm63UXyx5MvEH2"},
new object[] { 20, "00000000000000000000000000000000000000000000000000000000000000", "bi1EWXwJay2udZVxLJozuTb8Meg4W9c6xnmJaRDjg6pri5MBAxb9XwrpQXbtnqEoRV5U2pixnFfwyXC8tRAVC8XxnjK"},
- };
+ ];
[Test]
[TestCaseSource(nameof(testData))]
diff --git a/test/Base58/BitcoinTest.cs b/test/Base58/BitcoinTest.cs
index e477bcd..e5c01c9 100644
--- a/test/Base58/BitcoinTest.cs
+++ b/test/Base58/BitcoinTest.cs
@@ -24,8 +24,8 @@ namespace SimpleBaseTest.Base58Test;
[Parallelizable]
class BitcoinTest
{
- private static readonly TestCaseData[] bitcoinTestData = new TestCaseData[]
- {
+ private static readonly TestCaseData[] bitcoinTestData =
+ [
new TestCaseData("0001", "12"),
new TestCaseData("0000010203", "11Ldp"),
new TestCaseData("009C1CA2CBA6422D3988C735BB82B5C880B0441856B9B0910F", "1FESiat4YpNeoYhW3Lp7sW1T6WydcW7vcE"),
@@ -38,7 +38,7 @@ class BitcoinTest
new TestCaseData("21", "a"),
new TestCaseData("000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F", "1thX6LZfHDZZKUs92febWaf4WJZnsKRiVwJusXxB7L"),
new TestCaseData("0000000000000000000000000000000000000000000000000000", "11111111111111111111111111"),
- };
+ ];
[Test]
public void Encode_NullBuffer_ReturnsEmptyString()
diff --git a/test/Base58/Cb58Test.cs b/test/Base58/Cb58Test.cs
index 9757546..df437e0 100644
--- a/test/Base58/Cb58Test.cs
+++ b/test/Base58/Cb58Test.cs
@@ -38,14 +38,14 @@ public class Cb58Test
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
//OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- private static readonly TestCaseData[] testData = new []
- {
- new TestCaseData(Array.Empty(), "45PJLL"),
+ private static readonly TestCaseData[] testData =
+ [
+ new TestCaseData(Array.Empty(), "45PJLL"),
new TestCaseData(new byte[]{ 0}, "1c7hwa"),
new TestCaseData(new byte[]{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255}, "1NVSVezva3bAtJesnUj"),
new TestCaseData(new byte[32] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 },
"SkB92YpWm4Q2ijQHH34cqbKkCZWszsiQgHVjtNeFF2HdvDQU"),
- };
+ ];
[Test]
diff --git a/test/Base58/FlickrTest.cs b/test/Base58/FlickrTest.cs
index 0a77454..3258c34 100644
--- a/test/Base58/FlickrTest.cs
+++ b/test/Base58/FlickrTest.cs
@@ -24,8 +24,8 @@ namespace SimpleBaseTest.Base58Test;
[Parallelizable]
class FlickrTest
{
- private static readonly TestCaseData[] flickrTestData = new TestCaseData[]
- {
+ private static readonly TestCaseData[] flickrTestData =
+ [
new TestCaseData("0000010203", "11kCP"),
new TestCaseData("009C1CA2CBA6422D3988C735BB82B5C880B0441856B9B0910F", "1ferHzT4xPnDNxGv3kP7Sv1s6vYCBv7VBe"),
new TestCaseData("000860C220EBBAF591D40F51994C4E2D9C9D88168C33E761F6", "1LijqnBz45gt2ipUhyQyJhfnKTzQaS7FG"),
@@ -35,7 +35,7 @@ class FlickrTest
new TestCaseData("FFEEDDCCBBAA", "3crWn61oo"),
new TestCaseData("00", "1"),
new TestCaseData("21", "z"),
- };
+ ];
[Test]
public void Encode_NullBuffer_ReturnsEmptyString()
diff --git a/test/Base58/RippleTest.cs b/test/Base58/RippleTest.cs
index 77e59b2..57768e2 100644
--- a/test/Base58/RippleTest.cs
+++ b/test/Base58/RippleTest.cs
@@ -24,8 +24,8 @@ namespace SimpleBaseTest.Base58Test;
[Parallelizable]
class RippleTest
{
- private static readonly TestCaseData[] rippleTestData = new TestCaseData[]
- {
+ private static readonly TestCaseData[] rippleTestData =
+ [
new TestCaseData("0000010203", "rrLdF"),
new TestCaseData("009C1CA2CBA6422D3988C735BB82B5C880B0441856B9B0910F", "rENS52thYF4eoY6WsLFf1WrTaWydcWfvcN"),
new TestCaseData("000860C220EBBAF591D40F51994C4E2D9C9D88168C33E761F6", "rmJKR4c2hnG7pJQuHZqZjHE4kt2qw1fg6"),
@@ -35,7 +35,7 @@ class RippleTest
new TestCaseData("FFEEDDCCBBAA", "sUSA4arPP"),
new TestCaseData("00", "r"),
new TestCaseData("21", "2"),
- };
+ ];
[Test]
public void Encode_NullBuffer_ReturnsEmptyString()
diff --git a/test/Base85/Ascii85Test.cs b/test/Base85/Ascii85Test.cs
index 9df9e73..3ee3e85 100644
--- a/test/Base85/Ascii85Test.cs
+++ b/test/Base85/Ascii85Test.cs
@@ -8,16 +8,16 @@ namespace SimpleBaseTest.Base85Test;
internal class Ascii85Test
{
- private static readonly object[][] testVectors = new object[][]
- {
- new object[] { Array.Empty(), "" },
- new object[] { new byte[] { 0, 0, 0, 0 }, "z" },
- new object[] { new byte[] { 0x20, 0x20, 0x20, 0x20 }, "y" },
- new object[] { new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45 }, "5sdq,70" },
- new object[] { new byte[] { 0x86, 0x4F, 0xD2, 0x6F, 0xB5, 0x59, 0xF7, 0x5B }, "L/669[9<6." },
- new object[] { new byte[] { 0x11, 0x22, 0x33 }, "&L'\"" },
- new object[] { new byte[] { 77, 97, 110, 32 }, "9jqo^" },
- };
+ private static readonly object[][] testVectors =
+ [
+ [Array.Empty(), ""],
+ [new byte[] { 0, 0, 0, 0 }, "z"],
+ [new byte[] { 0x20, 0x20, 0x20, 0x20 }, "y"],
+ [new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45 }, "5sdq,70"],
+ [new byte[] { 0x86, 0x4F, 0xD2, 0x6F, 0xB5, 0x59, 0xF7, 0x5B }, "L/669[9<6."],
+ [new byte[] { 0x11, 0x22, 0x33 }, "&L'\""],
+ [new byte[] { 77, 97, 110, 32 }, "9jqo^"],
+ ];
[Test]
public void Decode_InvalidShortcut_ThrowsArgumentException()
diff --git a/test/Base85/Z85Test.cs b/test/Base85/Z85Test.cs
index b951502..482f3ab 100644
--- a/test/Base85/Z85Test.cs
+++ b/test/Base85/Z85Test.cs
@@ -6,8 +6,8 @@ namespace SimpleBaseTest.Base85Test;
class Z85Test
{
- private static readonly TestCaseData[] testVectors = new[]
- {
+ private static readonly TestCaseData[] testVectors =
+ [
new TestCaseData(Array.Empty(), ""),
new TestCaseData(new byte[] { 0x86, 0x4F, 0xD2, 0x6F, 0xB5, 0x59, 0xF7, 0x5B }, "HelloWorld"),
new TestCaseData(new byte[] { 0x11 }, "5D"),
@@ -17,7 +17,7 @@ class Z85Test
new TestCaseData(new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55 }, "5H620rr"),
new TestCaseData(new byte[] { 0x00, 0x00, 0x00, 0x00 }, "00000"),
new TestCaseData(new byte[] { 0x20, 0x20, 0x20, 0x20 }, "arR^H"),
- };
+ ];
[Test]
[TestCaseSource(nameof(testVectors))]