feat(batch1): implement proto varint encoder parity

This commit is contained in:
Joseph Doherty
2026-02-28 06:35:12 -05:00
parent c1ae46fc66
commit 3c98c4c4fd
5 changed files with 84 additions and 4 deletions

View File

@@ -311,4 +311,10 @@ public static class ProtoWire
(byte)((v >> 56) & 0x7F | 0x80),
1];
}
/// <summary>
/// Compatibility mapped entrypoint for PortTracker: <c>protoEncodeVarint</c>.
/// </summary>
public static byte[] ProtoEncodeVarint(ulong v)
=> EncodeVarint(v);
}

View File

@@ -74,4 +74,41 @@ public class ProtoWireTests
typ.ShouldBe(2);
size.ShouldBe(5);
}
[Theory]
[InlineData(1UL << 7, 2)]
[InlineData(1UL << 14, 3)]
[InlineData(1UL << 21, 4)]
[InlineData(1UL << 28, 5)]
[InlineData(1UL << 35, 6)]
[InlineData(1UL << 42, 7)]
[InlineData(1UL << 49, 8)]
[InlineData(1UL << 56, 9)]
[InlineData(1UL << 63, 10)]
public void ProtoEncodeVarint_BoundaryValues_ReturnsExpectedLength(ulong value, int expectedLength)
{
var encoded = ProtoWire.ProtoEncodeVarint(value);
encoded.Length.ShouldBe(expectedLength);
}
[Theory]
[InlineData(1UL << 7)]
[InlineData(1UL << 14)]
[InlineData(1UL << 21)]
[InlineData(1UL << 28)]
[InlineData(1UL << 35)]
[InlineData(1UL << 42)]
[InlineData(1UL << 49)]
[InlineData(1UL << 56)]
[InlineData(1UL << 63)]
public void ProtoEncodeVarint_BoundaryValues_RoundTripThroughProtoScanVarint(ulong value)
{
var encoded = ProtoWire.ProtoEncodeVarint(value);
var (decoded, size, err) = ProtoWire.ProtoScanVarint(encoded);
err.ShouldBeNull();
size.ShouldBe(encoded.Length);
decoded.ShouldBe(value);
}
}

Binary file not shown.

View File

@@ -1,6 +1,6 @@
# NATS .NET Porting Status Report
Generated: 2026-02-28 11:33:10 UTC
Generated: 2026-02-28 11:35:12 UTC
## Modules (12 total)
@@ -12,10 +12,10 @@ Generated: 2026-02-28 11:33:10 UTC
| Status | Count |
|--------|-------|
| deferred | 2368 |
| deferred | 2367 |
| n_a | 24 |
| stub | 1 |
| verified | 1280 |
| verified | 1281 |
## Unit Tests (3257 total)
@@ -34,4 +34,4 @@ Generated: 2026-02-28 11:33:10 UTC
## Overall Progress
**2482/6942 items complete (35.8%)**
**2483/6942 items complete (35.8%)**

37
reports/report_c1ae46f.md Normal file
View File

@@ -0,0 +1,37 @@
# NATS .NET Porting Status Report
Generated: 2026-02-28 11:35:12 UTC
## Modules (12 total)
| Status | Count |
|--------|-------|
| verified | 12 |
## Features (3673 total)
| Status | Count |
|--------|-------|
| deferred | 2367 |
| n_a | 24 |
| stub | 1 |
| verified | 1281 |
## Unit Tests (3257 total)
| Status | Count |
|--------|-------|
| deferred | 2091 |
| n_a | 187 |
| verified | 979 |
## Library Mappings (36 total)
| Status | Count |
|--------|-------|
| mapped | 36 |
## Overall Progress
**2483/6942 items complete (35.8%)**