Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_GPS/tests/test_gps.cpp
Views: 1799
/*1* Copyright (C) 2016 Intel Corporation. All rights reserved.2*3* This file is free software: you can redistribute it and/or modify it4* under the terms of the GNU General Public License as published by the5* Free Software Foundation, either version 3 of the License, or6* (at your option) any later version.7*8* This file is distributed in the hope that it will be useful, but9* WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.11* See the GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License along14* with this program. If not, see <http://www.gnu.org/licenses/>.15*/16#include <AP_gtest.h>1718#include <AP_GPS/AP_GPS_NMEA.h>1920const AP_HAL::HAL &hal = AP_HAL::get_HAL();2122class AP_GPS_NMEA_Test23{24public:25int32_t parse_decimal_100(const char *p) const26{27return AP_GPS_NMEA::_parse_decimal_100(p);28}29};3031TEST(AP_GPS_NMEA, parse_decimal_100)32{33AP_GPS_NMEA_Test test;3435/* Positive numbers with possible round/truncate */36ASSERT_EQ(100, test.parse_decimal_100("1.0"));37ASSERT_EQ(100, test.parse_decimal_100("1.00"));38ASSERT_EQ(100, test.parse_decimal_100("1.001"));39ASSERT_EQ(101, test.parse_decimal_100("1.006"));4041/* Positive numbers with possible round/truncate with + signal */42ASSERT_EQ(100, test.parse_decimal_100("+1.0"));43ASSERT_EQ(100, test.parse_decimal_100("+1.00"));44ASSERT_EQ(100, test.parse_decimal_100("+1.001"));45ASSERT_EQ(101, test.parse_decimal_100("+1.006"));4647/* Positive numbers in (0, 1) range, with possible round/truncate */48ASSERT_EQ(0, test.parse_decimal_100("0.0"));49ASSERT_EQ(0, test.parse_decimal_100("0.00"));50ASSERT_EQ(0, test.parse_decimal_100("0.001"));51ASSERT_EQ(1, test.parse_decimal_100("0.006"));5253/* Negative numbers with possible round/truncate */54ASSERT_EQ(-100, test.parse_decimal_100("-1.0"));55ASSERT_EQ(-100, test.parse_decimal_100("-1.00"));56ASSERT_EQ(-100, test.parse_decimal_100("-1.001"));57ASSERT_EQ(-101, test.parse_decimal_100("-1.006"));5859/* Integer numbers */60ASSERT_EQ(100, test.parse_decimal_100("1"));61ASSERT_EQ(-100, test.parse_decimal_100("-1"));62}6364AP_GTEST_MAIN()656667