<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'unittest.TestCase',
    'peer.mail.InternetAddress'
  );

  /**
   * Testcase for InternetAddress class
   *
   * @purpose  Testcase
   */
  class InternetAddressTest extends TestCase {

    /**
     * Test construction
     *
     */
    #[@test]
    public function createAddress() {
      $address= new InternetAddress('<EMAIL>');
      $this->assertEquals('kiesel', $address->localpart);
      $this->assertEquals('example.com', $address->domain);
    }
    
    /**
     * Test fromString
     *
     */
    #[@test]
    public function testFromString() {
      $strings= array(
        '<NAME> <<EMAIL>>',
        '<EMAIL> (<NAME>)',
        '"<NAME>" <<EMAIL>>',
        '<EMAIL>',
        '=?iso-8859-1?Q?Alex_Kiesel?= <<EMAIL>>'
      );
      foreach ($strings as $string) {
        $address= InternetAddress::fromString($string);
        $this->assertEquals('kiesel', $address->localpart);
        $this->assertEquals('example.com', $address->domain);
      }
    }

    /**
     * Test escaping
     *
     */
    #[@test]
    public function colonIsEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?I=3A=3ADev?= <<EMAIL>>',
        create(new InternetAddress('<EMAIL>', 'I::Dev'))->toString()
      );
    }

    /**
     * Test escaping
     *
     */
    #[@test]
    public function umlautsAreEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?M=FCcke?= <<EMAIL>>',
        create(new InternetAddress('<EMAIL>', 'Mcke'))->toString()
      );
    }
    
    /**
     * Test escaping
     *
     */
    #[@test]
    public function spaceIsEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?Alex_Kiesel?= <<EMAIL>>', 
        create(new InternetAddress('<EMAIL>', '<NAME>'))->toString()
      );
    }
  }
?><commit_msg>- add test for getAddress() method<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses(
    'unittest.TestCase',
    'peer.mail.InternetAddress'
  );

  /**
   * Testcase for InternetAddress class
   *
   * @purpose  Testcase
   */
  class InternetAddressTest extends TestCase {

    /**
     * Test construction
     *
     */
    #[@test]
    public function createAddress() {
      $address= new InternetAddress('<EMAIL>');
      $this->assertEquals('kiesel', $address->localpart);
      $this->assertEquals('example.com', $address->domain);
    }
    
    /**
     * Test fromString
     *
     */
    #[@test]
    public function testFromString() {
      $strings= array(
        '<NAME> <<EMAIL>>',
        '<EMAIL> (<NAME>)',
        '"<NAME>" <<EMAIL>>',
        '<EMAIL>',
        '=?iso-8859-1?Q?Alex_Kiesel?= <<EMAIL>>'
      );
      foreach ($strings as $string) {
        $address= InternetAddress::fromString($string);
        $this->assertEquals('kiesel', $address->localpart);
        $this->assertEquals('example.com', $address->domain);
      }
    }

    /**
     * Test escaping
     *
     */
    #[@test]
    public function colonIsEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?I=3A=3ADev?= <<EMAIL>>',
        create(new InternetAddress('<EMAIL>', 'I::Dev'))->toString()
      );
    }

    /**
     * Test escaping
     *
     */
    #[@test]
    public function umlautsAreEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?M=FCcke?= <mue<EMAIL>>',
        create(new InternetAddress('<EMAIL>', 'Mcke'))->toString()
      );
    }
    
    /**
     * Test escaping
     *
     */
    #[@test]
    public function spaceIsEscaped() {
      $this->assertEquals(
        '=?iso-8859-1?Q?Alex_Kiesel?= <<EMAIL>>', 
        create(new InternetAddress('<EMAIL>', '<NAME>'))->toString()
      );
    }
    
    /**
     * Test getAddress() method
     *
     */
    #[@test]
    public function addressInRawFormat() {
      $this->assertEquals(
        '<EMAIL>', 
        create(new InternetAddress('<EMAIL>', '<NAME>'))->getAddress()
      );
    }    
  }
?>
{'fraction_non_alphanumeric': 0.18835873095178615, 'fraction_numerical': 0.010991756182862853, 'mean_word_length': 2.160220994475138, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6745864', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1298, 'n_words': 215}