<commit_before><?php
namespace IPv4;

// Precalculated constants for network 192.168.112.203/23.
const IP_ADDRESS               = '192.168.112.203';
const NETWORK_SIZE             = 23;
const NUMBER_IP_ADDRESSES      = 512;
const NUMBER_ADDRESSABLE_HOSTS = 510;
const LOWER_IP_ADDRESS_RANGE   = '192.168.112.0';
const UPPER_IP_ADDRESS_RANGE   = '192.168.113.255';
const BROADCAST_ADDRESS        = '192.168.113.255';
const IP_ADDRESS_HEX           = 'C0A870CB';
const IP_ADDRESS_BINARY        = '11000000101010000111000011001011';
const SUBNET_MASK              = '255.255.254.0';
const SUBNET_MASK_HEX          = 'FFFFFE00';
const SUBNET_MASK_BINARY       = '11111111111111111111111000000000';
const NETWORK                  = '192.168.112.0';
const NETWORK_HEX              = 'C0A87000';
const NETWORK_BINARY           = '11000000101010000111000000000000';
const HOST                     = '0.0.0.203';
const HOST_HEX                 = '000000CB';
const HOST_BINARY              = '00000000000000000000000011001011';

class SubnetCalculatorTest extends \PHPUnit_Framework_TestCase
{
    
    public function setUp()
    {
        $this->sub = new SubnetCalculator('192.168.112.203', 23);
    }

    public function testGetIPAddress()
    {
        $this->assertEquals($this->sub->getIPAddress(), IP_ADDRESS);
    }

    public function testGetNetworkSize()
    {
        $this->assertEquals($this->sub->getNetworkSize(), NETWORK_SIZE);
    }

    public function testGetNumberIPAddresses()
    {
        $this->assertEquals($this->sub->getNumberIPAddresses(), NUMBER_IP_ADDRESSES);
    }

    public function testGetNumberAddressableHosts()
    {
        $this->assertEquals($this->sub->getNumberAddressableHosts(), NUMBER_ADDRESSABLE_HOSTS);
    }

    public function testGetIPAddressRange()
    {
        $this->assertEquals($this->sub->getIPAddressRange()[0], LOWER_IP_ADDRESS_RANGE);
        $this->assertEquals($this->sub->getIPAddressRange()[1], UPPER_IP_ADDRESS_RANGE);
    }

    public function testGetBroadcastAddress()
    {
        $this->assertEquals($this->sub->getBroadcastAddress(), BROADCAST_ADDRESS);
    }

    public function testGetIPAddressQuads()
    {<commit_msg>Add unit tests.<commit_after><?php
namespace IPv4;

// Precalculated constants for network 192.168.112.203/23.
const IP_ADDRESS               = '192.168.112.203';
const NETWORK_SIZE             = 23;
const NUMBER_IP_ADDRESSES      = 512;
const NUMBER_ADDRESSABLE_HOSTS = 510;
const LOWER_IP_ADDRESS_RANGE   = '192.168.112.0';
const UPPER_IP_ADDRESS_RANGE   = '192.168.113.255';
const BROADCAST_ADDRESS        = '192.168.113.255';
const IP_ADDRESS_HEX           = 'C0A870CB';
const IP_ADDRESS_BINARY        = '11000000101010000111000011001011';
const SUBNET_MASK              = '255.255.254.0';
const SUBNET_MASK_HEX          = 'FFFFFE00';
const SUBNET_MASK_BINARY       = '11111111111111111111111000000000';
const NETWORK                  = '192.168.112.0';
const NETWORK_HEX              = 'C0A87000';
const NETWORK_BINARY           = '11000000101010000111000000000000';
const HOST                     = '0.0.0.203';
const HOST_HEX                 = '000000CB';
const HOST_BINARY              = '00000000000000000000000011001011';

class SubnetCalculatorTest extends \PHPUnit_Framework_TestCase
{
    
    public function setUp()
    {
        $this->sub = new SubnetCalculator('192.168.112.203', 23);
    }

    public function testGetIPAddress()
    {
        $this->assertEquals($this->sub->getIPAddress(), IP_ADDRESS);
    }

    public function testGetNetworkSize()
    {
        $this->assertEquals($this->sub->getNetworkSize(), NETWORK_SIZE);
    }

    public function testGetNumberIPAddresses()
    {
        $this->assertEquals($this->sub->getNumberIPAddresses(), NUMBER_IP_ADDRESSES);
    }

    public function testGetNumberAddressableHosts()
    {
        $this->assertEquals($this->sub->getNumberAddressableHosts(), NUMBER_ADDRESSABLE_HOSTS);
    }

    public function testGetNumberAddressableHostsEdgeCases()
    {
        $sub = new SubnetCalculator('192.168.112.203', 32);
        $this->assertEquals(1, $sub->getNumberAddressableHosts());

        $sub = new SubnetCalculator('192.168.112.203', 31);
        $this->assertEquals(2, $sub->getNumberAddressableHosts());
    }

    public function testGetIPAddressRange()
    {
        $this->assertEquals($this->sub->getIPAddressRange()[0], LOWER_IP_ADDRESS_RANGE);
        $this->assertEquals($this->sub->getIPAddressRange()[1], UPPER_IP_ADDRESS_RANGE);
    }

    public function testGetBroadcastAddress()
    {
        $this->assertEquals($this->sub->getBroadcastAddress(), BROADCAST_ADDRESS);
    }

    public function testGetIPAddressQuads()
    {
{'fraction_non_alphanumeric': 0.1161605436398386, 'fraction_numerical': 0.11552346570397112, 'mean_word_length': 3.0429184549356223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 20, 'substrings_counts': 8, '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': '4127674', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1449, 'n_words': 233}