1*09dbbe93SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*09dbbe93SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*09dbbe93SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*09dbbe93SAndrew Rist * distributed with this work for additional information 6*09dbbe93SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*09dbbe93SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*09dbbe93SAndrew Rist * "License"); you may not use this file except in compliance 9*09dbbe93SAndrew Rist * with the License. You may obtain a copy of the License at 10*09dbbe93SAndrew Rist * 11*09dbbe93SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*09dbbe93SAndrew Rist * 13*09dbbe93SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*09dbbe93SAndrew Rist * software distributed under the License is distributed on an 15*09dbbe93SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*09dbbe93SAndrew Rist * KIND, either express or implied. See the License for the 17*09dbbe93SAndrew Rist * specific language governing permissions and limitations 18*09dbbe93SAndrew Rist * under the License. 19*09dbbe93SAndrew Rist * 20*09dbbe93SAndrew Rist *************************************************************/ 21*09dbbe93SAndrew Rist 22*09dbbe93SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir 25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 26cdf0e10cSrcweir #include "precompiled_basegfx.hxx" 27cdf0e10cSrcweir // autogenerated file with codegen.pl 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "preextstl.h" 30cdf0e10cSrcweir #include "cppunit/TestAssert.h" 31cdf0e10cSrcweir #include "cppunit/TestFixture.h" 32cdf0e10cSrcweir #include "cppunit/extensions/HelperMacros.h" 33cdf0e10cSrcweir #include "postextstl.h" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <basegfx/tools/keystoplerp.hxx> 36cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <boost/tuple/tuple.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace ::basegfx; 41cdf0e10cSrcweir using namespace ::boost::tuples; 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace basegfxtools 44cdf0e10cSrcweir { 45cdf0e10cSrcweir 46cdf0e10cSrcweir class KeyStopLerpTest : public CppUnit::TestFixture 47cdf0e10cSrcweir { 48cdf0e10cSrcweir tools::KeyStopLerp maKeyStops; 49cdf0e10cSrcweir getTestVector()50cdf0e10cSrcweir static std::vector<double> getTestVector() 51cdf0e10cSrcweir { 52cdf0e10cSrcweir std::vector<double> aStops(3); 53cdf0e10cSrcweir aStops[0] = 0.1; 54cdf0e10cSrcweir aStops[1] = 0.5; 55cdf0e10cSrcweir aStops[2] = 0.9; 56cdf0e10cSrcweir return aStops; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir public: KeyStopLerpTest()60cdf0e10cSrcweir KeyStopLerpTest() : 61cdf0e10cSrcweir maKeyStops(getTestVector()) 62cdf0e10cSrcweir {} 63cdf0e10cSrcweir setUp()64cdf0e10cSrcweir void setUp() 65cdf0e10cSrcweir {} 66cdf0e10cSrcweir tearDown()67cdf0e10cSrcweir void tearDown() 68cdf0e10cSrcweir {} 69cdf0e10cSrcweir test()70cdf0e10cSrcweir void test() 71cdf0e10cSrcweir { 72cdf0e10cSrcweir double fAlpha; 73cdf0e10cSrcweir std::ptrdiff_t nIndex; 74cdf0e10cSrcweir 75cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(-1.0); 76cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("-1.0", nIndex==0 && fAlpha==0.0); 77cdf0e10cSrcweir 78cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(0.1); 79cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.1", nIndex==0 && fAlpha==0.0); 80cdf0e10cSrcweir 81cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(0.3); 82cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.3", nIndex==0 && fTools::equal(fAlpha,0.5)); 83cdf0e10cSrcweir 84cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(0.5); 85cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.5", nIndex==0 && fTools::equal(fAlpha,1.0)); 86cdf0e10cSrcweir 87cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(0.51); 88cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,0.025)); 89cdf0e10cSrcweir 90cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(0.9); 91cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,1.0)); 92cdf0e10cSrcweir 93cdf0e10cSrcweir tie(nIndex,fAlpha) = maKeyStops.lerp(1.0); 94cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fAlpha==1.0); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir // Change the following lines only, if you add, remove or rename 98cdf0e10cSrcweir // member functions of the current class, 99cdf0e10cSrcweir // because these macros are need by auto register mechanism. 100cdf0e10cSrcweir 101cdf0e10cSrcweir CPPUNIT_TEST_SUITE(KeyStopLerpTest); 102cdf0e10cSrcweir CPPUNIT_TEST(test); 103cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END(); 104cdf0e10cSrcweir }; 105cdf0e10cSrcweir 106cdf0e10cSrcweir // ----------------------------------------------------------------------------- 107cdf0e10cSrcweir CPPUNIT_TEST_SUITE_REGISTRATION(basegfxtools::KeyStopLerpTest); 108cdf0e10cSrcweir } // namespace basegfxtools 109