示例#1
0
TEST(DictionarySerializationTest, DifferentPropertiesNoReference) {
	AmfDictionary d(false, false);
	AmfDictionary d2(true, false);
	AmfDictionary d3(true, true);

	d.insert(AmfBool(true), AmfUndefined());
	d2.insert(AmfBool(true), AmfUndefined());
	d3.insert(AmfBool(true), AmfUndefined());

	SerializationContext ctx;
	isEqual({ 0x11, 0x03, 0x00, 0x03, 0x00 }, d.serialize(ctx));
	isEqual({
		0x11, 0x03, 0x00,
		0x06, 0x09, 0x74, 0x72, 0x75, 0x65,
		0x00
	}, d2.serialize(ctx));
	isEqual({
		0x11, 0x03, 0x01,
		0x06, 0x00,
		0x00
	}, d3.serialize(ctx));
	isEqual({ 0x11, 0x00 }, d.serialize(ctx));
	isEqual({ 0x11, 0x02 }, d2.serialize(ctx));
	isEqual({ 0x11, 0x04 }, d3.serialize(ctx));
}
示例#2
0
TEST(DictionarySerializationTest, UndefinedKeys) {
	AmfDictionary d(false, false);
	d.insert(AmfUndefined(), AmfUndefined());
	isEqual(v8 {
		0x11, 0x03, 0x00, 0x00, 0x00
	}, d);

	d.asString = true;

	isEqual(v8 {
		0x11, 0x03, 0x00,
		0x06, 0x13, 0x75, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64,
		0x00
	}, d);
}
示例#3
0
TEST(DictionaryEquality, NestedDictionary) {
	AmfDictionary d0(true), d1(true), i(false);
	i.insert(AmfNull(), AmfUndefined());
	d0.insert(i, i);
	d1.insert(i, i);
	EXPECT_EQ(d0, d1);
}
示例#4
0
TEST(DictionaryDeserialization, StringKeys) {
	AmfDictionary d(false, false);
	d.insert(AmfString("foo"), AmfUndefined());
	v8 data {
		0x11, 0x03, 0x00,
		0x06, 0x07, 0x66, 0x6f, 0x6f,
		0x00
	};
	deserialize(d, data, 0);
}
示例#5
0
TEST(DictionaryEquality, SimpleValues) {
	AmfDictionary d0(true), d1(true), d2(false);
	d0.insert(AmfInteger(0), AmfString("foo"));
	d1.insert(AmfInteger(0), AmfString("foo"));
	d2.insert(AmfInteger(0), AmfString("foo"));
	EXPECT_EQ(d0, d1);
	EXPECT_NE(d0, d2);

	d0.insert(AmfString("qux"), AmfByteArray(v8 { 0x00 }));
	EXPECT_NE(d0, d1);
	d1.insert(AmfString("qux"), AmfByteArray(v8 { 0x00 }));
	EXPECT_EQ(d0, d1);

	d0.insert(AmfNull(), AmfUndefined());
	d1.insert(AmfUndefined(), AmfNull());
	EXPECT_NE(d0, d1);

	d0.insert(AmfUndefined(), AmfNull());
	d1.insert(AmfNull(), AmfUndefined());
	EXPECT_EQ(d0, d1);
}
示例#6
0
TEST(DictionaryDeserialization, SelfReference2) {
	v8 data {
		0x11,
		0x05,
		0x00,
			0x00,
			0x11, 0x00,
			0x11, 0x00,
			0x00
	};

	DeserializationContext ctx;
	auto it = data.cbegin();
	AmfItemPtr ptr = AmfDictionary::deserializePtr(it, data.cend(), ctx);
	AmfDictionary & d = ptr.as<AmfDictionary>();

	const AmfItemPtr& inner = d.values.at(AmfItemPtr(AmfUndefined()));
	EXPECT_EQ(ptr.get(), inner.get());

	// TODO: segfault due to AmfDictionaryHash
	// const AmfItemPtr& inner2 = d.values.at(ptr);
	// EXPECT_EQ(AmfUndefined(), inner2.as<AmfUndefined>());
}
示例#7
0
TEST(DeserializerTest, Undefined) {
	deserializesTo(AmfUndefined(), { 0x00 });
	deserializesTo(AmfUndefined(), { 0x00, 0x00 }, 1);
}
示例#8
0
TEST(UndefinedSerializationTest, SimpleValue) {
	ASSERT_EQ(v8 { 0x00 }, AmfUndefined().serialize());
}
示例#9
0
TEST(UndefinedDeserialization, SimpleValue) {
	deserialize(AmfUndefined(), v8 { 0x00, }, 0);
	deserialize(AmfUndefined(), v8 { 0x00, 0x00 }, 1);
	deserialize(AmfUndefined(), v8 { 0x00, 0x00, 0x00, 0x00 }, 3);
}
示例#10
0
TEST(UndefinedSerialization, SimpleValue) {
	isEqual(v8 { 0x00 }, AmfUndefined());
}