Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/Codebelt.Unitify/BinaryPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ public static double ConvertBytesToBits(double bytes)
{
var list = new List<BinaryPrefix>()
{
Exbi,
Gibi,
Kibi,
Mebi,
Pebi,
Gibi,
Tebi,
Pebi,
Exbi,
Zebi,
Yobi,
Zebi
Robi,
Quebi
};
return list;
});
Expand Down Expand Up @@ -110,9 +112,21 @@ public static double ConvertBytesToBits(double bytes)
public static BinaryPrefix Yobi => new("yobi", "Yi", 80);

/// <summary>
/// Gets the complete sequence of multiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE).
/// Gets the binary-multiple prefix robi (symbol 'Ri'), 2^90 = 1237940039285380274899124224.
/// </summary>
/// <value>The binary-multiple prefix robi (symbol 'Ri').</value>
public static BinaryPrefix Robi => new("robi", "Ri", 90);

/// <summary>
/// Gets the binary-multiple prefix quebi (symbol 'Qi'), 2^100 = 1267650600228229401496703205376.
/// </summary>
/// <value>The binary-multiple prefix quebi (symbol 'Qi').</value>
public static BinaryPrefix Quebi => new("quebi", "Qi", 100);

/// <summary>
/// Gets the complete sequence of multiples binary prefixes as specified by IEC 80000-13:2025, covering kibi (2^10) through quebi (2^100).
/// </summary>
/// <value>The complete sequence of multiples binary prefixes as specified by Institute of Electrical and Electronics Engineers (IEEE).</value>
/// <value>The complete sequence of multiples binary prefixes as specified by IEC 80000-13:2025.</value>
public static IEnumerable<BinaryPrefix> BinaryPrefixes => LazyPrefixes.Value;

/// <summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Codebelt.Unitify/PrefixTableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,25 @@ public static IPrefixUnit YobiOrDefault(this PrefixTable prefixes)
{
return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Yobi.Symbol);
}

/// <summary>
/// Returns the unit with the Robi prefix or the default value if not found.
/// </summary>
/// <param name="prefixes">The table of multiple units.</param>
/// <returns>The unit with the Robi prefix or the default value.</returns>
public static IPrefixUnit RobiOrDefault(this PrefixTable prefixes)
{
return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Robi.Symbol);
}

/// <summary>
/// Returns the unit with the Quebi prefix or the default value if not found.
/// </summary>
/// <param name="prefixes">The table of multiple units.</param>
/// <returns>The unit with the Quebi prefix or the default value.</returns>
public static IPrefixUnit QuebiOrDefault(this PrefixTable prefixes)
{
return prefixes.SingleOrDefault(p => p.Prefix.Symbol == BinaryPrefix.Quebi.Symbol);
}
Comment on lines +335 to +348
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new RobiOrDefault / QuebiOrDefault extension methods are not covered by tests, while similar *OrDefault methods are exercised in existing storage tests. Adding a small focused test (e.g., a minimal PrefixTable implementation containing Robi/Quebi prefix units) would help prevent accidental breakage/regressions in these lookups.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

}
}
20 changes: 20 additions & 0 deletions test/Codebelt.Unitify/BinaryPrefixTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Codebelt.Extensions.Xunit;
using Xunit;

Expand All @@ -21,6 +22,25 @@ public void BinaryPrefix_ShouldVerifyMultiplePrefixConstants()
Assert.Equal(BinaryPrefix.Exbi.Multiplier, Math.Pow(2, 60));
Assert.Equal(BinaryPrefix.Zebi.Multiplier, Math.Pow(2, 70));
Assert.Equal(BinaryPrefix.Yobi.Multiplier, Math.Pow(2, 80));
Assert.Equal(BinaryPrefix.Robi.Multiplier, Math.Pow(2, 90));
Assert.Equal(BinaryPrefix.Quebi.Multiplier, Math.Pow(2, 100));
}

[Fact]
public void BinaryPrefix_ShouldContainAllPrefixesInOrder()
{
var prefixes = BinaryPrefix.BinaryPrefixes.ToList();
Assert.Equal(10, prefixes.Count);
Assert.Equal("Ki", prefixes[0].Symbol);
Assert.Equal("Mi", prefixes[1].Symbol);
Assert.Equal("Gi", prefixes[2].Symbol);
Assert.Equal("Ti", prefixes[3].Symbol);
Assert.Equal("Pi", prefixes[4].Symbol);
Assert.Equal("Ei", prefixes[5].Symbol);
Assert.Equal("Zi", prefixes[6].Symbol);
Assert.Equal("Yi", prefixes[7].Symbol);
Assert.Equal("Ri", prefixes[8].Symbol);
Assert.Equal("Qi", prefixes[9].Symbol);
}
}
}
Loading