Skip to content

Commit 1eb33a0

Browse files
author
Vyacheslav
committed
feat: test ReducingCapacity head after tail Own
1 parent 89213bf commit 1eb33a0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Src/TestGenerator/GenerateQueuePrimitiveTest.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ in Func<T, string> toStr
290290

291291
QueuePrimitiveReducingCapacity(in values, in builder, in queueNamespace);
292292
QueuePrimitiveReducingCapacityHeadAfterTail(in values, in builder, in queueNamespace, in toStr);
293+
QueuePrimitiveReducingCapacityHeadAfterTailOwn(in values, in builder, in queueNamespace, in toStr);
293294

294295
QueuePrimitiveSize(in values, in builder, in queueNamespace, in toStr);
295296
QueuePrimitiveCapacity(in values, in builder, in queueNamespace, in toStr);
@@ -1369,6 +1370,68 @@ public void ReducingCapacityHeadAfterTailTest()
13691370
");
13701371
}
13711372

1373+
private void QueuePrimitiveReducingCapacityHeadAfterTailOwn<T>(
1374+
in List<T> values,
1375+
in StringBuilder builder,
1376+
in string queueNamespace,
1377+
in Func<T, string> toStr
1378+
) where T : unmanaged
1379+
{
1380+
if (values.Count < 5)
1381+
{
1382+
throw new ArgumentException($"{nameof(values)} Must have minimum 5 values to generate tests");
1383+
}
1384+
1385+
builder.Append($@"
1386+
[Test]
1387+
public void ReducingCapacityHeadAfterTailOwnTest()
1388+
{{
1389+
unsafe
1390+
{{
1391+
var queue = new StackMemoryCollections.{queueNamespace}.QueueOf{typeof(T).Name}();
1392+
");
1393+
for (int i = 0; i < 4; i++)
1394+
{
1395+
builder.Append($@"
1396+
queue.Push({toStr(values[i])});
1397+
");
1398+
}
1399+
builder.Append($@"
1400+
queue.ExpandCapacity(1);
1401+
queue.Push({toStr(values[0])});
1402+
queue.Pop();
1403+
queue.Pop();
1404+
");
1405+
1406+
builder.Append($@"
1407+
queue.Push({toStr(values[values.Count - 1])});
1408+
queue.ReducingCapacity(1);
1409+
");
1410+
for (int i = 2; i < 4; i++)
1411+
{
1412+
builder.Append($@"
1413+
Assert.That(queue.Front(), Is.EqualTo({toStr(values[i])}));
1414+
queue.Pop();
1415+
");
1416+
}
1417+
builder.Append($@"
1418+
Assert.That(queue.Front(), Is.EqualTo({toStr(values[0])}));
1419+
queue.Pop();
1420+
Assert.That(queue.Front(), Is.EqualTo({toStr(values[values.Count - 1])}));
1421+
queue.Pop();
1422+
");
1423+
if(queueNamespace == "Struct")
1424+
{
1425+
builder.Append($@"
1426+
queue.Dispose();
1427+
");
1428+
}
1429+
builder.Append($@"
1430+
}}
1431+
}}
1432+
");
1433+
}
1434+
13721435
private void QueuePrimitiveSize<T>(
13731436
in List<T> values,
13741437
in StringBuilder builder,

0 commit comments

Comments
 (0)