diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2013-01-02 02:16:51 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2013-01-02 02:16:51 +0400 |
commit | 0e9d96100b28be2794804fc73c200423b8b9ef8e (patch) | |
tree | e081e9b0ea3d46e9d2bbd1f3e5bb87725216e62b /t/layers.t | |
parent | a633180518ebfe2ec1805aa9d63cc9c9f4c00ccb (diff) |
New unit test for layer heights
Diffstat (limited to 't/layers.t')
-rw-r--r-- | t/layers.t | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/t/layers.t b/t/layers.t new file mode 100644 index 000000000..3d381788a --- /dev/null +++ b/t/layers.t @@ -0,0 +1,58 @@ +use Test::More tests => 4; +use strict; +use warnings; + +BEGIN { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use List::Util qw(first); +use Slic3r; +use Slic3r::Test qw(_eq); + +my $config = Slic3r::Config->new_from_defaults; + +my $test = sub { + my ($conf) = @_; + $conf ||= $config; + + my $print = Slic3r::Test::init_print('20mm_cube', config => $conf); + + my @z = (); + my @increments = (); + Slic3r::Test::GCodeReader->new(gcode => Slic3r::Test::gcode($print))->parse(sub { + my ($self, $cmd, $args, $info) = @_; + + if ($info->{dist_Z}) { + push @z, 1*$args->{Z}; + push @increments, $info->{dist_Z}; + } + }); + + fail 'wrong first layer height' + if $z[0] ne $config->get_value('first_layer_height') + $config->z_offset; + + fail 'wrong second layer height' + if $z[1] ne $config->get_value('first_layer_height') + $config->get_value('layer_height') + $config->z_offset; + + fail 'wrong layer height' + if first { !_eq($_, $config->layer_height) } @increments[1..$#increments]; + + 1; +}; + +$config->set('layer_height', 0.3); +$config->set('first_layer_height', 0.2); +ok $test->(), "absolute first layer height"; + +$config->set('first_layer_height', '60%'); +ok $test->(), "relative first layer height"; + +$config->set('z_offset', 0.9); +ok $test->(), "positive Z offset"; + +$config->set('z_offset', -0.8); +ok $test->(), "negative Z offset"; + +__END__ |