public function testAddSeparator() { $sc = new StringCalculator(); $result = $sc->add('1,2,3'); $this->assertEquals(6, $result); $result = $sc->add('1\\n2,3'); $this->assertEquals(6, $result); $result = $sc->add('1\\n2\\n3,4\\n5'); $this->assertEquals(15, $result); $result = $sc->add('//;\\n1;2;3;4'); $this->assertEquals(10, $result); $result = $sc->add('//k\\n1k2,3\\n4k66'); $this->assertEquals(76, $result); }
/** * Test for the 1,3,2000 scenario */ public function testAddBigNumber() { // Arrange $simpleTest = new StringCalculator(); // Test cases $expected = "4"; $result = $simpleTest->Add("1,3,2000"); // Assert $this->assertEquals($expected, $result); }
/** * @test * @dataProvider provider_for_add_ko */ public function add_will_throw_an_exception_if_the§_format_is_wrong($string) { $stringCalculator = new StringCalculator(); $this->setExpectedException(\Exception::class); $stringCalculator->add($string); }