OSDN Git Service

初期コミット
[yubeshi/yubeshi.git] / YubeshiTest / Nmea / PacketTest.cs
1 /*\r
2  *      Yubeshi GPS Parser\r
3  *\r
4  *      This software is distributed under a zlib-style license.\r
5  *      See license.txt for more information.\r
6  */\r
7 \r
8 using System;\r
9 using System.Collections.Generic;\r
10 using System.Text;\r
11 using NUnit.Framework;\r
12 using Yubeshi.Nmea;\r
13 \r
14 namespace YubeshiTest.Nmea\r
15 {\r
16 \r
17     class PacketTest\r
18     {\r
19 \r
20         static readonly byte[] gpdtm;\r
21         static readonly byte[] gpgbs;\r
22         static readonly byte[] gpgga;\r
23 \r
24         static PacketTest()\r
25         {\r
26             Encoding ascii = Encoding.ASCII;\r
27 \r
28             gpdtm = ascii.GetBytes("$GPDTM,W84,,0.000000,N,0.000000,E,0.0,W84*6F\r\n");\r
29             gpgga = ascii.GetBytes("$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47\r\n");\r
30         }\r
31 \r
32         [Test]\r
33         public void GpDtmTest()\r
34         {\r
35             Packet p;\r
36             GpDtm.TryParse(gpdtm, out p);\r
37         }\r
38 \r
39         [Test]\r
40         public void GpGgaTest()\r
41         {\r
42             Packet packet;\r
43             Assert.AreEqual(true, GpGga.TryParse(gpgga, out packet));\r
44             GpGga p = packet as GpGga;\r
45             Assert.AreEqual(new TimeSpan(12,35,19), p.TimeOfFix);\r
46             Assert.AreEqual(48.1173m, p.Position.Latitude);\r
47             Assert.AreEqual(691m / 60m, p.Position.Longitude);\r
48         }\r
49     }\r
50 }\r