mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 23:51:49 +02:00
Fix for sporadic test failure due to hash ordering.
This commit is contained in:
parent
eea45e98d7
commit
26159a05d9
1 changed files with 20 additions and 14 deletions
|
@ -83,7 +83,7 @@ static TestSharedObjectA::TestFlags getRandomTestFlags() {
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QScriptValue createRandomScriptValue(bool complex = false) {
|
static QScriptValue createRandomScriptValue(bool complex = false, bool ensureHashOrder = false) {
|
||||||
scriptObjectsCreated++;
|
scriptObjectsCreated++;
|
||||||
switch (randIntInRange(0, complex ? 5 : 3)) {
|
switch (randIntInRange(0, complex ? 5 : 3)) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -108,31 +108,37 @@ static QScriptValue createRandomScriptValue(bool complex = false) {
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
QScriptValue value = ScriptCache::getInstance()->getEngine()->newObject();
|
QScriptValue value = ScriptCache::getInstance()->getEngine()->newObject();
|
||||||
if (randomBoolean()) {
|
if (ensureHashOrder) {
|
||||||
|
// we can't depend on the iteration order, so if we need it to be the same (as when comparing bytes), we
|
||||||
|
// can only have one property
|
||||||
value.setProperty("foo", createRandomScriptValue());
|
value.setProperty("foo", createRandomScriptValue());
|
||||||
}
|
} else {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
value.setProperty("bar", createRandomScriptValue());
|
value.setProperty("foo", createRandomScriptValue());
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
value.setProperty("baz", createRandomScriptValue());
|
value.setProperty("bar", createRandomScriptValue());
|
||||||
}
|
}
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
value.setProperty("bong", createRandomScriptValue());
|
value.setProperty("baz", createRandomScriptValue());
|
||||||
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
value.setProperty("bong", createRandomScriptValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestMessageC createRandomMessageC() {
|
static TestMessageC createRandomMessageC(bool ensureHashOrder = false) {
|
||||||
TestMessageC message;
|
TestMessageC message;
|
||||||
message.foo = randomBoolean();
|
message.foo = randomBoolean();
|
||||||
message.bar = rand();
|
message.bar = rand();
|
||||||
message.baz = randFloat();
|
message.baz = randFloat();
|
||||||
message.bong.foo = createRandomBytes();
|
message.bong.foo = createRandomBytes();
|
||||||
message.bong.baz = getRandomTestEnum();
|
message.bong.baz = getRandomTestEnum();
|
||||||
message.bizzle = createRandomScriptValue(true);
|
message.bizzle = createRandomScriptValue(true, ensureHashOrder);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +152,7 @@ static bool testSerialization(Bitstream::MetadataType metadataType) {
|
||||||
SharedObjectPointer testObjectWrittenB = new TestSharedObjectB(randFloat(), createRandomBytes(),
|
SharedObjectPointer testObjectWrittenB = new TestSharedObjectB(randFloat(), createRandomBytes(),
|
||||||
TestSharedObjectB::THIRD_TEST_ENUM, TestSharedObjectB::SECOND_TEST_FLAG);
|
TestSharedObjectB::THIRD_TEST_ENUM, TestSharedObjectB::SECOND_TEST_FLAG);
|
||||||
out << testObjectWrittenB;
|
out << testObjectWrittenB;
|
||||||
TestMessageC messageWritten = createRandomMessageC();
|
TestMessageC messageWritten = createRandomMessageC(true);
|
||||||
out << QVariant::fromValue(messageWritten);
|
out << QVariant::fromValue(messageWritten);
|
||||||
QByteArray endWritten = "end";
|
QByteArray endWritten = "end";
|
||||||
out << endWritten;
|
out << endWritten;
|
||||||
|
|
Loading…
Reference in a new issue