Skip to content

Commit 621db34

Browse files
committed
Add basic TestQWord suite
1 parent a55b75e commit 621db34

File tree

1 file changed

+49
-12
lines changed

1 file changed

+49
-12
lines changed

Classes/FCryptoTestMutator.uc

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,24 @@ simulated event PreBeginPlay()
199199
{
200200
Utils = new (self) class'FCryptoUtils';
201201

202-
TestDelegatesToRun.Length = 7;
203-
TestDelegatesToRun[0].TestDelegate = TestMemory;
204-
TestDelegatesToRun[0].TestName = NameOf(TestMemory);
205-
TestDelegatesToRun[1].TestDelegate = TestOperations;
206-
TestDelegatesToRun[1].TestName = NameOf(TestOperations);
207-
TestDelegatesToRun[2].TestDelegate = TestMath;
208-
TestDelegatesToRun[2].TestName = NameOf(TestMath);
209-
TestDelegatesToRun[3].TestDelegate = TestAesCt;
210-
TestDelegatesToRun[3].TestName = NameOf(TestAesCt);
211-
212-
TestDelegatesToRun[4].TestDelegate = TestSpeed;
213-
TestDelegatesToRun[4].TestName = NameOf(TestSpeed);
202+
TestDelegatesToRun.Length = 8;
203+
TestDelegatesToRun[0].TestDelegate = TestQWord;
204+
TestDelegatesToRun[0].TestName = NameOf(TestQWord);
205+
TestDelegatesToRun[1].TestDelegate = TestMemory;
206+
TestDelegatesToRun[1].TestName = NameOf(TestMemory);
207+
TestDelegatesToRun[2].TestDelegate = TestOperations;
208+
TestDelegatesToRun[2].TestName = NameOf(TestOperations);
209+
TestDelegatesToRun[3].TestDelegate = TestMath;
210+
TestDelegatesToRun[3].TestName = NameOf(TestMath);
211+
TestDelegatesToRun[4].TestDelegate = TestAesCt;
212+
TestDelegatesToRun[4].TestName = NameOf(TestAesCt);
213+
214214
TestDelegatesToRun[5].TestDelegate = TestSpeed;
215215
TestDelegatesToRun[5].TestName = NameOf(TestSpeed);
216216
TestDelegatesToRun[6].TestDelegate = TestSpeed;
217217
TestDelegatesToRun[6].TestName = NameOf(TestSpeed);
218+
TestDelegatesToRun[7].TestDelegate = TestSpeed;
219+
TestDelegatesToRun[7].TestName = NameOf(TestSpeed);
218220

219221
super.PreBeginPlay();
220222
}
@@ -789,6 +791,41 @@ private final simulated function IntToBytes(
789791
Bytes[3] = (I ) & 0xFF;
790792
}
791793

794+
// TODO: mirror all the tests from Python QWord tests here!
795+
// And perhaps add more UScript specific checks?
796+
private final simulated function int TestQWord()
797+
{
798+
local int TestFailures;
799+
local FCQWORD16 QW1;
800+
local array<byte> QW1Bytes;
801+
local array<byte> QW1BytesCorrect;
802+
803+
TestFailures = 0;
804+
805+
QW1.A = 0x0000; QW1.B = 0x1010; QW1.C = 0xffff; QW1.D = 0xffff;
806+
class'FCryptoQWORD'.static.FCQWORD16_AddInt(QW1, 1000);
807+
// TODO: need a macro or static function for convenience!
808+
QW1Bytes[0] = (QW1.A >>> 8) & 0xff;
809+
QW1Bytes[1] = (QW1.A ) & 0xff;
810+
QW1Bytes[2] = (QW1.B >>> 8) & 0xff;
811+
QW1Bytes[3] = (QW1.B ) & 0xff;
812+
QW1Bytes[4] = (QW1.C >>> 8) & 0xff;
813+
QW1Bytes[5] = (QW1.C ) & 0xff;
814+
QW1Bytes[6] = (QW1.D >>> 8) & 0xff;
815+
QW1Bytes[7] = (QW1.D ) & 0xff;
816+
QW1BytesCorrect[0] = 0x00;
817+
QW1BytesCorrect[1] = 0x00;
818+
QW1BytesCorrect[2] = 0x10;
819+
QW1BytesCorrect[3] = 0x11;
820+
QW1BytesCorrect[4] = 0x00;
821+
QW1BytesCorrect[5] = 0x00;
822+
QW1BytesCorrect[6] = 0x03;
823+
QW1BytesCorrect[7] = 0xe7;
824+
TestFailures += BytesShouldBeEqual(QW1Bytes, QW1BytesCorrect, "QW1Bytes");
825+
826+
return TestFailures;
827+
}
828+
792829
private final simulated function int TestMemory()
793830
{
794831
local int TestFailures;

0 commit comments

Comments
 (0)