fix test for some version of boots,
...also fix a copy/paste error in image_modification header
This commit is contained in:
parent
ade6952e41
commit
60c1056e01
2 changed files with 95 additions and 316 deletions
|
@ -311,316 +311,3 @@ private:
|
|||
} /* end namespace image */
|
||||
|
||||
#endif /* !defined(IMAGE_MODIFICATIONS_HPP_INCLUDED) */
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2009 - 2011 by Ignacio R. Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 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.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef IMAGE_MODIFICATIONS_HPP_INCLUDED
|
||||
#define IMAGE_MODIFICATIONS_HPP_INCLUDED
|
||||
|
||||
#include "sdl_utils.hpp"
|
||||
#include <queue>
|
||||
|
||||
namespace image {
|
||||
|
||||
class modification;
|
||||
struct mod_ptr_comparator_;
|
||||
/// A priority queue used to enforce using the rc modifications first
|
||||
typedef std::priority_queue<modification*,
|
||||
std::vector<modification*>,
|
||||
mod_ptr_comparator_> modification_queue;
|
||||
|
||||
/// Base abstract class for an image-path modification
|
||||
class modification
|
||||
{
|
||||
public:
|
||||
/// Decodes modifications from a modification string
|
||||
static modification_queue decode(const std::string&);
|
||||
|
||||
virtual ~modification() {}
|
||||
|
||||
///Applies the image-path modification on the specified surface
|
||||
virtual surface operator()(const surface& src) const = 0;
|
||||
|
||||
/// Specifies the priority of the modification
|
||||
virtual int priority() const { return 0; }
|
||||
};
|
||||
|
||||
/// A functor for comparing modification pointers
|
||||
struct mod_ptr_comparator_
|
||||
{
|
||||
/// Provides a descending priority ordering
|
||||
bool operator()(const modification* a, const modification* b) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Recolor (RC/TC/PAL) modification.
|
||||
* It is used not only for color-range-based recoloring ("~RC(magenta>teal)")
|
||||
* but also for team-color-based color range selection and recoloring
|
||||
* ("~TC(3,magenta)") and palette switches ("~PAL(000000,005000 > FFFFFF,FF00FF)").
|
||||
*/
|
||||
class rc_modification : public modification
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
rc_modification()
|
||||
: rc_map_()
|
||||
{}
|
||||
/**
|
||||
* RC-map based constructor.
|
||||
* @param recolor_map The palette switch map.
|
||||
*/
|
||||
rc_modification(const std::map<Uint32, Uint32>& recolor_map)
|
||||
: rc_map_(recolor_map)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
// The rc modification has a higher priority
|
||||
virtual int priority() const { return 1; }
|
||||
|
||||
bool no_op() const { return rc_map_.empty(); }
|
||||
|
||||
const std::map<Uint32, Uint32>& map() const { return rc_map_;}
|
||||
std::map<Uint32, Uint32>& map() { return rc_map_;}
|
||||
|
||||
private:
|
||||
std::map<Uint32, Uint32> rc_map_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mirror (FL) modification.
|
||||
*/
|
||||
class fl_modification : public modification
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* @param horiz Horizontal mirror flag.
|
||||
* @param vert Vertical mirror flag.
|
||||
*/
|
||||
fl_modification(bool horiz = false, bool vert = false)
|
||||
: horiz_(horiz)
|
||||
, vert_(vert)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
void set_horiz(bool val) { horiz_ = val; }
|
||||
void set_vert(bool val) { vert_ = val; }
|
||||
bool get_horiz() const { return horiz_; }
|
||||
bool get_vert() const { return vert_; }
|
||||
/** Toggle horizontal mirror flag.
|
||||
* @return The new flag state after toggling. */
|
||||
bool toggle_horiz() { return((horiz_ = !horiz_)); }
|
||||
/** Toggle vertical mirror flag.
|
||||
* @return The new flag state after toggling. */
|
||||
bool toggle_vert() { return((vert_ = !vert_)); }
|
||||
|
||||
bool no_op() const { return ((!horiz_) && (!vert_)); }
|
||||
|
||||
private:
|
||||
bool horiz_;
|
||||
bool vert_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Grayscale (GS) modification.
|
||||
*/
|
||||
class gs_modification : public modification
|
||||
{
|
||||
public:
|
||||
virtual surface operator()(const surface& src) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Crop (CROP) modification.
|
||||
*/
|
||||
class crop_modification : public modification
|
||||
{
|
||||
public:
|
||||
crop_modification(const SDL_Rect& slice)
|
||||
: slice_(slice)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
const SDL_Rect& get_slice() const;
|
||||
|
||||
private:
|
||||
SDL_Rect slice_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scale (BLIT) modification.
|
||||
*/
|
||||
|
||||
class blit_modification : public modification
|
||||
{
|
||||
public:
|
||||
blit_modification(const surface& surf, int x, int y)
|
||||
: surf_(surf), x_(x), y_(y)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
const surface& get_surface() const;
|
||||
int get_x() const;
|
||||
int get_y() const;
|
||||
|
||||
private:
|
||||
surface surf_;
|
||||
int x_;
|
||||
int y_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mask (MASK) modification.
|
||||
*/
|
||||
|
||||
class mask_modification : public modification
|
||||
{
|
||||
public:
|
||||
mask_modification(const surface& mask, int x, int y)
|
||||
: mask_(mask), x_(x), y_(y)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
const surface& get_mask() const;
|
||||
int get_x() const;
|
||||
int get_y() const;
|
||||
|
||||
private:
|
||||
surface mask_;
|
||||
int x_;
|
||||
int y_;
|
||||
};
|
||||
|
||||
/**
|
||||
* LIGHT (L) modification.
|
||||
*/
|
||||
|
||||
class light_modification : public modification
|
||||
{
|
||||
public:
|
||||
light_modification(const surface& surf)
|
||||
: surf_(surf)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
|
||||
const surface& get_surface() const;
|
||||
|
||||
private:
|
||||
surface surf_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scale (SCALE) modification.
|
||||
*/
|
||||
class scale_modification : public modification
|
||||
{
|
||||
public:
|
||||
scale_modification(int width, int height)
|
||||
: w_(width), h_(height)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
int get_w() const;
|
||||
int get_h() const;
|
||||
|
||||
private:
|
||||
int w_, h_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Opacity (O) modification
|
||||
*/
|
||||
class o_modification : public modification
|
||||
{
|
||||
public:
|
||||
o_modification(float opacity)
|
||||
: opacity_(opacity)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
float get_opacity() const;
|
||||
|
||||
private:
|
||||
float opacity_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Color-shift (CS, R, G, B) modification.
|
||||
*/
|
||||
class cs_modification : public modification
|
||||
{
|
||||
public:
|
||||
cs_modification(int r, int g, int b)
|
||||
: r_(r), g_(g), b_(b)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
int get_r() const;
|
||||
int get_g() const;
|
||||
int get_b() const;
|
||||
|
||||
private:
|
||||
int r_, g_, b_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gaussian-like blur (BL) modification.
|
||||
*/
|
||||
class bl_modification : public modification
|
||||
{
|
||||
public:
|
||||
bl_modification(int depth)
|
||||
: depth_(depth)
|
||||
{}
|
||||
virtual surface operator()(const surface& src) const;
|
||||
int get_depth() const;
|
||||
|
||||
private:
|
||||
int depth_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overlay with ToD brightening (BRIGHTEN).
|
||||
*/
|
||||
struct brighten_modification : modification
|
||||
{
|
||||
virtual surface operator()(const surface &src) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overlay with ToD darkening (DARKEN).
|
||||
*/
|
||||
struct darken_modification : modification
|
||||
{
|
||||
virtual surface operator()(const surface &src) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fill background with a color (BG).
|
||||
*/
|
||||
struct background_modification : modification
|
||||
{
|
||||
background_modification(SDL_Color const &c): color_(c) {}
|
||||
virtual surface operator()(const surface &src) const;
|
||||
const SDL_Color& get_color() const;
|
||||
|
||||
private:
|
||||
SDL_Color color_;
|
||||
};
|
||||
|
||||
} /* end namespace image */
|
||||
|
||||
#endif /* !defined(IMAGE_MODIFICATIONS_HPP_INCLUDED) */
|
||||
|
|
|
@ -120,7 +120,7 @@ private:
|
|||
};
|
||||
} // anonymous namespace
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(image_modification_parsing, environment_setup)
|
||||
BOOST_AUTO_TEST_SUITE(image_modification_parsing)
|
||||
|
||||
/** Tests if modifications with a higher priority are placed before the others
|
||||
*
|
||||
|
@ -130,6 +130,8 @@ BOOST_FIXTURE_TEST_SUITE(image_modification_parsing, environment_setup)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_modificaiton_queue_order)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue;
|
||||
modification* low_priority_mod = new fl_modification();
|
||||
modification* high_priority_mod = new rc_modification();
|
||||
|
@ -162,6 +164,8 @@ BOOST_AUTO_TEST_CASE(test_modificaiton_queue_order)
|
|||
/// Tests if the TC modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_tc_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~TC(1,blue)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -184,6 +188,8 @@ BOOST_AUTO_TEST_CASE(test_tc_modification_decoding)
|
|||
/// Tests if the TC modification with invalid arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_tc_modification_decoding_invalid_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~TC()~TC(1)~TC(0,blue)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 0);
|
||||
|
@ -192,6 +198,8 @@ BOOST_AUTO_TEST_CASE(test_tc_modification_decoding_invalid_args)
|
|||
/// Tests if the RC modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_rc_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~RC(red>blue)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -213,6 +221,8 @@ BOOST_AUTO_TEST_CASE(test_rc_modification_decoding)
|
|||
/// Tests if the RC modification with invalid arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_rc_modification_decoding_invalid_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~RC()~RC(blue)~RC(>)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 0);
|
||||
|
@ -221,6 +231,8 @@ BOOST_AUTO_TEST_CASE(test_rc_modification_decoding_invalid_args)
|
|||
/// Tests if the PAL modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_pal_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue =
|
||||
modification::decode("~PAL(000000,005000 > FFFFFF,FF00FF)");
|
||||
|
||||
|
@ -236,6 +248,8 @@ BOOST_AUTO_TEST_CASE(test_pal_modification_decoding)
|
|||
std::map<Uint32, Uint32> expected;
|
||||
|
||||
for(size_t i = 0; i < old_palette.size() && i < new_palette.size(); ++i) {
|
||||
environment_setup env_setup;
|
||||
|
||||
expected[old_palette[i]] = new_palette[i];
|
||||
}
|
||||
|
||||
|
@ -247,6 +261,8 @@ BOOST_AUTO_TEST_CASE(test_pal_modification_decoding)
|
|||
/// Tests if the PAL modification with invalid arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_pal_modification_decoding_invalid_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue =
|
||||
modification::decode("~PAL()~PAL(>)");
|
||||
|
||||
|
@ -256,6 +272,8 @@ BOOST_AUTO_TEST_CASE(test_pal_modification_decoding_invalid_args)
|
|||
/// Tests if the FL modification is correctly decoded without arguments
|
||||
BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_default)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~FL()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -274,6 +292,8 @@ BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_default)
|
|||
/// Tests if the FL modification is correctly decoded with the horiz argument
|
||||
BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_horiz)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~FL(horiz)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -292,6 +312,8 @@ BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_horiz)
|
|||
/// Tests if the FL modification is correctly decoded with the vert argument
|
||||
BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_vert)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~FL(vert)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -310,6 +332,8 @@ BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_vert)
|
|||
/// Tests if the FL modification is correctly decoded with both horiz and vert
|
||||
BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_horiz_and_vert)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~FL(horiz,vert)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -328,6 +352,8 @@ BOOST_AUTO_TEST_CASE(test_fl_modification_decoding_horiz_and_vert)
|
|||
/// Tests if the GS modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_gs_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~GS()");
|
||||
|
||||
BOOST_REQUIRE(queue.size() == 1);
|
||||
|
@ -343,6 +369,8 @@ BOOST_AUTO_TEST_CASE(test_gs_modification_decoding)
|
|||
/// Tests if the CROP modification without arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~CROP()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 0);
|
||||
|
@ -351,6 +379,8 @@ BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_no_args)
|
|||
/// Tests if the CROP modification is correctly decoded when given one argument
|
||||
BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~CROP(1)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -373,6 +403,8 @@ BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_1_arg)
|
|||
/// Tests if the CROP modification is correctly decoded when given two args
|
||||
BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_2_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~CROP(1,2)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -395,6 +427,8 @@ BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_2_args)
|
|||
/// Tests if the CROP modification is correctly decoded when given three args
|
||||
BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_3_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~CROP(1,2,3)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -417,6 +451,8 @@ BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_3_args)
|
|||
/// Tests if the CROP modification is correctly decoded when given four args
|
||||
BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_4_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~CROP(1,2,3,4)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -442,6 +478,8 @@ BOOST_AUTO_TEST_CASE(test_crop_modification_decoding_4_args)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BLIT(wesnoth-icon.png)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -464,6 +502,8 @@ BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_1_arg)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_3_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BLIT(wesnoth-icon.png,1,2)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -483,6 +523,8 @@ BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_3_args)
|
|||
/// Tests if the BLIT modification with invalid arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_invalid_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue =
|
||||
modification::decode("~BLIT()"
|
||||
"~BLIT(wesnoth-icon.png,1,-2)"
|
||||
|
@ -498,6 +540,8 @@ BOOST_AUTO_TEST_CASE(test_blit_modification_decoding_invalid_args)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~MASK(wesnoth-icon.png)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -520,6 +564,8 @@ BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_1_arg)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_3_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~MASK(wesnoth-icon.png,3,4)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -539,6 +585,8 @@ BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_3_args)
|
|||
/// Tests if the MASK modification with invalid arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_invalid_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue =
|
||||
modification::decode("~MASK()"
|
||||
"~MASK(wesnoth-icon.png,3,-4)"
|
||||
|
@ -551,6 +599,8 @@ BOOST_AUTO_TEST_CASE(test_mask_modification_decoding_invalid_args)
|
|||
/// Tests if the L modification without arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_l_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~L()");
|
||||
|
||||
BOOST_CHECK_EQUAL(queue.size(), 0);
|
||||
|
@ -562,6 +612,8 @@ BOOST_AUTO_TEST_CASE(test_l_modification_decoding_no_args)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(test_l_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~L(wesnoth-icon.png)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -579,6 +631,8 @@ BOOST_AUTO_TEST_CASE(test_l_modification_decoding_1_arg)
|
|||
/// Tests if the SCALE modification without arguments is ignored
|
||||
BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~SCALE()");
|
||||
|
||||
BOOST_CHECK_EQUAL(queue.size(), 0);
|
||||
|
@ -587,6 +641,8 @@ BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_no_args)
|
|||
/// Tests if the SCALE modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~SCALE(3)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -605,6 +661,8 @@ BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_1_arg)
|
|||
/// Tests if the SCALE modification with two arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_2_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~SCALE(4,5)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -623,6 +681,8 @@ BOOST_AUTO_TEST_CASE(test_scale_modification_decoding_2_args)
|
|||
/// Tests if the O modification with a percent argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_o_modification_decoding_percent_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~O(45%)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -632,7 +692,8 @@ BOOST_AUTO_TEST_CASE(test_o_modification_decoding_percent_args)
|
|||
// The dynamic_cast returns NULL if the argument doesn't match the type
|
||||
BOOST_REQUIRE(mod != NULL);
|
||||
|
||||
BOOST_CHECK_CLOSE(mod->get_opacity(), 0.45, 0.01);
|
||||
BOOST_CHECK(mod->get_opacity() > 0.44);
|
||||
BOOST_CHECK(mod->get_opacity() < 0.46);
|
||||
|
||||
delete mod;
|
||||
}
|
||||
|
@ -640,6 +701,8 @@ BOOST_AUTO_TEST_CASE(test_o_modification_decoding_percent_args)
|
|||
/// Tests if the O modification with a fraction argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_o_modification_decoding_fraction_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~O(0.34)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -649,7 +712,8 @@ BOOST_AUTO_TEST_CASE(test_o_modification_decoding_fraction_args)
|
|||
// The dynamic_cast returns NULL if the argument doesn't match the type
|
||||
BOOST_REQUIRE(mod != NULL);
|
||||
|
||||
BOOST_CHECK_CLOSE(mod->get_opacity(), 0.34, 0.01);
|
||||
BOOST_CHECK(mod->get_opacity() > 0.33);
|
||||
BOOST_CHECK(mod->get_opacity() < 0.35);
|
||||
|
||||
delete mod;
|
||||
}
|
||||
|
@ -657,6 +721,8 @@ BOOST_AUTO_TEST_CASE(test_o_modification_decoding_fraction_args)
|
|||
/// Tests if the BL modification without arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bl_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BL()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -674,6 +740,8 @@ BOOST_AUTO_TEST_CASE(test_bl_modification_decoding_no_args)
|
|||
/// Tests if the BL modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bl_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BL(2)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -691,11 +759,15 @@ BOOST_AUTO_TEST_CASE(test_bl_modification_decoding)
|
|||
/// Tests if the R, G and B modifications without args are correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_rgb_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~R()~G()~B()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 3);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
environment_setup env_setup;
|
||||
|
||||
cs_modification* mod = dynamic_cast<cs_modification*>(queue.top());
|
||||
|
||||
// The dynamic_cast returns NULL if the argument doesn't match the type
|
||||
|
@ -714,6 +786,8 @@ BOOST_AUTO_TEST_CASE(test_rgb_modification_decoding_no_args)
|
|||
/// Tests if the R modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_r_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~R(123)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -733,6 +807,8 @@ BOOST_AUTO_TEST_CASE(test_r_modification_decoding)
|
|||
/// Tests if the G modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_g_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~G(132)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -752,6 +828,8 @@ BOOST_AUTO_TEST_CASE(test_g_modification_decoding)
|
|||
/// Tests if the B modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_b_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~B(312)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -771,6 +849,8 @@ BOOST_AUTO_TEST_CASE(test_b_modification_decoding)
|
|||
/// Tests if the BRIGHTEN modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_brighten_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BRIGHTEN()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -786,6 +866,8 @@ BOOST_AUTO_TEST_CASE(test_brighten_modification_decoding)
|
|||
/// Tests if the DARKEN modification is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_draken_modification_decoding)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~DARKEN()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -801,6 +883,8 @@ BOOST_AUTO_TEST_CASE(test_draken_modification_decoding)
|
|||
/// Tests if the BG modification without arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_no_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BG()");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -821,6 +905,8 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_no_args)
|
|||
/// Tests if the BG modification with one argument is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_1_arg)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BG(1)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -841,6 +927,8 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_1_arg)
|
|||
/// Tests if the BG modification with two arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_2_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BG(1,2)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -861,6 +949,8 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_2_args)
|
|||
/// Tests if the BG modification with three arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_3_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BG(1,2,3)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
@ -881,6 +971,8 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_3_args)
|
|||
/// Tests if the BG modification with four arguments is correctly decoded
|
||||
BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_4_args)
|
||||
{
|
||||
environment_setup env_setup;
|
||||
|
||||
modification_queue queue = modification::decode("~BG(1,2,3,4)");
|
||||
|
||||
BOOST_REQUIRE_EQUAL(queue.size(), 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue