2 #include <boost/property_tree/ptree.hpp> 6 #include <gtest/gtest.h> 12 boost::property_tree::iptree pt;
14 return parse_int<T>(pt,
"test");
19 static void test_hex(
const T& val,
const std::string &str){
20 EXPECT_EQ(val, prepare_test<T>(str).
template get<T>());
22 static void test_hex_node(
const T& val,
const std::string &str,
const uint8_t offset){
27 typedef ::testing::Types<uint8_t, uint16_t, uint32_t, uint64_t>
PosTypes;
32 TestFixture::test_hex(0,
"0");
33 TestFixture::test_hex(0,
"0x0");
35 for(uint8_t i = 0; i <=127; ++i){
36 TestFixture::test_hex_node(0,
"0",i);
37 TestFixture::test_hex_node(0,
"0x0",i);
38 TestFixture::test_hex_node(0+i,
"$NODEID+0",i);
39 TestFixture::test_hex_node(0+i,
"$NODEID+0x0",i);
42 TEST(TestHex, checkCamelCase){
49 TEST(TestHex, checkNodeCamelCase){
50 for(uint8_t i = 0; i <=127; ++i){
59 TEST(TestHex, checkSpaces){
65 TEST(TestHex, checkNodeSpaces){
66 for(uint8_t i = 0; i <=127; ++i){
78 TEST(TestHex, checkCommonObjects){
79 for(uint8_t i = 0; i <=127; ++i){
103 void testAccess(
bool c,
bool r,
bool w,
const char* variants[]){
105 for(
const char ** v = variants; *v; ++v){
121 const char* variants[] = {
"ro",
"Ro",
"rO",
"RO", 0};
127 const char* variants[] = {
"wo",
"Wo",
"wO",
"WO", 0};
133 const char* variants[] = {
134 "rw" ,
"Rw" ,
"rW" ,
"Rw",
135 "rwr",
"Rwr",
"rWr",
"Rwr",
136 "rwR",
"RwR",
"rWR",
"RwR",
137 "rww",
"Rww",
"rWw",
"Rww",
138 "rwW",
"RwW",
"rWW",
"RwW",
143 TEST(TestAccessString, TestConst)
145 const char* variants[] = {
146 "const" ,
"Const" ,
"CONST", 0};
152 int main(
int argc,
char **argv){
153 testing::InitGoogleTest(&argc, argv);
154 return RUN_ALL_TESTS();
int main(int argc, char **argv)
canopen::HoldAny parse_int(boost::property_tree::iptree &pt, const std::string &key)
::testing::Types< uint8_t, uint16_t, uint32_t, uint64_t > PosTypes
TYPED_TEST_CASE(TestHexTypes, PosTypes)
static void test_hex(const T &val, const std::string &str)
void testAccess(bool c, bool r, bool w, const char *variants[])
TEST(TestHex, checkCamelCase)
static void test_hex_node(const T &val, const std::string &str, const uint8_t offset)
void set_access(canopen::ObjectDict::Entry &entry, std::string access)
canopen::HoldAny prepare_test(const std::string &str)
TYPED_TEST(TestHexTypes, checkZero)