test_decode.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The urg_stamped Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 
19 #include <string>
20 
21 #include <scip2/decode.h>
22 
23 TEST(DecoderTest, testChecksumValidation)
24 {
25  // Checksum example shown in SCIP2.0 Specification
26  const std::string line("Hokuyo");
27  scip2::Decoder<1> dec(line);
28  ASSERT_EQ((dec.getChecksum() & 0x3F) + 0x30, 'o');
29 }
30 
31 TEST(DecoderTest, testDecodeSingle)
32 {
33  // Examples shown in SCIP2.0 Specification
34  const std::string line2("CB");
35  scip2::Decoder<2> dec2(line2);
36  ASSERT_EQ(*dec2.begin(), 1234u);
37 
38  const std::string line3("1Dh");
39  scip2::Decoder<3> dec3(line3);
40  ASSERT_EQ(*dec3.begin(), 5432u);
41 
42  const std::string line4("m2@0");
43  scip2::Decoder<4> dec4(line4);
44  ASSERT_EQ(*dec4.begin(), 16000000u);
45 }
46 
47 int main(int argc, char** argv)
48 {
49  testing::InitGoogleTest(&argc, argv);
50 
51  return RUN_ALL_TESTS();
52 }
uint8_t getChecksum() const
Definition: decode.h:123
int main(int argc, char **argv)
Definition: test_decode.cpp:47
TEST(DecoderTest, testChecksumValidation)
Definition: test_decode.cpp:23
Iterator begin()
Definition: decode.h:115


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Tue May 11 2021 02:14:05