Commit 811f733f authored by imalone's avatar imalone

Add tests for oggz_comment_generate, including reference packets as header. ...

Add tests for oggz_comment_generate, including reference packets as header.  Possibly too many, cull if not needed.

Putting the packets in a header is not ideal, but it allows the use of fixed size arrays (unlike a separate source file, less prone to errors than using structs for this) and avoids cluttering the source.  I doubt the new comment-test.h is subject to copyright (data listing), but as much of the license from comment-test.c should be added if necessary.


git-svn-id: http://svn.annodex.net/liboggz/trunk@2593 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent b1f2f2f5
......@@ -40,6 +40,8 @@
#include "oggz_tests.h"
#include "comment-test.h"
#define ARTIST1 "Trout Junkies"
#define ARTIST2 "DJ Fugu"
#define COPYRIGHT "Copyright (C) 2004. Some Rights Reserved."
......@@ -53,9 +55,12 @@ main (int argc, char * argv[])
{
const OggzComment * comment, * comment2;
OggzComment mycomment;
ogg_packet *op;
const char * vendor;
int err;
long serialno = 7;
long invalidserialno = 8;
#if OGGZ_CONFIG_WRITE
INFO ("Initializing OGGZ for comments (writer)");
......@@ -184,6 +189,85 @@ main (int argc, char * argv[])
if (comment != NULL)
FAIL ("Removed comment incorrectly retrieved");
INFO ("+ Attempting to set vendor string");
err = oggz_comment_set_vendor (oggz, serialno, vendor_flac );
if (err) FAIL ("Operation failed");
INFO ("+ Retrieving vendor string");
vendor = oggz_comment_get_vendor (oggz, serialno);
if (!vendor || strcmp(vendor, vendor_flac))
FAIL ("+ Operation failed");
INFO("+ Generating FLAC comment packet");
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_FLAC, 0);
if (!op) FAIL ("Operation failed");
INFO("+ Checking FLAC comment packet");
if (op->bytes != sizeof comment_packet_flac ||
memcmp (op->packet, comment_packet_flac, op->bytes) )
FAIL ("Incorrect packet");
oggz_packet_destroy(op);
INFO("+ Generating OggPCM comment packet");
/* OggPCM and Speex comment packets are identical. */
err = oggz_comment_set_vendor (oggz, serialno, vendor_speex );
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_PCM, 0);
if (err || !op) FAIL ("Operation failed");
INFO("+ Checking OggPCM comment packet");
if (op->bytes != sizeof comment_packet_speex ||
memcmp (op->packet, comment_packet_speex, op->bytes) )
FAIL ("Incorrect packet");
oggz_packet_destroy(op);
INFO("+ Generating Speex comment packet");
err = oggz_comment_set_vendor (oggz, serialno, vendor_speex );
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_SPEEX, 0);
if (err || !op) FAIL ("Operation failed");
INFO("+ Checking Speex comment packet");
if (op->bytes != sizeof comment_packet_speex ||
memcmp (op->packet, comment_packet_speex, op->bytes) )
FAIL ("Incorrect packet");
oggz_packet_destroy(op);
INFO("+ Generating Theora comment packet");
err = oggz_comment_set_vendor (oggz, serialno, vendor_theora );
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_THEORA, 0);
if (err || !op) FAIL ("Operation failed");
INFO("+ Checking Theora comment packet");
if (op->bytes != sizeof comment_packet_theora ||
memcmp (op->packet, comment_packet_theora, op->bytes) )
FAIL ("Incorrect packet");
oggz_packet_destroy(op);
INFO("+ Generating Vorbis comment packet");
err = oggz_comment_set_vendor (oggz, serialno, vendor_vorbis );
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_VORBIS, 0);
if (err || !op) FAIL ("Operation failed");
INFO("+ Checking Vorbis comment packet");
if (op->bytes != sizeof comment_packet_vorbis ||
memcmp (op->packet, comment_packet_vorbis, op->bytes) )
FAIL ("Incorrect packet");
oggz_packet_destroy(op);
INFO("+ Testing comment generate for unsupported type");
op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_UNKNOWN, 0);
if(op) FAIL ("Returned comment packet for unsupported type");
oggz_packet_destroy(op);
INFO("+ Testing comment generate for invalid serialno");
op = oggz_comment_generate (oggz, invalidserialno, OGGZ_CONTENT_VORBIS, 0);
if(op) FAIL ("Returned comment packet for invalid serialno");
oggz_packet_destroy(op);
INFO ("Closing OGGZ (writer)");
oggz_close (oggz);
#endif /* OGGZ_CONFIG_WRITE */
......
/* - Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Reference packets for the comment generator, taken from files produced
by: flac, speexenc, libtheora API and vorbiscomment. Comments are:
ARTIST=Trout Junkies
ARTIST=DJ Fugu
*/
char *vendor_flac = "reference libFLAC 1.1.2 20050205";
unsigned char comment_packet_flac[86] = {0x04,0x00,0x00,0x52,0x20,0x00,0x00,0x00,0x72,0x65,0x66,0x65,0x72,0x65,0x6e,0x63,0x65,0x20,0x6c,0x69,0x62,0x46,0x4c,0x41,0x43,0x20,0x31,0x2e,0x31,0x2e,0x32,0x20,0x32,0x30,0x30,0x35,0x30,0x32,0x30,0x35,0x02,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x54,0x72,0x6f,0x75,0x74,0x20,0x4a,0x75,0x6e,0x6b,0x69,0x65,0x73,0x0e,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x44,0x4a,0x20,0x46,0x75,0x67,0x75};
char *vendor_speex = "Encoded with Speex 1.2beta1";
unsigned char comment_packet_speex[77] = {0x1b,0x00,0x00,0x00,0x45,0x6e,0x63,0x6f,0x64,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x53,0x70,0x65,0x65,0x78,0x20,0x31,0x2e,0x32,0x62,0x65,0x74,0x61,0x31,0x02,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x54,0x72,0x6f,0x75,0x74,0x20,0x4a,0x75,0x6e,0x6b,0x69,0x65,0x73,0x0e,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x44,0x4a,0x20,0x46,0x75,0x67,0x75};
char *vendor_theora = "Xiph.Org libTheora I 20060526 3 2 0";
unsigned char comment_packet_theora[92] = {0x81,0x74,0x68,0x65,0x6f,0x72,0x61,0x23,0x00,0x00,0x00,0x58,0x69,0x70,0x68,0x2e,0x4f,0x72,0x67,0x20,0x6c,0x69,0x62,0x54,0x68,0x65,0x6f,0x72,0x61,0x20,0x49,0x20,0x32,0x30,0x30,0x36,0x30,0x35,0x32,0x36,0x20,0x33,0x20,0x32,0x20,0x30,0x02,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x54,0x72,0x6f,0x75,0x74,0x20,0x4a,0x75,0x6e,0x6b,0x69,0x65,0x73,0x0e,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x44,0x4a,0x20,0x46,0x75,0x67,0x75};
char *vendor_vorbis = "Xiph.Org libVorbis I 20050304";
unsigned char comment_packet_vorbis[87] = {0x03,0x76,0x6f,0x72,0x62,0x69,0x73,0x1d,0x00,0x00,0x00,0x58,0x69,0x70,0x68,0x2e,0x4f,0x72,0x67,0x20,0x6c,0x69,0x62,0x56,0x6f,0x72,0x62,0x69,0x73,0x20,0x49,0x20,0x32,0x30,0x30,0x35,0x30,0x33,0x30,0x34,0x02,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x54,0x72,0x6f,0x75,0x74,0x20,0x4a,0x75,0x6e,0x6b,0x69,0x65,0x73,0x0e,0x00,0x00,0x00,0x41,0x52,0x54,0x49,0x53,0x54,0x3d,0x44,0x4a,0x20,0x46,0x75,0x67,0x75,0x01};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment