LCOV - code coverage report
Current view: top level - tests - test_as2js_options.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 15 15 100.0 %
Date: 2014-11-22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* test_as2js_options.cpp -- written by Alexis WILKE for Made to Order Software Corp. (c) 2005-2014 */
       2             : 
       3             : /*
       4             : 
       5             : Copyright (c) 2005-2014 Made to Order Software Corp.
       6             : 
       7             : http://snapwebsites.org/project/as2js
       8             : 
       9             : Permission is hereby granted, free of charge, to any
      10             : person obtaining a copy of this software and
      11             : associated documentation files (the "Software"), to
      12             : deal in the Software without restriction, including
      13             : without limitation the rights to use, copy, modify,
      14             : merge, publish, distribute, sublicense, and/or sell
      15             : copies of the Software, and to permit persons to whom
      16             : the Software is furnished to do so, subject to the
      17             : following conditions:
      18             : 
      19             : The above copyright notice and this permission notice
      20             : shall be included in all copies or substantial
      21             : portions of the Software.
      22             : 
      23             : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
      24             : ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
      25             : LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
      26             : FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
      27             : EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
      28             : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      29             : WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      30             : ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      31             : SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      32             : SOFTWARE.
      33             : 
      34             : */
      35             : 
      36             : #include    "test_as2js_options.h"
      37             : #include    "test_as2js_main.h"
      38             : 
      39             : #include    "as2js/options.h"
      40             : #include    "as2js/exceptions.h"
      41             : 
      42             : #include    <cstring>
      43             : #include    <algorithm>
      44             : 
      45             : #include    <cppunit/config/SourcePrefix.h>
      46           4 : CPPUNIT_TEST_SUITE_REGISTRATION( As2JsOptionsUnitTests );
      47             : 
      48             : 
      49             : 
      50             : 
      51             : 
      52           1 : void As2JsOptionsUnitTests::test_options()
      53             : {
      54           1 :     as2js::Options::pointer_t opt(new as2js::Options);
      55             : 
      56             :     // verify that all options are set to zero by default
      57          14 :     for(as2js::Options::option_t o(as2js::Options::option_t::OPTION_UNKNOWN); o < as2js::Options::option_t::OPTION_max; o = static_cast<as2js::Options::option_t>(static_cast<int>(o) + 1))
      58             :     {
      59          13 :         CPPUNIT_ASSERT(opt->get_option(o) == 0);
      60             :     }
      61             : 
      62          14 :     for(as2js::Options::option_t o(as2js::Options::option_t::OPTION_UNKNOWN); o < as2js::Options::option_t::OPTION_max; o = static_cast<as2js::Options::option_t>(static_cast<int>(o) + 1))
      63             :     {
      64        1313 :         for(int i(0); i < 100; ++i)
      65             :         {
      66        1300 :             int64_t value((static_cast<int64_t>(rand()) << 48)
      67        1300 :                         ^ (static_cast<int64_t>(rand()) << 32)
      68        1300 :                         ^ (static_cast<int64_t>(rand()) << 16)
      69        1300 :                         ^ (static_cast<int64_t>(rand()) <<  0));
      70        1300 :             opt->set_option(o, value);
      71        1300 :             CPPUNIT_ASSERT(opt->get_option(o) == value);
      72             :         }
      73           1 :     }
      74          13 : }
      75             : 
      76             : 
      77             : 
      78             : 
      79             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.10