I hope this is correct, but having lots of tiny SAM examples could help me more quickly and confidently understand the SAM spec so I can generate better test cases.
I am about to create test cases with paired end reads with gaps, and before doing so I hope I might find more tiny SAM examples and/or better resources given my background.
It's unfortunate that the sam spec is always named SAMv1.pdf, when the actual specification changes rapidly.
(edited - I'm not really sure what I was trying to say).
Anyway, yes, using a random read generator and aligning small numbers of reads to a reference is a good way to explore the sam format, considering that the optional tags are poorly documented.
After reading the comments and other answers, this is what I ended up doing, so I figured I'd share the explicit steps I took in case it helps someone else.
I would suggest you to go through the source code of existing tools that process the sam/bam files. For example, there is a feature in Picard tool (http://broadinstitute.github.io/picard/) to validate the SAM/BAM format. You can go through the code to get an idea of what information it looks for to validate the file.
Please note however that I am specifically looking for small SAM files that are easily manually understandable for testing / unit testing, not real/large BAM files. (Real/large BAM files seem abundantly available unlike small SAM test files accompanied by explanations of meaning).
It's unfortunate that the sam spec is always named SAMv1.pdf, when the actual specification changes rapidly.
(edited - I'm not really sure what I was trying to say).
Anyway, yes, using a random read generator and aligning small numbers of reads to a reference is a good way to explore the sam format, considering that the optional tags are poorly documented.
I'm currently experimenting with wgsim while following this helpful tutorial: http://biobits.org/samtools_primer.html
This online utility to decode/encode a SAM flag to/from plain English is helpful: http://broadinstitute.github.io/picard/explain-flags.html
Perhaps a read generator is the most pragmatic way of generating small correct SAM files for testing purposes.