PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - intl/collator - collator_attr.c
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 33
Code covered: 75.8 % Executed lines: 25
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | This source file is subject to version 3.01 of the PHP license,      |
       6                 :    | that is bundled with this package in the file LICENSE, and is        |
       7                 :    | available through the world-wide-web at the following url:           |
       8                 :    | http://www.php.net/license/3_01.txt                                  |
       9                 :    | If you did not receive a copy of the PHP license and are unable to   |
      10                 :    | obtain it through the world-wide-web, please send a note to          |
      11                 :    | license@php.net so we can mail you a copy immediately.               |
      12                 :    +----------------------------------------------------------------------+
      13                 :    | Authors: Vadim Savchuk <vsavchuk@productengine.com>                  |
      14                 :    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
      15                 :    +----------------------------------------------------------------------+
      16                 :  */
      17                 : 
      18                 : #ifdef HAVE_CONFIG_H
      19                 : #include "config.h"
      20                 : #endif
      21                 : 
      22                 : #include "php_intl.h"
      23                 : #include "collator_class.h"
      24                 : #include "collator_convert.h"
      25                 : #include "collator_attr.h"
      26                 : 
      27                 : #include <unicode/ustring.h>
      28                 : 
      29                 : /* {{{ proto int Collator::getAttribute( int $attr )
      30                 :  * Get collation attribute value. }}} */
      31                 : /* {{{ proto int collator_get_attribute( Collator $coll, int $attr )
      32                 :  * Get collation attribute value.
      33                 :  */
      34                 : PHP_FUNCTION( collator_get_attribute )
      35              12 : {
      36                 :         long attribute, value;
      37                 : 
      38              12 :         COLLATOR_METHOD_INIT_VARS
      39                 : 
      40                 :         /* Parse parameters. */
      41              12 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
      42                 :                 &object, Collator_ce_ptr, &attribute ) == FAILURE )
      43                 :         {
      44               0 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      45                 :                         "collator_get_attribute: unable to parse input params", 0 TSRMLS_CC );
      46                 : 
      47               0 :                 RETURN_FALSE;
      48                 :         }
      49                 : 
      50                 :         /* Fetch the object. */
      51              12 :         COLLATOR_METHOD_FETCH_OBJECT;
      52                 : 
      53              12 :         value = ucol_getAttribute( co->ucoll, attribute, COLLATOR_ERROR_CODE_P( co ) );
      54              12 :         COLLATOR_CHECK_STATUS( co, "Error getting attribute value" );
      55                 : 
      56               8 :         RETURN_LONG( value );
      57                 : }
      58                 : /* }}} */
      59                 : 
      60                 : /* {{{ proto bool Collator::getAttribute( int $attr )
      61                 :  * Get collation attribute value. }}} */
      62                 : /* {{{ proto bool collator_set_attribute( Collator $coll, int $attr, int $val )
      63                 :  * Set collation attribute.
      64                 :  */
      65                 : PHP_FUNCTION( collator_set_attribute )
      66               8 : {
      67                 :         long attribute, value;
      68               8 :         COLLATOR_METHOD_INIT_VARS
      69                 : 
      70                 : 
      71                 :         /* Parse parameters. */
      72               8 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll",
      73                 :                 &object, Collator_ce_ptr, &attribute, &value ) == FAILURE)
      74                 :         {
      75               0 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      76                 :                          "collator_set_attribute: unable to parse input params", 0 TSRMLS_CC );
      77                 : 
      78               0 :                 RETURN_FALSE;
      79                 :         }
      80                 : 
      81                 :         /* Fetch the object. */
      82               8 :         COLLATOR_METHOD_FETCH_OBJECT;
      83                 : 
      84                 :         /* Set new value for the given attribute. */
      85               8 :         ucol_setAttribute( co->ucoll, attribute, value, COLLATOR_ERROR_CODE_P( co ) );
      86               8 :         COLLATOR_CHECK_STATUS( co, "Error setting attribute value" );
      87                 : 
      88               8 :         RETURN_TRUE;
      89                 : }
      90                 : /* }}} */
      91                 : 
      92                 : /* {{{ proto int Collator::getStrength()
      93                 :  * Returns the current collation strength. }}} */
      94                 : /* {{{ proto int collator_get_strength(Collator coll)
      95                 :  * Returns the current collation strength.
      96                 :  */
      97                 : PHP_FUNCTION( collator_get_strength )
      98               6 : {
      99               6 :         COLLATOR_METHOD_INIT_VARS
     100                 : 
     101                 :         /* Parse parameters. */
     102               6 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
     103                 :                 &object, Collator_ce_ptr ) == FAILURE )
     104                 :         {
     105               0 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
     106                 :                          "collator_get_strength: unable to parse input params", 0 TSRMLS_CC );
     107                 : 
     108               0 :                 RETURN_FALSE;
     109                 :         }
     110                 : 
     111                 :         /* Fetch the object. */
     112               6 :         COLLATOR_METHOD_FETCH_OBJECT;
     113                 : 
     114                 :         /* Get current strength and return it. */
     115               6 :         RETURN_LONG( ucol_getStrength( co->ucoll ) );
     116                 : }
     117                 : /* }}} */
     118                 : 
     119                 : /* {{{ proto bool Collator::setStrength(int strength)
     120                 :  * Set the collation strength. }}} */
     121                 : /* {{{ proto bool collator_set_strength(Collator coll, int strength)
     122                 :  * Set the collation strength.
     123                 :  */
     124                 : PHP_FUNCTION( collator_set_strength )
     125              10 : {
     126                 :         long strength;
     127                 : 
     128              10 :         COLLATOR_METHOD_INIT_VARS
     129                 : 
     130                 :         /* Parse parameters. */
     131              10 :         if( zend_parse_method_parameters( ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol",
     132                 :                 &object, Collator_ce_ptr, &strength ) == FAILURE )
     133                 :         {
     134               0 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
     135                 :                          "collator_set_strength: unable to parse input params", 0 TSRMLS_CC );
     136                 : 
     137               0 :                 RETURN_FALSE;
     138                 :         }
     139                 : 
     140                 :         /* Fetch the object. */
     141              10 :         COLLATOR_METHOD_FETCH_OBJECT;
     142                 : 
     143                 :         /* Set given strength. */
     144              10 :         ucol_setStrength( co->ucoll, strength );
     145                 : 
     146              10 :         RETURN_TRUE;
     147                 : }
     148                 : /* }}} */
     149                 : 
     150                 : /*
     151                 :  * Local variables:
     152                 :  * tab-width: 4
     153                 :  * c-basic-offset: 4
     154                 :  * End:
     155                 :  * vim600: noet sw=4 ts=4 fdm=marker
     156                 :  * vim<600: noet sw=4 ts=4
     157                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:27:01 +0000 (3 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.