#!/usr/bin/perl
#
# eg12: first test of the frequency utilities module..
#

use strict;
use warnings;
use Function::Parameters qw(:strict);
use Test::More;

plan tests => 2;			# how many tests?

use_ok( 'frequtils' );			# first test.. load module?


#
# my $str = as_string( %hash ):
#	Produce a predictable plain text form of a hash.
#	we've chosen comma separated key:value pairs,
#	sorted by key
#
fun as_string( %hash )
{
	my @k = sort keys %hash;
	return join( ",", map { "$_:$hash{$_}" } @k );
}


my @array = (1,2,1,3);
my $input = "1,2,1,3";
my $expected = "1:2,2:1,3:1";

my %freq = build_freq_hash( @array );
my $output = as_string( %freq );

is( $output, $expected,			# second test.. right result?
	"build_freq_hash($input)=$output" );
