autogen.sh : OpenBSD tweaks.
[platform/upstream/flac.git] / src / test_libFLAC / format.c
index 9c55a9a..5e88172 100644 (file)
@@ -1,5 +1,5 @@
 /* test_libFLAC - Unit tester for libFLAC
- * Copyright (C) 2004,2005,2006  Josh Coalson
+ * Copyright (C) 2004,2005,2006,2007,2008,2009  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #if HAVE_CONFIG_H
@@ -22,6 +22,7 @@
 
 #include "FLAC/assert.h"
 #include "FLAC/format.h"
+#include "format.h"
 #include <stdio.h>
 
 static const char *true_false_string_[2] = { "false", "true" };
@@ -29,41 +30,46 @@ static const char *true_false_string_[2] = { "false", "true" };
 static struct {
        unsigned rate;
        FLAC__bool valid;
+       FLAC__bool subset;
 } SAMPLE_RATES[] = {
-       { 0      , false },
-       { 1      , true  },
-       { 9      , true  },
-       { 10     , true  },
-       { 4000   , true  },
-       { 8000   , true  },
-       { 11025  , true  },
-       { 12000  , true  },
-       { 16000  , true  },
-       { 22050  , true  },
-       { 24000  , true  },
-       { 32000  , true  },
-       { 32768  , true  },
-       { 44100  , true  },
-       { 48000  , true  },
-       { 65000  , true  },
-       { 65535  , true  },
-       { 65536  , false },
-       { 65540  , true  },
-       { 65550  , true  },
-       { 65555  , false },
-       { 66000  , true  },
-       { 66001  , false },
-       { 96000  , true  },
-       { 100000 , true  },
-       { 100001 , false },
-       { 192000 , true  },
-       { 500000 , true  },
-       { 500001 , false },
-       { 500010 , true  },
-       { 700000 , false },
-       { 700010 , false },
-       { 1000000, false },
-       { 1100000, false }
+       { 0      , false, false },
+       { 1      , true , true  },
+       { 9      , true , true  },
+       { 10     , true , true  },
+       { 4000   , true , true  },
+       { 8000   , true , true  },
+       { 11025  , true , true  },
+       { 12000  , true , true  },
+       { 16000  , true , true  },
+       { 22050  , true , true  },
+       { 24000  , true , true  },
+       { 32000  , true , true  },
+       { 32768  , true , true  },
+       { 44100  , true , true  },
+       { 48000  , true , true  },
+       { 65000  , true , true  },
+       { 65535  , true , true  },
+       { 65536  , true , false },
+       { 65540  , true , true  },
+       { 65550  , true , true  },
+       { 65555  , true , false },
+       { 66000  , true , true  },
+       { 66001  , true , false },
+       { 96000  , true , true  },
+       { 100000 , true , true  },
+       { 100001 , true , false },
+       { 192000 , true , true  },
+       { 500000 , true , true  },
+       { 500001 , true , false },
+       { 500010 , true , true  },
+       { 655349 , true , false },
+       { 655350 , true , true  },
+       { 655351 , false, false },
+       { 655360 , false, false },
+       { 700000 , false, false },
+       { 700010 , false, false },
+       { 1000000, false, false },
+       { 1100000, false, false }
 };
 
 static struct {
@@ -185,7 +191,7 @@ static struct {
        { 5, (const FLAC__byte*)"a=\xe1\xa5\x80", true  }
 };
 
-FLAC__bool test_format()
+FLAC__bool test_format(void)
 {
        unsigned i;
 
@@ -200,6 +206,15 @@ FLAC__bool test_format()
                printf("OK\n");
        }
 
+       for(i = 0; i < sizeof(SAMPLE_RATES)/sizeof(SAMPLE_RATES[0]); i++) {
+               printf("testing FLAC__format_sample_rate_is_subset(%u)... ", SAMPLE_RATES[i].rate);
+               if(FLAC__format_sample_rate_is_subset(SAMPLE_RATES[i].rate) != SAMPLE_RATES[i].subset) {
+                       printf("FAILED, expected %s, got %s\n", true_false_string_[SAMPLE_RATES[i].subset], true_false_string_[!SAMPLE_RATES[i].subset]);
+                       return false;
+               }
+               printf("OK\n");
+       }
+
        for(i = 0; i < sizeof(VCENTRY_NAMES)/sizeof(VCENTRY_NAMES[0]); i++) {
                printf("testing FLAC__format_vorbiscomment_entry_name_is_legal(\"%s\")... ", VCENTRY_NAMES[i].string);
                if(FLAC__format_vorbiscomment_entry_name_is_legal(VCENTRY_NAMES[i].string) != VCENTRY_NAMES[i].valid) {