3 namespace Tests\Unit\Models;
5 use App\Models\ChatLib;
6 use PHPUnit\Framework\TestCase;
8 class ChatLibTest extends TestCase {
10 public function test_binary_search() {
17 $this->assertEquals('a', ChatLib::search($options, 0)[0]);
18 $this->assertEquals('a', ChatLib::search($options, 1)[0]);
19 $this->assertEquals('b', ChatLib::search($options, 2)[0]);
20 $this->assertEquals('c', ChatLib::search($options, 3)[0]);
21 $this->assertEquals('c', ChatLib::search($options, 4)[0]);
22 $this->assertEquals('c', ChatLib::search($options, 5)[0]);
24 $this->assertEquals('a', ChatLib::search($options, -1)[0]);
25 $this->assertEquals('c', ChatLib::search($options, 6)[0]);