NumericLeafVectorTests: a mixed-record vector, the shape a replicated document has
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
42f746de20
commit
3eb4cb641f
2 changed files with 24 additions and 176 deletions
|
|
@ -1,176 +0,0 @@
|
|||
// Oracle for the numeric leaves, written by the C# reference. Each READ row is a one-slot record [value] fed to a C#
|
||||
// MessagePackSerializer.Deserialize of a class with one int, long, float or double field: ACCEPT <value> (float
|
||||
// values as the double's IEEE bits) or REFUSE. Each WRITE row is the bytes this runtime writes for a value, which
|
||||
// the C# reader read and re-serialized to the same bytes. Produced by a job-only probe of src/ at this commit's
|
||||
// parent range; the C# test project owns no numeric vector.
|
||||
export const referenceReads: readonly (readonly [leaf: string, value: string, outcome: string])[] = [
|
||||
["int32", "05", "ACCEPT 5"],
|
||||
["int32", "ff", "ACCEPT -1"],
|
||||
["int32", "ccc8", "ACCEPT 200"],
|
||||
["int32", "cd0100", "ACCEPT 256"],
|
||||
["int32", "ceb2d05e00", "REFUSE"],
|
||||
["int32", "d0ce", "ACCEPT -50"],
|
||||
["int32", "d18000", "ACCEPT -32768"],
|
||||
["int32", "d280000000", "ACCEPT -2147483648"],
|
||||
["int32", "d38000000000000000", "REFUSE"],
|
||||
["int32", "cf0020000000000001", "REFUSE"],
|
||||
["int32", "cfffffffffffffffff", "REFUSE"],
|
||||
["int32", "cf8000000000000000", "REFUSE"],
|
||||
["int32", "d30020000000000001", "REFUSE"],
|
||||
["int32", "d3fffffffffffffff0", "ACCEPT -16"],
|
||||
["int32", "ca3fc00000", "REFUSE"],
|
||||
["int32", "cb3ff8000000000000", "REFUSE"],
|
||||
["int32", "cb401c000000000000", "REFUSE"],
|
||||
["int32", "cb7ff8000000000000", "REFUSE"],
|
||||
["int32", "ca7f800000", "REFUSE"],
|
||||
["int32", "cb7e37e43c8800759c", "REFUSE"],
|
||||
["int32", "cb47efffffe0000000", "REFUSE"],
|
||||
["int32", "cb3fb999999999999a", "REFUSE"],
|
||||
["int32", "ca3dcccccd", "REFUSE"],
|
||||
["int32", "cb8000000000000000", "REFUSE"],
|
||||
["int32", "c0", "REFUSE"],
|
||||
["int32", "c3", "REFUSE"],
|
||||
["int32", "a161", "REFUSE"],
|
||||
["int32", "c40100", "REFUSE"],
|
||||
["int32", "90", "REFUSE"],
|
||||
["int32", "80", "REFUSE"],
|
||||
["int64", "05", "ACCEPT 5"],
|
||||
["int64", "ff", "ACCEPT -1"],
|
||||
["int64", "ccc8", "ACCEPT 200"],
|
||||
["int64", "cd0100", "ACCEPT 256"],
|
||||
["int64", "ceb2d05e00", "ACCEPT 3000000000"],
|
||||
["int64", "d0ce", "ACCEPT -50"],
|
||||
["int64", "d18000", "ACCEPT -32768"],
|
||||
["int64", "d280000000", "ACCEPT -2147483648"],
|
||||
["int64", "d38000000000000000", "ACCEPT -9223372036854775808"],
|
||||
["int64", "cf0020000000000001", "ACCEPT 9007199254740993"],
|
||||
["int64", "cfffffffffffffffff", "REFUSE"],
|
||||
["int64", "cf8000000000000000", "REFUSE"],
|
||||
["int64", "d30020000000000001", "ACCEPT 9007199254740993"],
|
||||
["int64", "d3fffffffffffffff0", "ACCEPT -16"],
|
||||
["int64", "ca3fc00000", "REFUSE"],
|
||||
["int64", "cb3ff8000000000000", "REFUSE"],
|
||||
["int64", "cb401c000000000000", "REFUSE"],
|
||||
["int64", "cb7ff8000000000000", "REFUSE"],
|
||||
["int64", "ca7f800000", "REFUSE"],
|
||||
["int64", "cb7e37e43c8800759c", "REFUSE"],
|
||||
["int64", "cb47efffffe0000000", "REFUSE"],
|
||||
["int64", "cb3fb999999999999a", "REFUSE"],
|
||||
["int64", "ca3dcccccd", "REFUSE"],
|
||||
["int64", "cb8000000000000000", "REFUSE"],
|
||||
["int64", "c0", "REFUSE"],
|
||||
["int64", "c3", "REFUSE"],
|
||||
["int64", "a161", "REFUSE"],
|
||||
["int64", "c40100", "REFUSE"],
|
||||
["int64", "90", "REFUSE"],
|
||||
["int64", "80", "REFUSE"],
|
||||
["float32", "05", "ACCEPT 4014000000000000"],
|
||||
["float32", "ff", "ACCEPT bff0000000000000"],
|
||||
["float32", "ccc8", "ACCEPT 4069000000000000"],
|
||||
["float32", "cd0100", "ACCEPT 4070000000000000"],
|
||||
["float32", "ceb2d05e00", "ACCEPT 41e65a0bc0000000"],
|
||||
["float32", "d0ce", "ACCEPT c049000000000000"],
|
||||
["float32", "d18000", "ACCEPT c0e0000000000000"],
|
||||
["float32", "d280000000", "ACCEPT c1e0000000000000"],
|
||||
["float32", "d38000000000000000", "ACCEPT c3e0000000000000"],
|
||||
["float32", "cf0020000000000001", "ACCEPT 4340000000000000"],
|
||||
["float32", "cfffffffffffffffff", "ACCEPT 43f0000000000000"],
|
||||
["float32", "cf8000000000000000", "ACCEPT 43e0000000000000"],
|
||||
["float32", "d30020000000000001", "ACCEPT 4340000000000000"],
|
||||
["float32", "d3fffffffffffffff0", "ACCEPT c030000000000000"],
|
||||
["float32", "ca3fc00000", "ACCEPT 3ff8000000000000"],
|
||||
["float32", "cb3ff8000000000000", "ACCEPT 3ff8000000000000"],
|
||||
["float32", "cb401c000000000000", "ACCEPT 401c000000000000"],
|
||||
["float32", "cb7ff8000000000000", "ACCEPT NaN"],
|
||||
["float32", "ca7f800000", "ACCEPT 7ff0000000000000"],
|
||||
["float32", "cb7e37e43c8800759c", "ACCEPT 7ff0000000000000"],
|
||||
["float32", "cb47efffffe0000000", "ACCEPT 47efffffe0000000"],
|
||||
["float32", "cb3fb999999999999a", "ACCEPT 3fb99999a0000000"],
|
||||
["float32", "ca3dcccccd", "ACCEPT 3fb99999a0000000"],
|
||||
["float32", "cb8000000000000000", "ACCEPT 8000000000000000"],
|
||||
["float32", "c0", "REFUSE"],
|
||||
["float32", "c3", "REFUSE"],
|
||||
["float32", "a161", "REFUSE"],
|
||||
["float32", "c40100", "REFUSE"],
|
||||
["float32", "90", "REFUSE"],
|
||||
["float32", "80", "REFUSE"],
|
||||
["float64", "05", "ACCEPT 4014000000000000"],
|
||||
["float64", "ff", "ACCEPT bff0000000000000"],
|
||||
["float64", "ccc8", "ACCEPT 4069000000000000"],
|
||||
["float64", "cd0100", "ACCEPT 4070000000000000"],
|
||||
["float64", "ceb2d05e00", "ACCEPT 41e65a0bc0000000"],
|
||||
["float64", "d0ce", "ACCEPT c049000000000000"],
|
||||
["float64", "d18000", "ACCEPT c0e0000000000000"],
|
||||
["float64", "d280000000", "ACCEPT c1e0000000000000"],
|
||||
["float64", "d38000000000000000", "ACCEPT c3e0000000000000"],
|
||||
["float64", "cf0020000000000001", "ACCEPT 4340000000000000"],
|
||||
["float64", "cfffffffffffffffff", "ACCEPT 43f0000000000000"],
|
||||
["float64", "cf8000000000000000", "ACCEPT 43e0000000000000"],
|
||||
["float64", "d30020000000000001", "ACCEPT 4340000000000000"],
|
||||
["float64", "d3fffffffffffffff0", "ACCEPT c030000000000000"],
|
||||
["float64", "ca3fc00000", "ACCEPT 3ff8000000000000"],
|
||||
["float64", "cb3ff8000000000000", "ACCEPT 3ff8000000000000"],
|
||||
["float64", "cb401c000000000000", "ACCEPT 401c000000000000"],
|
||||
["float64", "cb7ff8000000000000", "ACCEPT NaN"],
|
||||
["float64", "ca7f800000", "ACCEPT 7ff0000000000000"],
|
||||
["float64", "cb7e37e43c8800759c", "ACCEPT 7e37e43c8800759c"],
|
||||
["float64", "cb47efffffe0000000", "ACCEPT 47efffffe0000000"],
|
||||
["float64", "cb3fb999999999999a", "ACCEPT 3fb999999999999a"],
|
||||
["float64", "ca3dcccccd", "ACCEPT 3fb99999a0000000"],
|
||||
["float64", "cb8000000000000000", "ACCEPT 8000000000000000"],
|
||||
["float64", "c0", "REFUSE"],
|
||||
["float64", "c3", "REFUSE"],
|
||||
["float64", "a161", "REFUSE"],
|
||||
["float64", "c40100", "REFUSE"],
|
||||
["float64", "90", "REFUSE"],
|
||||
["float64", "80", "REFUSE"],
|
||||
];
|
||||
|
||||
export const referenceWrites: readonly (readonly [leaf: string, value: string, hex: string])[] = [
|
||||
["int32", "0", "9100"],
|
||||
["int32", "1", "9101"],
|
||||
["int32", "127", "917f"],
|
||||
["int32", "128", "91cc80"],
|
||||
["int32", "255", "91ccff"],
|
||||
["int32", "256", "91cd0100"],
|
||||
["int32", "65535", "91cdffff"],
|
||||
["int32", "65536", "91ce00010000"],
|
||||
["int32", "-1", "91ff"],
|
||||
["int32", "-32", "91e0"],
|
||||
["int32", "-33", "91d0df"],
|
||||
["int32", "-128", "91d080"],
|
||||
["int32", "-129", "91d1ff7f"],
|
||||
["int32", "-32768", "91d18000"],
|
||||
["int32", "-32769", "91d2ffff7fff"],
|
||||
["int32", "2147483647", "91ce7fffffff"],
|
||||
["int32", "-2147483648", "91d280000000"],
|
||||
["int64", "0", "9100"],
|
||||
["int64", "127", "917f"],
|
||||
["int64", "128", "91cc80"],
|
||||
["int64", "4294967295", "91ceffffffff"],
|
||||
["int64", "4294967296", "91cf0000000100000000"],
|
||||
["int64", "9007199254740991", "91cf001fffffffffffff"],
|
||||
["int64", "-9007199254740991", "91d3ffe0000000000001"],
|
||||
["int64", "-2147483649", "91d3ffffffff7fffffff"],
|
||||
["int64", "9007199254740994n", "91cf0020000000000002"],
|
||||
["int64", "9223372036854775807n", "91cf7fffffffffffffff"],
|
||||
["int64", "-9223372036854775808n", "91d38000000000000000"],
|
||||
["int64", "9007199254740993n", "91cf0020000000000001"],
|
||||
["int64", "-9007199254740993n", "91d3ffdfffffffffffff"],
|
||||
["float32", "1.5", "91ca3fc00000"],
|
||||
["float32", "0.1", "91ca3dcccccd"],
|
||||
["float32", "0", "91ca00000000"],
|
||||
["float32", "-0", "91ca80000000"],
|
||||
["float32", "3", "91ca40400000"],
|
||||
["float32", "1e+30", "91ca7149f2ca"],
|
||||
["float32", "Infinity", "91ca7f800000"],
|
||||
["float32", "NaN", "91ca7fc00000"],
|
||||
["float64", "1.5", "91cb3ff8000000000000"],
|
||||
["float64", "0.1", "91cb3fb999999999999a"],
|
||||
["float64", "0", "91cb0000000000000000"],
|
||||
["float64", "-0", "91cb8000000000000000"],
|
||||
["float64", "3", "91cb4008000000000000"],
|
||||
["float64", "1e+300", "91cb7e37e43c8800759c"],
|
||||
["float64", "Infinity", "91cb7ff0000000000000"],
|
||||
["float64", "NaN", "91cb7ff8000000000000"],
|
||||
];
|
||||
|
|
@ -24,6 +24,17 @@ namespace GameCult.Caching.Tests
|
|||
[MessagePackObject] public sealed class Float32Slot { [Key(0)] public float V; }
|
||||
[MessagePackObject] public sealed class Float64Slot { [Key(0)] public double V; }
|
||||
|
||||
// A record of every leaf kind, the shape a replicated document has.
|
||||
[MessagePackObject]
|
||||
public sealed class Mixed
|
||||
{
|
||||
[Key(0)] public string Id = string.Empty;
|
||||
[Key(1)] public int I;
|
||||
[Key(2)] public long L;
|
||||
[Key(3)] public float F;
|
||||
[Key(4)] public double D;
|
||||
}
|
||||
|
||||
private static bool Writing => Environment.GetEnvironmentVariable(WriteVariable) == "1";
|
||||
|
||||
private static readonly MessagePackSerializerOptions Options = CultDocumentMessagePackSerialization.OptionsFor(typeof(NumericLeafVectorTests).Assembly);
|
||||
|
|
@ -160,6 +171,9 @@ namespace GameCult.Caching.Tests
|
|||
return buffer.WrittenSpan.ToArray();
|
||||
}
|
||||
|
||||
// mixed-record.msgpack: the reference's bytes for Mixed { "n1", 7, 8, 1.5f, 2.5 }, which other runtimes must write identically.
|
||||
private static byte[] MixedRecord() => MessagePackSerializer.Serialize(new Mixed { Id = "n1", I = 7, L = 8, F = 1.5f, D = 2.5 }, Options);
|
||||
|
||||
// ---- tests ----
|
||||
|
||||
[Test]
|
||||
|
|
@ -168,6 +182,16 @@ namespace GameCult.Caching.Tests
|
|||
[Test]
|
||||
public void WritesVectorMatches() => Check("writes.msgpack", WritesVector());
|
||||
|
||||
[Test]
|
||||
public void MixedRecordVectorMatches()
|
||||
{
|
||||
var written = MixedRecord();
|
||||
Assert.That(Convert.ToHexString(written), Is.EqualTo("95A26E310708CA3FC00000CB4004000000000000"));
|
||||
Check("mixed-record.msgpack", written);
|
||||
var read = MessagePackSerializer.Deserialize<Mixed>(written, Options);
|
||||
Assert.That((read.Id, read.I, read.L, read.F, read.D), Is.EqualTo(("n1", 7, 8L, 1.5f, 2.5)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadsCoverEveryLeafAndBothOutcomes()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue