Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Sep 2, 2024
1 parent 0d6687c commit 25edebb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
45 changes: 45 additions & 0 deletions tests/DataStructure/KVPairTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Typhoon\DataStructure;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(KVPair::class)]
final class KVPairTest extends TestCase
{
public function testWithKey(): void
{
$kv = new KVPair('k', 'v');

$newKv = $kv->withKey('k2');

self::assertNotSame($kv, $newKv);
self::assertSame('k2', $newKv->key);
self::assertSame('v', $newKv->value);
}

public function testWithValue(): void
{
$kv = new KVPair('k', 'v');

$newKv = $kv->withValue('v2');

self::assertNotSame($kv, $newKv);
self::assertSame('k', $newKv->key);
self::assertSame('v2', $newKv->value);
}

public function testFlip(): void
{
$kv = new KVPair('k', 'v');

$newKv = $kv->flip();

self::assertNotSame($kv, $newKv);
self::assertSame('v', $newKv->key);
self::assertSame('k', $newKv->value);
}
}
2 changes: 0 additions & 2 deletions tests/DataStructure/MapTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ final public function testGetReturnsDefaultIfKeyDoesNotExist(): void

$value = $map->get(1, 'NO KEY');

/** @psalm-suppress RedundantConditionGivenDocblockType */
self::assertSame('NO KEY', $value);
}

Expand Down Expand Up @@ -408,7 +407,6 @@ final public function testReduceReturnsFirstValueIfSingleElementMap(): void

$value = $map->reduceKV(static fn(): never => self::fail());

/** @psalm-suppress RedundantConditionGivenDocblockType */
self::assertSame('a', $value);
}

Expand Down

0 comments on commit 25edebb

Please sign in to comment.