[serialization] How do I unit-test serialization?
Do I just serialize to a memory buffer, then serialize from the same buffer, and then compare the source and destination objects? Should I use a text format (plain and/or XML) with a string-stream source/ sink so I can check by reading? Should I make up a string of a text archive and have my routine try reading it? -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Daryle Walker wrote:
Do I just serialize to a memory buffer, then serialize from the same buffer, and then compare the source and destination objects?
This is one way. You can also try executing the exact same operations on source and destination to ensure you get the same results. This can work (for example) when you have a class hierarchy and there is some meaningful common ground on which to do these tests. Should I
use a text format (plain and/or XML) with a string-stream source/sink so I can check by reading? Should I make up a string of a text archive and have my routine try reading it?
Never use anything except what you will use in production. If you are using binary, then use the binary archives to write to a buffer. -- Sohail Somani http://uint32t.blogspot.com
Sohail Somani wrote:
Never use anything except what you will use in production. If you are using binary, then use the binary archives to write to a buffer.
Well actually, I should say: At least use what you would use in production. Feel free to also test with the other archives :-) -- Sohail Somani http://uint32t.blogspot.com
Sohail Somani wrote:
Daryle Walker wrote:
Do I just serialize to a memory buffer, then serialize from the same buffer, and then compare the source and destination objects?
This is one way. You can also try executing the exact same operations on source and destination to ensure you get the same results. This can work (for example) when you have a class hierarchy and there is some meaningful common ground on which to do these tests.
Should I
use a text format (plain and/or XML) with a string-stream source/sink so I can check by reading? Should I make up a string of a text archive and have my routine try reading it?
Never use anything except what you will use in production. If you are using binary, then use the binary archives to write to a buffer.
Hmm - my view is the opposite - test everything. The serialization library tests are setup so that all archive classes are tested against all serializable types. This has been referred to as the "carpet bombing" approach. Crude? true, Effective? pretty much. Robert Ramey
Robert Ramey wrote:
Sohail Somani wrote:
Daryle Walker wrote: Should I
use a text format (plain and/or XML) with a string-stream source/sink so I can check by reading? Should I make up a string of a text archive and have my routine try reading it? Never use anything except what you will use in production. If you are using binary, then use the binary archives to write to a buffer.
Hmm - my view is the opposite - test everything.
The serialization library tests are setup so that all archive classes are tested against all serializable types. This has been referred to as the "carpet bombing" approach. Crude? true, Effective? pretty much.
Yeah, that totally came out wrong. I meant to say that you should *atleast* test what you are using in production. I don't know that it makes sense for applications to test each archive if they don't use it but if it isn't too much work, why not? TGIF -- Sohail Somani http://uint32t.blogspot.com
Look at how the serialization test suite works. libs/serialization/test/... Robert Ramey Daryle Walker wrote:
Do I just serialize to a memory buffer, then serialize from the same buffer, and then compare the source and destination objects?
that's mostly what we do. Should
I use a text format (plain and/or XML) with a string-stream source/ sink so I can check by reading? Should I make up a string of a text archive and have my routine try reading it?
That would be more work. Robert Ramey
participants (3)
-
Daryle Walker
-
Robert Ramey
-
Sohail Somani