| [86442cb] | 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 Nmea0183Mtw.php
|
|---|
| 24 | */
|
|---|
| 25 | final class Nmea0183MtwTest extends PHPUnit_Framework_TestCase
|
|---|
| 26 | {
|
|---|
| 27 | /**
|
|---|
| 28 | * @dataProvider mtwProvider
|
|---|
| 29 | */
|
|---|
| 30 | public function testMtw($sentence, $talker, $type, $temperature, $unit, $checksum, $valid)
|
|---|
| 31 | {
|
|---|
| 32 | $parser = new GnuBoat\Nmea\Parser(0);
|
|---|
| 33 | $sentence = $parser->parseSentence($sentence, "0183");
|
|---|
| 34 | $this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Mtw::class, $sentence);
|
|---|
| 35 | $this->assertEquals($talker, $sentence->talker());
|
|---|
| 36 | $this->assertEquals($type, $sentence->type());
|
|---|
| 37 | $this->assertEquals($temperature, $sentence->temperature());
|
|---|
| 38 | $this->assertEquals($unit, $sentence->unit());
|
|---|
| 39 | $this->assertEquals($checksum, $sentence->checksum());
|
|---|
| 40 | $message = "";
|
|---|
| 41 | $result = $sentence->valid($message);
|
|---|
| 42 | $this->assertEquals($valid, $result, $message);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | public function mtwProvider()
|
|---|
| 46 | {
|
|---|
| 47 | return [
|
|---|
| 48 | "wrong_data_count" => ['$YXMTW,C*15', 'YX', 'MTW', 0, '', 15, false],
|
|---|
| 49 | "wrong_checksum" => ['$YXMTW,26.3,C*22', 'YX', 'MTW', 26.3, 'C', 22, false],
|
|---|
| 50 | "valid1" => ['$YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
|
|---|
| 51 | "valid2" => ['!YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
|
|---|
| 52 | ];
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | ?>
|
|---|