void testWhoIs( Test * pTest) { uint8_t apdu[480] = { 0 }; int len = 0; int apdu_len = 0; int32_t low_limit = -1; int32_t high_limit = -1; int32_t test_low_limit = 0; int32_t test_high_limit = 0; /* normal who-is without limits */ len = whois_encode_apdu(&apdu[0], low_limit, high_limit); ct_test(pTest, len > 0); apdu_len = len; len = whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, &test_high_limit); ct_test(pTest, len != BACNET_STATUS_ERROR); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); /* normal who-is with limits - complete range */ for (low_limit = 0; low_limit <= BACNET_MAX_INSTANCE; low_limit += (BACNET_MAX_INSTANCE / 4)) { for (high_limit = 0; high_limit <= BACNET_MAX_INSTANCE; high_limit += (BACNET_MAX_INSTANCE / 4)) { len = whois_encode_apdu(&apdu[0], low_limit, high_limit); apdu_len = len; ct_test(pTest, len > 0); len = whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, &test_high_limit); ct_test(pTest, len != BACNET_STATUS_ERROR); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); } } /* abnormal case: who-is with no limits, but with APDU containing 2 limits */ low_limit = 0; high_limit = 0; len = whois_encode_apdu(&apdu[0], low_limit, high_limit); ct_test(pTest, len > 0); apdu_len = len; low_limit = -1; high_limit = -1; len = whois_encode_apdu(&apdu[0], low_limit, high_limit); ct_test(pTest, len > 0); apdu_len = len; len = whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, &test_high_limit); ct_test(pTest, len != BACNET_STATUS_ERROR); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); }
void testWhoIs( Test * pTest) { uint8_t apdu[480] = { 0 }; int len = 0; int apdu_len = 0; int32_t low_limit = -1; int32_t high_limit = -1; int32_t test_low_limit = -1; int32_t test_high_limit = -1; len = whois_encode_apdu(&apdu[0], low_limit, high_limit); ct_test(pTest, len != 0); apdu_len = len; len = whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, &test_high_limit); ct_test(pTest, len != -1); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); for (low_limit = 0; low_limit <= BACNET_MAX_INSTANCE; low_limit += (BACNET_MAX_INSTANCE / 4)) { for (high_limit = 0; high_limit <= BACNET_MAX_INSTANCE; high_limit += (BACNET_MAX_INSTANCE / 4)) { len = whois_encode_apdu(&apdu[0], low_limit, high_limit); apdu_len = len; ct_test(pTest, len != 0); len = whois_decode_apdu(&apdu[0], apdu_len, &test_low_limit, &test_high_limit); ct_test(pTest, len != -1); ct_test(pTest, test_low_limit == low_limit); ct_test(pTest, test_high_limit == high_limit); } } }