| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This program is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | // enable in php 7
|
|---|
| 20 | // declare(Strict_types=1);
|
|---|
| 21 |
|
|---|
| 22 | /**
|
|---|
| 23 | * @brief Covers Nmea0183Dpt.php
|
|---|
| 24 | */
|
|---|
| 25 | final class Nmea0183DptTest extends PHPUnit_Framework_TestCase
|
|---|
| 26 | {
|
|---|
| 27 | /**
|
|---|
| 28 | * @dataProvider dptProvider
|
|---|
| 29 | */
|
|---|
| 30 | public function testDpt($sentence, $talker, $type, $depth, $offset, $checksum, $valid)
|
|---|
| 31 | {
|
|---|
| 32 | $parser = new GnuBoat\Nmea\Parser(0);
|
|---|
| 33 | $sentence = $parser->parseSentence($sentence, "0183");
|
|---|
| 34 | $this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Dpt::class, $sentence);
|
|---|
| 35 | $this->assertEquals($talker, $sentence->talker());
|
|---|
| 36 | $this->assertEquals($type, $sentence->type());
|
|---|
| 37 | $this->assertEquals($depth, $sentence->depth());
|
|---|
| 38 | $this->assertEquals($offset, $sentence->offset());
|
|---|
| 39 | $this->assertEquals($checksum, $sentence->checksum());
|
|---|
| 40 | $message = "";
|
|---|
| 41 | $result = $sentence->valid($message);
|
|---|
| 42 | $this->assertEquals($valid, $result, $message);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | public function dptProvider()
|
|---|
| 46 | {
|
|---|
| 47 | return [
|
|---|
| 48 | "wrong_data_count" => ['$SDDPT,00.71,00.71,00.00*51', 'SD', 'dpt', 0, 0, 51, false],
|
|---|
| 49 | "wrong_checksum" => ['$SDDPT,00.71,00.00*22', 'SD', 'dpt', 0.71, 0.0, 22, false],
|
|---|
| 50 | "valid1" => ['$SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
|
|---|
| 51 | "valid2" => ['!SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
|
|---|
| 52 | ];
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | ?>
|
|---|