Skip to content

Commit b545998

Browse files
author
Vyacheslav
committed
feat: test ReducingCapacity head before tail Own
1 parent b83da92 commit b545998

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

Src/TestGenerator/GenerateQueuePrimitiveTest.cs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ in Func<T, string> toStr
292292
QueuePrimitiveReducingCapacityHeadAfterTail(in values, in builder, in queueNamespace, in toStr);
293293
QueuePrimitiveReducingCapacityHeadAfterTailOwn(in values, in builder, in queueNamespace, in toStr);
294294
QueuePrimitiveReducingCapacityHeadBeforeTail(in values, in builder, in queueNamespace, in toStr);
295+
QueuePrimitiveReducingCapacityHeadBeforeTailOwn(in values, in builder, in queueNamespace, in toStr);
295296

296297
QueuePrimitiveSize(in values, in builder, in queueNamespace, in toStr);
297298
QueuePrimitiveCapacity(in values, in builder, in queueNamespace, in toStr);
@@ -309,7 +310,6 @@ in Func<T, string> toStr
309310
QueuePrimitiveEnd(in builder);
310311

311312
context.AddSource($"QueueOf{typeof(T).Name}{queueNamespace}Fixture.g.cs", builder.ToString());
312-
//File.WriteAllText($"E:\\Work\\OutTrash\\QueueOf{typeof(T).Name}{queueNamespace}Fixture.g.cs", builder.ToString());
313313
}
314314

315315
private void QueuePrimitiveStart<T>(
@@ -1485,6 +1485,59 @@ public void ReducingCapacityHeadBeforeTailTest()
14851485
");
14861486
}
14871487

1488+
private void QueuePrimitiveReducingCapacityHeadBeforeTailOwn<T>(
1489+
in List<T> values,
1490+
in StringBuilder builder,
1491+
in string queueNamespace,
1492+
in Func<T, string> toStr
1493+
) where T : unmanaged
1494+
{
1495+
if (values.Count < 5)
1496+
{
1497+
throw new ArgumentException($"{nameof(values)} Must have minimum 5 values to generate tests");
1498+
}
1499+
1500+
builder.Append($@"
1501+
[Test]
1502+
public void ReducingCapacityHeadBeforeTailOwnTest()
1503+
{{
1504+
unsafe
1505+
{{
1506+
var queue = new StackMemoryCollections.{queueNamespace}.QueueOf{typeof(T).Name}();
1507+
");
1508+
for (int i = 0; i < 3; i++)
1509+
{
1510+
builder.Append($@"
1511+
queue.Push({toStr(values[i])});
1512+
");
1513+
}
1514+
1515+
builder.Append($@"
1516+
queue.Pop();
1517+
queue.ReducingCapacity(2);
1518+
");
1519+
for (int i = 1; i < 3; i++)
1520+
{
1521+
builder.Append($@"
1522+
Assert.That(queue.Front(), Is.EqualTo({toStr(values[i])}));
1523+
queue.Pop();
1524+
");
1525+
}
1526+
builder.Append($@"
1527+
Assert.That(queue.Size, Is.EqualTo((nuint)0));
1528+
");
1529+
if (queueNamespace == "Struct")
1530+
{
1531+
builder.Append($@"
1532+
queue.Dispose();
1533+
");
1534+
}
1535+
builder.Append($@"
1536+
}}
1537+
}}
1538+
");
1539+
}
1540+
14881541
private void QueuePrimitiveSize<T>(
14891542
in List<T> values,
14901543
in StringBuilder builder,

0 commit comments

Comments
 (0)