@@ -121,60 +121,45 @@ void test_comment()
121121
122122void test_route ()
123123{
124+ // For some reason merely having this array causes a segfault
125+ // TODO: Fix this so that part of the test can be implemented
126+ //uint8_t expect[] = { 0x04, 0x1b, 0x03, 0x56, 0x45, 0x33, 0x4b, 0x43, 0x4e, 0xff, 0x07, 0x10, 0x56, 0x45, 0x32, 0x44,
127+ // 0x45, 0x46, 0xfd, 0xea, 0x56, 0x45, 0x33, 0x58, 0x59, 0x5a, 0xfd, 0x0e, 0xfe};
124128 cats_route_whisker_t data ;
125- data .len = 0 ;
126-
127- cats_route_hop_t hop1 ;
128- strcpy (hop1 .callsign , "VE3KCN" );
129- hop1 .hopType = 0xFF ;
130- hop1 .rssi = 0x10 ;
131- hop1 .ssid = 7 ;
132- data .len += 3 + strlen ("VE3KCN" );
133-
134- cats_route_hop_t hop2 ;
135- strcpy (hop2 .callsign , "VE3KCN" );
136- hop2 .hopType = CATS_ROUTE_INET ;
137- hop2 .rssi = 0x00 ;
138- hop2 .ssid = 15 ;
139- data .len += 2 + strlen ("VE3KCN" );
140-
141129 data .maxDigipeats = 3 ;
142- memcpy ( & data . hops [ 0 ], & hop1 , sizeof ( cats_route_hop_t ));
143- memcpy (& data . hops [ 1 ], & hop2 , sizeof ( cats_route_hop_t ) );
144- data . numHops = 2 ;
145-
146- cats_route_add_hop (& data , "VE3KCN " , 1 , 0xea , CATS_ROUTE_INET );
130+
131+ cats_route_add_hop (& data , "VE3KCN" , 7 , 0x10 , CATS_ROUTE_PAST );
132+ cats_route_add_hop ( & data , "VE2DEF" , 234 , 0 , CATS_ROUTE_FUTURE ) ;
133+ cats_route_add_hop ( & data , "VE3XYZ" , 14 , 0 , CATS_ROUTE_FUTURE );
134+ cats_route_add_hop (& data , "" , 0 , 0 , CATS_ROUTE_INET );
147135
148136 cats_whisker_t * whisker = malloc (sizeof (cats_whisker_t ));
149137 whisker -> type = WHISKER_TYPE_ROUTE ;
150138 whisker -> data .route = data ;
151- whisker -> len = data .len + 1 ;
139+ whisker -> len = data .len ;
152140
153141 uint8_t buf [whisker -> len + 2 ];
154142 assert (cats_whisker_encode (whisker , buf ) == CATS_SUCCESS );
155- hexdump (buf + 2 , whisker -> len );
156-
157143 free (whisker );
158144
159145 whisker = malloc (sizeof (cats_whisker_t ));
160146 assert (cats_whisker_decode (whisker , buf ) == CATS_SUCCESS );
161147
162148 data = whisker -> data .route ;
163- printf ("NH: %d" , data .numHops );
164- printf (data .hops [2 ].callsign );
165- return ;
166149 assert (data .maxDigipeats == 3 );
167150 assert (strcmp (data .hops -> callsign , "VE3KCN" ) == 0 );
168151 assert (data .hops -> hopType == 0xFF );
169152 assert (data .hops -> rssi == 0x10 );
170153 assert (data .hops -> ssid == 7 );
171- assert (strcmp (data .hops [1 ].callsign , "VE3KCN " ) == 0 );
172- assert (data .hops [1 ].hopType == CATS_ROUTE_INET );
173- assert (data .hops [1 ].ssid == 15 );
174- assert (strcmp (data .hops [2 ].callsign , "VE3KCN " ) == 0 );
175- assert (data .hops [2 ].hopType == CATS_ROUTE_PAST );
154+ assert (strcmp (data .hops [1 ].callsign , "VE2DEF " ) == 0 );
155+ assert (data .hops [1 ].hopType == CATS_ROUTE_FUTURE );
156+ assert (data .hops [1 ].ssid == 234 );
157+ assert (strcmp (data .hops [2 ].callsign , "VE3XYZ " ) == 0 );
158+ assert (data .hops [2 ].hopType == CATS_ROUTE_FUTURE );
176159 assert (data .hops [2 ].rssi == 0x00 );
177- assert (data .hops [2 ].ssid == 1 );
160+ assert (data .hops [2 ].ssid == 14 );
161+ assert (data .hops [3 ].hopType == CATS_ROUTE_INET );
162+ //assert(memcmp(buf, expect, whisker->len) == 0);
178163
179164 free (whisker );
180165}
0 commit comments