DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

Point.cpp (3092B)


      1 /*
      2  * DISTRHO Plugin Framework (DPF)
      3  * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
      4  *
      5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
      6  * or without fee is hereby granted, provided that the above copyright notice and this
      7  * permission notice appear in all copies.
      8  *
      9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
     10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
     11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
     12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
     13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
     14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     15  */
     16 
     17 #include "tests.hpp"
     18 
     19 #define DPF_TEST_POINT_CPP
     20 #include "dgl/src/Geometry.cpp"
     21 
     22 // --------------------------------------------------------------------------------------------------------------------
     23 
     24 template <typename T>
     25 static int runTestsPerType()
     26 {
     27     USE_NAMESPACE_DGL;
     28 
     29     // basic usage
     30     {
     31         Point<T> p;
     32         DISTRHO_ASSERT_EQUAL(p.getX(), 0, "point start X value is 0");
     33         DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value is 0");
     34         DISTRHO_ASSERT_EQUAL(p.isZero(), true, "point start is zero");
     35         DISTRHO_ASSERT_EQUAL(p.isNotZero(), false, "point start is for sure zero");
     36 
     37         p.setX(5);
     38         DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value changed to 5");
     39         DISTRHO_ASSERT_EQUAL(p.getY(), 0, "point start Y value remains 0");
     40         DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X is not zero");
     41         DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X is for sure not zero");
     42 
     43         p.setY(7);
     44         DISTRHO_ASSERT_EQUAL(p.getX(), 5, "point X value remains 5");
     45         DISTRHO_ASSERT_EQUAL(p.getY(), 7, "point Y value changed to 7");
     46         DISTRHO_ASSERT_EQUAL(p.isZero(), false, "point after custom X and Y is not zero");
     47         DISTRHO_ASSERT_EQUAL(p.isNotZero(), true, "point after custom X and Y is for sure not zero");
     48 
     49         // TODO everything else
     50     }
     51 
     52     return 0;
     53 }
     54 
     55 int main()
     56 {
     57     if (const int ret = runTestsPerType<double>())
     58         return ret;
     59 
     60     if (const int ret = runTestsPerType<float>())
     61         return ret;
     62 
     63     if (const int ret = runTestsPerType<int>())
     64         return ret;
     65 
     66     if (const int ret = runTestsPerType<uint>())
     67         return ret;
     68 
     69     if (const int ret = runTestsPerType<short>())
     70         return ret;
     71 
     72     if (const int ret = runTestsPerType<ushort>())
     73         return ret;
     74 
     75     if (const int ret = runTestsPerType<long>())
     76         return ret;
     77 
     78     if (const int ret = runTestsPerType<ulong>())
     79         return ret;
     80 
     81     if (const int ret = runTestsPerType<long long>())
     82         return ret;
     83 
     84     if (const int ret = runTestsPerType<unsigned long long>())
     85         return ret;
     86 
     87     return 0;
     88 }
     89 
     90 // --------------------------------------------------------------------------------------------------------------------