test_decode.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The urg_stamped Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <gtest/gtest.h>
00018 
00019 #include <string>
00020 
00021 #include <scip2/decode.h>
00022 
00023 TEST(DecoderTest, testChecksumValidation)
00024 {
00025   // Checksum example shown in SCIP2.0 Specification
00026   const std::string line("Hokuyo");
00027   scip2::Decoder<1> dec(line);
00028   ASSERT_EQ((dec.getChecksum() & 0x3F) + 0x30, 'o');
00029 }
00030 
00031 TEST(DecoderTest, testDecodeSingle)
00032 {
00033   // Examples shown in SCIP2.0 Specification
00034   const std::string line2("CB");
00035   scip2::Decoder<2> dec2(line2);
00036   ASSERT_EQ(*dec2.begin(), 1234u);
00037 
00038   const std::string line3("1Dh");
00039   scip2::Decoder<3> dec3(line3);
00040   ASSERT_EQ(*dec3.begin(), 5432u);
00041 
00042   const std::string line4("m2@0");
00043   scip2::Decoder<4> dec4(line4);
00044   ASSERT_EQ(*dec4.begin(), 16000000u);
00045 }
00046 
00047 int main(int argc, char **argv)
00048 {
00049   testing::InitGoogleTest(&argc, argv);
00050 
00051   return RUN_ALL_TESTS();
00052 }


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Thu Jun 6 2019 18:59:51