Initial commit
[data-faker-colour.git] / t / Data-Faker-Colour.t
CommitLineData
f14ac6c3
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Test::More tests => 8;
6BEGIN { use_ok('Data::Faker::Colour') }
7
8sub valid{
9 my $expected = shift;
10 return unless $expected == @_;
11 my $ret = 1;
12 for my $colour (@_) {
13 $ret &&= 0 <= $colour->[$_] && $colour->[$_] <= 255 for 0, 1, 2;
14 }
15 $ret
16}
17
18note 'These tests only check if the generated colours are valid. They don\'t check whether the colours have the requested hue, saturation or lightness';
19
20my $f = Data::Faker::Colour->new;
21
22ok valid (1, $f->colour), 'colour';
23ok valid (5, $f->color(5)), 'color(5)';
24
25ok valid (1, $f->colour_hsluv), 'colour_hsluv';
26ok valid (200, $f->colour_hsluv(200, 10)), 'colour_hsluv(200, 10)';
27ok valid (200, $f->colour_hsluv(200, -1, 10)), 'colour_hsluv(200, -1, 10)';
28ok valid (200, $f->colour_hsluv(200, -1, -1, 10)), 'colour_hsluv(200, -1, -1, 10)';
29
30ok valid (2000, $f->colour_hsluv(2000, -1, 100, 40)), 'colour_hsluv(2000, -1, 100, 40)';
This page took 0.011149 seconds and 4 git commands to generate.