Commit a46495cd authored by Daniel Kamil Kozar's avatar Daniel Kamil Kozar Committed by Jean-Paul Saman

write tests for the ISO 639 descriptor

Signed-off-by: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent f11c0a31
......@@ -28,3 +28,4 @@
<!ATTLIST array name CDATA #IMPLIED>
<!ATTLIST array len_name CDATA #IMPLIED>
<!ATTLIST array min_size CDATA #IMPLIED>
......@@ -71,7 +71,11 @@
</insert>
<integer name="i_ca_system_id" bitcount="16" default="0" />
<integer name="i_ca_pid" bitcount="13" default="0" />
<array name="i_private_data" len_name="i_private_length" />
<array name="i_private_data" len_name="i_private_length" min_size="0" />
</descriptor>
<descriptor name="ISO 639 language" sname="iso639" fname="ISO639">
<array name="code" len_name="i_code_count" min_size="1" />
</descriptor>
<descriptor name="system clock" sname="system_clock" fname="SystemClock">
......
......@@ -122,7 +122,7 @@ static int main_<xsl:value-of select="@sname" />_<xsl:value-of select="@msuffix"
<xsl:template match="array" mode="check">
/* check <xsl:value-of select="@name" /> */<xsl:apply-templates select=".." mode="init" />
BOZO_begin_array(<xsl:value-of select="@name" />, <xsl:value-of select="@len_name" />)
BOZO_begin_array(<xsl:value-of select="@name" />, <xsl:value-of select="@len_name" />, <xsl:value-of select="@min_size" />)
BOZO_DOJOB(<xsl:value-of select="../@fname" />);
BOZO_check_array(<xsl:value-of select="@name" />, <xsl:value-of select="@len_name" />)
BOZO_CLEAN();
......
......@@ -469,7 +469,7 @@ static int main_ca_(void)
s_decoded.i_private_length = 0;
BOZO_init_integer(i_ca_system_id, 0);
BOZO_init_integer(i_ca_pid, 0);
BOZO_begin_array(i_private_data, i_private_length)
BOZO_begin_array(i_private_data, i_private_length, 0)
BOZO_DOJOB(CA);
BOZO_check_array(i_private_data, i_private_length)
BOZO_CLEAN();
......@@ -481,6 +481,26 @@ static int main_ca_(void)
return i_err;
}
/* ISO 639 language */
static int main_iso639_(void)
{
BOZO_VARS(iso639);
BOZO_START(ISO 639 language);
/* check code */
BOZO_begin_array(code, i_code_count, 1)
BOZO_DOJOB(ISO639);
BOZO_check_array(code, i_code_count)
BOZO_CLEAN();
BOZO_end_array(code)
BOZO_END(ISO 639 language);
return i_err;
}
/* system clock */
static int main_system_clock_(void)
{
......@@ -670,6 +690,7 @@ int main(void)
i_err |= main_target_bg_grid_();
i_err |= main_vwindow_();
i_err |= main_ca_();
i_err |= main_iso639_();
i_err |= main_system_clock_();
i_err |= main_mx_buff_utilization_();
i_err |= main_copyright_();
......
......@@ -121,19 +121,22 @@
i_err = 1; \
}
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
/* array */
#define BOZO_begin_array(name, len_name) \
#define BOZO_begin_array(name, len_name, min_size) \
if(!i_err) \
{ \
fprintf(stdout, " \"%s\" array check\n", #name); \
i_loop_count = 0; \
i_loop_count = min_size; \
do \
{ \
for(size_t i = 0 ; i < i_loop_count ; ++i) s_decoded.name[i] = rand(); \
for(size_t i = 0 ; i < sizeof(s_decoded.name) ; ++i) \
((uint8_t*)s_decoded.name)[i] = rand(); \
s_decoded.len_name = i_loop_count;
#define BOZO_end_array(name) \
} while(!i_err && i_loop_count < sizeof(s_decoded.name)); \
} while(!i_err && i_loop_count < ARRAY_SIZE(s_decoded.name)); \
fprintf(stdout, "\r iteration count: %22"PRI64d, i_loop_count); \
if(i_err) \
fprintf(stdout, " FAILED !!!\n"); \
......@@ -143,7 +146,8 @@
#define BOZO_check_array(name, len_name) \
if( !i_err \
&& (memcmp(s_decoded.name, p_new_decoded->name, s_decoded.len_name) != 0)) \
&& (memcmp(s_decoded.name, p_new_decoded->name, \
s_decoded.len_name * sizeof(s_decoded.name[0])) != 0)) \
{ \
fprintf(stderr, "\nError: array %s not equal\n", #name); \
i_err = 1; \
......
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