NMEA: make nmeatool available with/without ENABLE_IO
[marnav.git] / test / nmea / Test_nmea_checksum.cpp
blobd8c5bce6ab38ba7844d45d1c61c72e7855420984
1 #include <marnav/nmea/checksum.hpp>
2 #include <gtest/gtest.h>
4 namespace
6 using namespace marnav;
8 class Test_nmea_checksum : public ::testing::Test
12 TEST_F(Test_nmea_checksum, checksum_error_construction)
14 EXPECT_NO_THROW(nmea::checksum_error e(0x12, 0x34));
17 TEST_F(Test_nmea_checksum, checksum_compute_sum)
19 struct test_case {
20 uint8_t sum;
21 std::string s;
24 const std::vector<test_case> cases{
25 {0x01u, "0123456789"},
26 {0x1bu, "abcdefghijklmnopqrstuvwxyz"},
27 {0x1bu, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
30 for (auto const & test : cases) {
31 EXPECT_EQ(test.sum, nmea::checksum(begin(test.s), end(test.s)));