/*
 * Huffman tree testing program
 *
 * Copyright (C) 2008-2023, Joachim Metz <joachim.metz@gmail.com>
 *
 * Refer to AUTHORS for acknowledgements.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 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 Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#include <common.h>
#include <memory.h>
#include <file_stream.h>
#include <types.h>

#if defined( HAVE_STDLIB_H ) || defined( WINAPI )
#include <stdlib.h>
#endif

#include "pff_test_libcerror.h"
#include "pff_test_libcnotify.h"
#include "pff_test_macros.h"
#include "pff_test_memory.h"
#include "pff_test_unused.h"

#include "../libpff/libpff_bit_stream.h"
#include "../libpff/libpff_huffman_tree.h"

uint8_t pff_test_huffman_tree_data[ 2627 ] = {
	0x78, 0xda, 0xbd, 0x59, 0x6d, 0x8f, 0xdb, 0xb8, 0x11, 0xfe, 0x7c, 0xfa, 0x15, 0xc4, 0x7e, 0xb9,
	0x5d, 0xc0, 0x75, 0x5e, 0x7b, 0x45, 0x0f, 0x45, 0x81, 0xed, 0xde, 0x26, 0xdd, 0x62, 0x2f, 0x0d,
	0xb2, 0x97, 0x16, 0xfd, 0x48, 0x4b, 0xb4, 0xcd, 0x46, 0x12, 0x5d, 0x52, 0x5a, 0xc7, 0xfd, 0xf5,
	0x7d, 0x66, 0x86, 0x94, 0x28, 0xd9, 0xde, 0xec, 0xe1, 0x80, 0x06, 0x38, 0x5c, 0x62, 0x93, 0xc3,
	0x79, 0x7d, 0xe6, 0x99, 0xf1, 0x77, 0xdf, 0x29, 0xa5, 0xde, 0x7f, 0xf8, 0xac, 0xee, 0x6f, 0x1f,
	0x1e, 0x6e, 0x3f, 0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40, 0xc6, 0x72, 0x69, 0xb1, 0x3e,
	0x94, 0xe5, 0x12, 0xff, 0xbc, 0x03, 0x79, 0xd9, 0x68, 0xcc, 0x54, 0x28, 0xc6, 0x93, 0x71, 0x41,
	0x7f, 0x2e, 0xaf, 0x92, 0xe3, 0xd4, 0xd4, 0x71, 0x45, 0xee, 0xb8, 0x71, 0x0f, 0xc5, 0x1e, 0xa4,
	0x01, 0x75, 0xea, 0xfd, 0x5f, 0xf1, 0x53, 0xcf, 0xb0, 0x77, 0xdb, 0x3a, 0xda, 0x37, 0x91, 0xe6,
	0x67, 0x7f, 0x3c, 0x3b, 0x23, 0x44, 0xc9, 0xf6, 0xea, 0xd9, 0x16, 0xc6, 0xad, 0xe6, 0xb1, 0x91,
	0x4f, 0x67, 0x07, 0x12, 0xf4, 0x2b, 0xf4, 0xd4, 0x94, 0xc0, 0x25, 0x1a, 0x46, 0x01, 0x98, 0xe0,
	0x68, 0xac, 0x7b, 0x5a, 0xa7, 0x0c, 0x15, 0xf7, 0xfc, 0x1f, 0xfd, 0x40, 0x73, 0xeb, 0x9a, 0x93,
	0xe3, 0xb0, 0x88, 0x01, 0xa5, 0x37, 0xbe, 0x0f, 0x62, 0x4c, 0xa9, 0xd0, 0x78, 0x3b, 0xfe, 0xf9,
	0x8e, 0x83, 0x5a, 0xd2, 0x3a, 0x59, 0xd3, 0x70, 0x15, 0x43, 0x3c, 0x16, 0x45, 0x41, 0xa3, 0x84,
	0x66, 0x7c, 0xd4, 0x7d, 0xb7, 0x75, 0xde, 0xfe, 0x57, 0x50, 0x82, 0x3a, 0x2d, 0x59, 0x46, 0xbf,
	0x7d, 0x8a, 0x87, 0xf9, 0x9d, 0x74, 0x33, 0x0e, 0x79, 0xc5, 0xf8, 0x73, 0xcd, 0xff, 0x00, 0x30,
	0x4a, 0x56, 0xa4 };

#if defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT )

/* Tests the libpff_huffman_tree_initialize function
 * Returns 1 if successful or 0 if not
 */
