FOSSology  4.4.0
Open Source License Compliance by Open Source Software
testOtheFunctions.c File Reference

Testing for the function CheckMimeTypes, GetDefaultMime, GetFieldValue. More...

#include <CUnit/CUnit.h>
#include "finder.h"
#include <string.h>
Include dependency graph for testOtheFunctions.c:

Go to the source code of this file.

Functions

int CheckMimeTypes (char *Ext)
 Given an extension, see if extension exists in the /etc/mime.types. More...
 
int DBCheckFileExtention ()
 Given a pfile, identify any filenames and see if any of them have a known extension based on /etc/mime.types. More...
 
char * GetFieldValue (char *Sin, char *Field, int FieldMax, char *Value, int ValueMax)
 Given a string that contains field='value' pairs, save the items. More...
 
int DBInit ()
 initialize DB
 
int DBClean ()
 clean the env
 
void testCheckMimeTypes ()
 for function CheckMimeTypes() More...
 
void testDBCheckFileExtention ()
 for function DBCheckFileExtention() More...
 
void testGetFieldValue ()
 for function GetFieldValue() More...
 

Variables

char * DBConfFile
 DB conf file location.
 
static PGresult * result = NULL
 
static long upload_pk = -1
 
static long pfile_pk = -1
 
CU_TestInfo testcases_CheckMimeTypes []
 testcases for function CheckMimeTypes More...
 
CU_TestInfo testcases_DBCheckFileExtention []
 testcases for function DBCheckFileExtention More...
 
CU_TestInfo testcases_Utilities []
 testcases for function GetFieldValue More...
 

Detailed Description

Testing for the function CheckMimeTypes, GetDefaultMime, GetFieldValue.

Definition in file testOtheFunctions.c.

Function Documentation

◆ CheckMimeTypes()

int CheckMimeTypes ( char *  Ext)

Given an extension, see if extension exists in the /etc/mime.types.

Parameters
ExtThe extension
Returns
int - if the extension exists in the /etc/mime.types, add metatype to DB and return DB index. Otherwise, return -1.

Definition at line 127 of file finder.c.

◆ DBCheckFileExtention()

int DBCheckFileExtention ( )

Given a pfile, identify any filenames and see if any of them have a known extension based on /etc/mime.types.

Note
Reads pfile id from Akey
Returns
int - return the mimetype id, or -1 if not found.

Definition at line 185 of file finder.c.

◆ GetFieldValue()

char* GetFieldValue ( char *  Sin,
char *  Field,
int  FieldMax,
char *  Value,
int  ValueMax 
)

Given a string that contains field='value' pairs, save the items.

Parameters
[in]SinInput string
[out]FieldField string
[in]FieldMaxCapacity of Field
[out]ValueValue string
[in]ValueMaxCapacity of Field
Returns
Return character pointer to start of next field, or NULL at \0.

Definition at line 414 of file finder.c.

◆ testCheckMimeTypes()

void testCheckMimeTypes ( )

for function CheckMimeTypes()

Test:
  1. Clear mimetype for bin extension in mimetype table
  2. Get mimetype id for bin extension from CheckMimeTypes()
  3. Check if the return id matched DB id
  4. Check for one more extension

Definition at line 212 of file testOtheFunctions.c.

◆ testDBCheckFileExtention()

void testDBCheckFileExtention ( )

for function DBCheckFileExtention()

Test:
  1. For a given file, check if DBCheckFileExtention() returns correct mimetype id

Definition at line 299 of file testOtheFunctions.c.

◆ testGetFieldValue()

void testGetFieldValue ( )

for function GetFieldValue()

Test:
  1. Create a string with field='value' format
  2. Call GetFieldValue()
  3. Check if correct filed and value are identified

Definition at line 343 of file testOtheFunctions.c.

Variable Documentation

◆ testcases_CheckMimeTypes

CU_TestInfo testcases_CheckMimeTypes[]
Initial value:
=
{
{"CheckMimeTypes:C", testCheckMimeTypes},
CU_TEST_INFO_NULL
}
void testCheckMimeTypes()
for function CheckMimeTypes()

testcases for function CheckMimeTypes

Definition at line 357 of file testOtheFunctions.c.

◆ testcases_DBCheckFileExtention

CU_TestInfo testcases_DBCheckFileExtention[]
Initial value:
=
{
{"DBCheckFileExtention:C", testDBCheckFileExtention},
CU_TEST_INFO_NULL
}
void testDBCheckFileExtention()
for function DBCheckFileExtention()

testcases for function DBCheckFileExtention

Definition at line 368 of file testOtheFunctions.c.

◆ testcases_Utilities

CU_TestInfo testcases_Utilities[]
Initial value:
=
{
{"GetFieldValue:Exist", testGetFieldValue},
CU_TEST_INFO_NULL
}
void testGetFieldValue()
for function GetFieldValue()

testcases for function GetFieldValue

Definition at line 379 of file testOtheFunctions.c.