Changeset 2593

Show
Ignore:
Timestamp:
2006-12-24 15:41:56 (2 years ago)
Author:
imalone
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • liboggz/trunk/src/tests/comment-test.c

    r2563 r2593  
    4141#include "oggz_tests.h" 
    4242 
     43#include "comment-test.h" 
     44 
    4345#define ARTIST1 "Trout Junkies" 
    4446#define ARTIST2 "DJ Fugu" 
     
    5456  const OggzComment * comment, * comment2; 
    5557  OggzComment mycomment; 
     58  ogg_packet *op; 
     59  const char * vendor; 
    5660  int err; 
    5761 
    5862  long serialno = 7; 
     63  long invalidserialno = 8; 
    5964 
    6065#if OGGZ_CONFIG_WRITE 
     
    185190    FAIL ("Removed comment incorrectly retrieved"); 
    186191 
     192  INFO ("+ Attempting to set vendor string"); 
     193  err = oggz_comment_set_vendor (oggz, serialno, vendor_flac ); 
     194  if (err) FAIL ("Operation failed"); 
     195 
     196  INFO ("+ Retrieving vendor string"); 
     197  vendor = oggz_comment_get_vendor (oggz, serialno); 
     198  if (!vendor || strcmp(vendor, vendor_flac)) 
     199    FAIL ("+ Operation failed"); 
     200 
     201  INFO("+ Generating FLAC comment packet"); 
     202  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_FLAC, 0); 
     203  if (!op) FAIL ("Operation failed"); 
     204 
     205  INFO("+ Checking FLAC comment packet"); 
     206  if (op->bytes != sizeof comment_packet_flac || 
     207      memcmp (op->packet, comment_packet_flac, op->bytes) ) 
     208      FAIL ("Incorrect packet"); 
     209  oggz_packet_destroy(op); 
     210 
     211 
     212  INFO("+ Generating OggPCM comment packet"); 
     213  /* OggPCM and Speex comment packets are identical. */ 
     214  err = oggz_comment_set_vendor (oggz, serialno, vendor_speex ); 
     215  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_PCM, 0); 
     216  if (err || !op) FAIL ("Operation failed"); 
     217 
     218  INFO("+ Checking OggPCM comment packet"); 
     219  if (op->bytes != sizeof comment_packet_speex || 
     220      memcmp (op->packet, comment_packet_speex, op->bytes) ) 
     221      FAIL ("Incorrect packet"); 
     222  oggz_packet_destroy(op); 
     223 
     224 
     225  INFO("+ Generating Speex comment packet"); 
     226  err = oggz_comment_set_vendor (oggz, serialno, vendor_speex ); 
     227  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_SPEEX, 0); 
     228  if (err || !op) FAIL ("Operation failed"); 
     229 
     230  INFO("+ Checking Speex comment packet"); 
     231  if (op->bytes != sizeof comment_packet_speex || 
     232      memcmp (op->packet, comment_packet_speex, op->bytes) ) 
     233      FAIL ("Incorrect packet"); 
     234  oggz_packet_destroy(op); 
     235 
     236 
     237  INFO("+ Generating Theora comment packet"); 
     238  err = oggz_comment_set_vendor (oggz, serialno, vendor_theora ); 
     239  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_THEORA, 0); 
     240  if (err || !op) FAIL ("Operation failed"); 
     241 
     242  INFO("+ Checking Theora comment packet"); 
     243  if (op->bytes != sizeof comment_packet_theora || 
     244      memcmp (op->packet, comment_packet_theora, op->bytes) ) 
     245    FAIL ("Incorrect packet"); 
     246  oggz_packet_destroy(op); 
     247 
     248 
     249  INFO("+ Generating Vorbis comment packet"); 
     250  err = oggz_comment_set_vendor (oggz, serialno, vendor_vorbis ); 
     251  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_VORBIS, 0); 
     252  if (err || !op) FAIL ("Operation failed"); 
     253 
     254  INFO("+ Checking Vorbis comment packet"); 
     255  if (op->bytes != sizeof comment_packet_vorbis || 
     256      memcmp (op->packet, comment_packet_vorbis, op->bytes) ) 
     257    FAIL ("Incorrect packet"); 
     258  oggz_packet_destroy(op); 
     259 
     260  INFO("+ Testing comment generate for unsupported type"); 
     261  op = oggz_comment_generate (oggz, serialno, OGGZ_CONTENT_UNKNOWN, 0); 
     262  if(op) FAIL ("Returned comment packet for unsupported type"); 
     263  oggz_packet_destroy(op); 
     264 
     265  INFO("+ Testing comment generate for invalid serialno"); 
     266  op = oggz_comment_generate (oggz, invalidserialno, OGGZ_CONTENT_VORBIS, 0); 
     267  if(op) FAIL ("Returned comment packet for invalid serialno"); 
     268  oggz_packet_destroy(op); 
     269 
     270 
    187271  INFO ("Closing OGGZ (writer)"); 
    188272  oggz_close (oggz);