1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/*
* A simple test for the ES unit lists from es.c
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the MPEG TS, PS and ES tools.
*
* The Initial Developer of the Original Code is Amino Communications Ltd.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Amino Communications Ltd, Swavesey, Cambridge UK
*
* ***** END LICENSE BLOCK *****
*/
#include <stdio.h>
#include <stdlib.h>
#include "compat.h"
#include "es_fns.h"
int main(int argc, char **argv)
{
int err, ii;
int max = ES_UNIT_LIST_START_SIZE + ES_UNIT_LIST_INCREMENT + 3;
ES_unit_list_p list = NULL;
ES_unit_p unit = NULL;
printf("Testing ES unit list\n");
printf("Test 1 - differing ES units\n");
err = build_ES_unit_list(&list);
if (err)
{
printf("Test failed - constructing list\n");
return 1;
}
for (ii=0; ii<max; ii++)
{
err = build_ES_unit(&unit);
if (err)
{
printf("Test failed - constructing ES unit\n");
return 1;
}
err = append_to_ES_unit_list(list,unit);
if (err)
{
printf("Test failed - appending ES unit %d\n",ii);
return 1;
}
if (list->length > list->size)
{
printf("Test failed - list length = %d, size = %d\n",
list->length,list->size);
return 1;
}
else if (list->length != ii+1)
{
printf("Test failed - list length is %d, expected %d\n",
list->length,ii+1);
return 1;
}
free_ES_unit(&unit);
}
printf("Test 1 - resetting list\n");
reset_ES_unit_list(list);
if (list->length != 0)
{
printf("Test failed - list length is %d, not 0\n",list->length);
return 1;
}
// And try populating the list again, but a bit further this time
for (ii=0; ii<max+ES_UNIT_LIST_INCREMENT; ii++)
{
err = build_ES_unit(&unit);
if (err)
{
printf("Test failed - constructing ES unit\n");
return 1;
}
err = append_to_ES_unit_list(list,unit);
if (err)
{
printf("Test failed - appending ES unit %d\n",ii);
return 1;
}
if (list->length > list->size)
{
printf("Test failed - list length = %d, size = %d\n",
list->length,list->size);
return 1;
}
else if (list->length != ii+1)
{
printf("Test failed - list length is %d, expected %d\n",
list->length,ii+1);
return 1;
}
free_ES_unit(&unit);
}
printf("Test 1 - clearing list\n");
free_ES_unit_list(&list);
printf("Test 1 succeeded\n");
printf("Test 2 - the same ES unit inserted multiple times\n");
err = build_ES_unit_list(&list);
if (err)
{
printf("Test failed - constructing list\n");
return 1;
}
err = build_ES_unit(&unit);
if (err)
{
printf("Test failed - constructing ES unit\n");
return 1;
}
// We aren't testing allocation limits this time round
for (ii=0; ii<5; ii++)
{
err = append_to_ES_unit_list(list,unit);
if (err)
{
printf("Test failed - appending ES unit %d\n",ii);
return 1;
}
}
printf("Test 2 - clearing list\n");
free_ES_unit_list(&list);
free_ES_unit(&unit);
printf("Test 2 succeeded\n");
return 0;
}
// Local Variables:
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 2
// End:
// vim: set tabstop=8 shiftwidth=2 expandtab:
|