int pff_test_huffman_tree_initialize(
     void )
{
	libcerror_error_t *error             = NULL;
	libpff_huffman_tree_t *huffman_tree = NULL;
	int result                           = 0;

#if defined( HAVE_PFF_TEST_MEMORY )
	int number_of_malloc_fail_tests      = 1;
	int number_of_memset_fail_tests      = 1;
	int test_number                      = 0;
#endif

	/* Test regular cases
	 */
	result = libpff_huffman_tree_initialize(
	          &huffman_tree,
	          288,
	          15,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	result = libpff_huffman_tree_free(
	          &huffman_tree,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	/* Test error cases
	 */
	result = libpff_huffman_tree_initialize(
	          NULL,
	          288,
	          15,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	huffman_tree = (libpff_huffman_tree_t *) 0x12345678UL;

	result = libpff_huffman_tree_initialize(
	          &huffman_tree,
	          288,
	          15,
	          &error );

	huffman_tree = NULL;

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

#if defined( HAVE_PFF_TEST_MEMORY )

	for( test_number = 0;
	     test_number < number_of_malloc_fail_tests;
	     test_number++ )
	{
		/* Test libpff_huffman_tree_initialize with malloc failing
		 */
		pff_test_malloc_attempts_before_fail = test_number;

		result = libpff_huffman_tree_initialize(
		          &huffman_tree,
		          288,
		          15,
		          &error );

		if( pff_test_malloc_attempts_before_fail != -1 )
		{
			pff_test_malloc_attempts_before_fail = -1;

			if( huffman_tree != NULL )
			{
				libpff_huffman_tree_free(
				 &huffman_tree,
				 NULL );
			}
		}
		else
		{
			PFF_TEST_ASSERT_EQUAL_INT(
			 "result",
			 result,
			 -1 );

			PFF_TEST_ASSERT_IS_NULL(
			 "huffman_tree",
			 huffman_tree );

			PFF_TEST_ASSERT_IS_NOT_NULL(
			 "error",
			 error );

			libcerror_error_free(
			 &error );
		}
	}
	for( test_number = 0;
	     test_number < number_of_memset_fail_tests;
	     test_number++ )
	{
		/* Test libpff_huffman_tree_initialize with memset failing
		 */
		pff_test_memset_attempts_before_fail = test_number;

		result = libpff_huffman_tree_initialize(
		          &huffman_tree,
		          288,
		          15,
		          &error );

		if( pff_test_memset_attempts_before_fail != -1 )
		{
			pff_test_memset_attempts_before_fail = -1;

			if( huffman_tree != NULL )
			{
				libpff_huffman_tree_free(
				 &huffman_tree,
				 NULL );
			}
		}
		else
		{
			PFF_TEST_ASSERT_EQUAL_INT(
			 "result",
			 result,
			 -1 );

			PFF_TEST_ASSERT_IS_NULL(
			 "huffman_tree",
			 huffman_tree );

			PFF_TEST_ASSERT_IS_NOT_NULL(
			 "error",
			 error );

			libcerror_error_free(
			 &error );
		}
	}
#endif /* defined( HAVE_PFF_TEST_MEMORY ) */

	return( 1 );

on_error:
	if( error != NULL )
	{
		libcerror_error_free(
		 &error );
	}
	if( huffman_tree != NULL )
	{
		libpff_huffman_tree_free(
		 &huffman_tree,
		 NULL );
	}
	return( 0 );
}

/* Tests the libpff_huffman_tree_free function
 * Returns 1 if successful or 0 if not
 */
int pff_test_huffman_tree_free(
     void )
{
	libcerror_error_t *error = NULL;
	int result               = 0;

	/* Test error cases
	 */
	result = libpff_huffman_tree_free(
	          NULL,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	return( 1 );

on_error:
	if( error != NULL )
	{
		libcerror_error_free(
		 &error );
	}
	return( 0 );
}

/* Tests the libpff_huffman_tree_build function
 * Returns 1 if successful or 0 if not
 */
int pff_test_huffman_tree_build(
     void )
{
	uint8_t code_size_array[ 318 ];

	libpff_huffman_tree_t *huffman_tree = NULL;
	libcerror_error_t *error             = NULL;
	uint16_t symbol                      = 0;
	int result                           = 0;

	/* Initialize test
	 */
	for( symbol = 0;
	     symbol < 318;
	     symbol++ )
	{
		if( symbol < 144 )
		{
			code_size_array[ symbol ] = 8;
		}
		else if( symbol < 256 )
		{
			code_size_array[ symbol ] = 9;
		}
		else if( symbol < 280 )
		{
			code_size_array[ symbol ] = 7;
		}
		else if( symbol < 288 )
		{
			code_size_array[ symbol ] = 8;
		}
		else
		{
			code_size_array[ symbol ] = 5;
		}
	}
	result = libpff_huffman_tree_initialize(
	          &huffman_tree,
	          288,
	          15,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	/* Test regular cases
	 */
	result = libpff_huffman_tree_build(
	          huffman_tree,
	          code_size_array,
	          288,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	/* Test error cases
	 */
	result = libpff_huffman_tree_build(
	          NULL,
	          code_size_array,
	          288,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	result = libpff_huffman_tree_build(
	          huffman_tree,
	          NULL,
	          288,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	result = libpff_huffman_tree_build(
	          huffman_tree,
	          code_size_array,
	          -1,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

#if defined( HAVE_PFF_TEST_MEMORY )

	/* Test libpff_huffman_tree_build with malloc failing
	 */
	pff_test_malloc_attempts_before_fail = 0;

	result = libpff_huffman_tree_build(
	          huffman_tree,
	          code_size_array,
	          288,
	          &error );

	if( pff_test_malloc_attempts_before_fail != -1 )
	{
		pff_test_malloc_attempts_before_fail = -1;
	}
	else
	{
		PFF_TEST_ASSERT_EQUAL_INT(
		 "result",
		 result,
		 -1 );

		PFF_TEST_ASSERT_IS_NOT_NULL(
		 "error",
		 error );

		libcerror_error_free(
		 &error );
	}
#if defined( OPTIMIZATION_DISABLED )

	/* Test libpff_huffman_tree_build with memset failing
	 */
	pff_test_memset_attempts_before_fail = 0;

	result = libpff_huffman_tree_build(
	          huffman_tree,
	          code_size_array,
	          288,
	          &error );

	if( pff_test_memset_attempts_before_fail != -1 )
	{
		pff_test_memset_attempts_before_fail = -1;
	}
	else
	{
		PFF_TEST_ASSERT_EQUAL_INT(
		 "result",
		 result,
		 -1 );

		PFF_TEST_ASSERT_IS_NOT_NULL(
		 "error",
		 error );

		libcerror_error_free(
		 &error );
	}
#endif /* defined( OPTIMIZATION_DISABLED ) */
#endif /* defined( HAVE_PFF_TEST_MEMORY ) */

	/* TODO test errornous data */

	/* Clean up
	 */
	result = libpff_huffman_tree_free(
	          &huffman_tree,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	return( 1 );

on_error:
	if( huffman_tree != NULL )
	{
		libpff_huffman_tree_free(
		 &huffman_tree,
		 NULL );
	}
	return( 0 );
}

/* Tests the libpff_huffman_tree_get_symbol_from_bit_stream function
 * Returns 1 if successful or 0 if not
 */
int pff_test_huffman_tree_get_symbol_from_bit_stream(
     void )
{
	uint8_t code_size_array[ 318 ];

	libpff_bit_stream_t *bit_stream     = NULL;
	libpff_huffman_tree_t *huffman_tree = NULL;
	libcerror_error_t *error             = NULL;
	uint16_t symbol                      = 0;
	int result                           = 0;

	/* Initialize test
	 */
	result = libpff_bit_stream_initialize(
	          &bit_stream,
	          pff_test_huffman_tree_data,
	          2627,
	          2,
	          LIBPFF_BIT_STREAM_STORAGE_TYPE_BYTE_BACK_TO_FRONT,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "bit_stream",
	 bit_stream );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	for( symbol = 0;
	     symbol < 318;
	     symbol++ )
	{
		if( symbol < 144 )
		{
			code_size_array[ symbol ] = 8;
		}
		else if( symbol < 256 )
		{
			code_size_array[ symbol ] = 9;
		}
		else if( symbol < 280 )
		{
			code_size_array[ symbol ] = 7;
		}
		else if( symbol < 288 )
		{
			code_size_array[ symbol ] = 8;
		}
		else
		{
			code_size_array[ symbol ] = 5;
		}
	}
	result = libpff_huffman_tree_initialize(
	          &huffman_tree,
	          288,
	          15,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	result = libpff_huffman_tree_build(
	          huffman_tree,
	          code_size_array,
	          288,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	/* Test regular cases
	 */
	symbol = 0;

	result = libpff_huffman_tree_get_symbol_from_bit_stream(
	          huffman_tree,
	          bit_stream,
	          &symbol,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_EQUAL_UINT16(
	 "symbol",
	 symbol,
	 (uint16_t) 141 );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	/* Test error cases
	 */
	symbol = 0;

	result = libpff_huffman_tree_get_symbol_from_bit_stream(
	          NULL,
	          bit_stream,
	          &symbol,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	result = libpff_huffman_tree_get_symbol_from_bit_stream(
	          huffman_tree,
	          NULL,
	          &symbol,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	result = libpff_huffman_tree_get_symbol_from_bit_stream(
	          huffman_tree,
	          bit_stream,
	          NULL,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

/* TODO add byte stream seek function */
        bit_stream->byte_stream_offset = 2627;
        bit_stream->bit_buffer_size    = 0;

	result = libpff_huffman_tree_get_symbol_from_bit_stream(
	          huffman_tree,
	          bit_stream,
	          &symbol,
	          &error );

        bit_stream->byte_stream_offset = 2;

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	PFF_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	/* Clean up
	 */
	result = libpff_huffman_tree_free(
	          &huffman_tree,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "huffman_tree",
	 huffman_tree );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	result = libpff_bit_stream_free(
	          &bit_stream,
	          &error );

	PFF_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 1 );

	PFF_TEST_ASSERT_IS_NULL(
	 "bit_stream",
	 bit_stream );

	PFF_TEST_ASSERT_IS_NULL(
	 "error",
	 error );

	return( 1 );

on_error:
	if( huffman_tree != NULL )
	{
		libpff_huffman_tree_free(
		 &huffman_tree,
		 NULL );
	}
	if( bit_stream != NULL )
	{
		libpff_bit_stream_free(
		 &bit_stream,
		 NULL );
	}
	return( 0 );
}

#endif /* defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT ) */

/* The main program
 */
#if defined( HAVE_WIDE_SYSTEM_CHARACTER )
int wmain(
     int argc PFF_TEST_ATTRIBUTE_UNUSED,
     wchar_t * const argv[] PFF_TEST_ATTRIBUTE_UNUSED )
#else
int main(
     int argc PFF_TEST_ATTRIBUTE_UNUSED,
     char * const argv[] PFF_TEST_ATTRIBUTE_UNUSED )
#endif
{
	PFF_TEST_UNREFERENCED_PARAMETER( argc )
	PFF_TEST_UNREFERENCED_PARAMETER( argv )

#if defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT )

	PFF_TEST_RUN(
	 "libpff_huffman_tree_initialize",
	 pff_test_huffman_tree_initialize );

	PFF_TEST_RUN(
	 "libpff_huffman_tree_free",
	 pff_test_huffman_tree_free );

	PFF_TEST_RUN(
	 "libpff_huffman_tree_build",
	 pff_test_huffman_tree_build );

	PFF_TEST_RUN(
	 "libpff_huffman_tree_get_symbol_from_bit_stream",
	 pff_test_huffman_tree_get_symbol_from_bit_stream );

#endif /* defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT ) */

	return( EXIT_SUCCESS );

#if defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT )

on_error:
	return( EXIT_FAILURE );

#endif /* defined( __GNUC__ ) && !defined( LIBPFF_DLL_IMPORT ) */
}

