diff --git a/source/styles/fill.cpp b/source/styles/fill.cpp index fc46d38b..30cd185b 100644 --- a/source/styles/fill.cpp +++ b/source/styles/fill.cpp @@ -178,9 +178,9 @@ std::string fill::to_hash_string() const hash_string.append(end_color_ ? "1" : "0"); - if (start_color_) + if (end_color_) { - hash_string.append(std::to_string(background_color_->hash())); + hash_string.append(std::to_string(end_color_->hash())); } break; diff --git a/source/styles/tests/test_fill.hpp b/source/styles/tests/test_fill.hpp index bc345fd9..25834d9d 100644 --- a/source/styles/tests/test_fill.hpp +++ b/source/styles/tests/test_fill.hpp @@ -40,6 +40,12 @@ public: TS_ASSERT_EQUALS(fill.get_gradient_left(), 0); TS_ASSERT_EQUALS(fill.get_gradient_top(), 0); TS_ASSERT_EQUALS(fill.get_gradient_right(), 0); + + const auto &const_fill = fill; + TS_ASSERT(const_fill.get_foreground_color()); + TS_ASSERT(const_fill.get_background_color()); + TS_ASSERT(const_fill.get_start_color()); + TS_ASSERT(const_fill.get_end_color()); } void test_hash() @@ -52,12 +58,20 @@ public: xlnt::fill pattern_fill; pattern_fill.set_type(xlnt::fill::type::pattern); - xlnt::fill gradient_fill; - gradient_fill.set_type(xlnt::fill::type::gradient); + xlnt::fill gradient_fill_linear; + gradient_fill_linear.set_type(xlnt::fill::type::gradient); + gradient_fill_linear.set_gradient_type(xlnt::fill::gradient_type::linear); + + xlnt::fill gradient_fill_path; + gradient_fill_path.set_type(xlnt::fill::type::gradient); + gradient_fill_path.set_gradient_type(xlnt::fill::gradient_type::linear); + gradient_fill_path.set_start_color(xlnt::color::red()); + gradient_fill_path.set_end_color(xlnt::color::green()); TS_ASSERT_DIFFERS(none_fill.hash(), solid_fill.hash()); TS_ASSERT_DIFFERS(solid_fill.hash(), pattern_fill.hash()); - TS_ASSERT_DIFFERS(pattern_fill.hash(), gradient_fill.hash()); - TS_ASSERT_DIFFERS(gradient_fill.hash(), none_fill.hash()); + TS_ASSERT_DIFFERS(pattern_fill.hash(), gradient_fill_linear.hash()); + TS_ASSERT_DIFFERS(gradient_fill_linear.hash(), gradient_fill_path.hash()); + TS_ASSERT_DIFFERS(gradient_fill_path.hash(), none_fill.hash()); } };