Initial commit
[data-faker-colour.git] / t / Data-Faker-Colour.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 8;
6 BEGIN { use_ok('Data::Faker::Colour') }
7
8 sub 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
18 note '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
20 my $f = Data::Faker::Colour->new;
21
22 ok valid (1, $f->colour), 'colour';
23 ok valid (5, $f->color(5)), 'color(5)';
24
25 ok valid (1, $f->colour_hsluv), 'colour_hsluv';
26 ok valid (200, $f->colour_hsluv(200, 10)), 'colour_hsluv(200, 10)';
27 ok valid (200, $f->colour_hsluv(200, -1, 10)), 'colour_hsluv(200, -1, 10)';
28 ok valid (200, $f->colour_hsluv(200, -1, -1, 10)), 'colour_hsluv(200, -1, -1, 10)';
29
30 ok valid (2000, $f->colour_hsluv(2000, -1, 100, 40)), 'colour_hsluv(2000, -1, 100, 40)';
This page took 0.02588 seconds and 4 git commands to generate.