END_TEST START_TEST(test_beginning_matches) { sdiff_t sds_out[3]; /* Test for when they both have two */ memcpy(&nms_no_match1[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match1[1], &nm2, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[1], &nm3, sizeof(navigation_measurement_t)); u8 num_match = single_diff(2, nms_no_match1, 2, nms_no_match2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].prn == 1); /* Test for both with two the other way */ memcpy(&nms_no_match1[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match1[1], &nm3, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[1], &nm2, sizeof(navigation_measurement_t)); num_match = single_diff(2, nms_no_match1, 2, nms_no_match2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].prn == 1); /* Test when one has only one */ memcpy(&nms_no_match1[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[1], &nm2, sizeof(navigation_measurement_t)); num_match = single_diff(1, nms_no_match1, 2, nms_no_match2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].prn == 1); /* Test when the other has only one */ memcpy(&nms_no_match1[0], &nm1, sizeof(navigation_measurement_t)); memcpy(&nms_no_match1[1], &nm2, sizeof(navigation_measurement_t)); memcpy(&nms_no_match2[0], &nm1, sizeof(navigation_measurement_t)); num_match = single_diff(2, nms_no_match1, 1, nms_no_match2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].prn == 1); }
END_TEST START_TEST(test_single_diff_3) { sdiff_t sds_out[3]; /* Test for when they both have two */ nms1[0] = nm1; nms1[1] = nm3; nms2[0] = nm2; nms2[1] = nm3; u8 num_match = single_diff(2, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 3); /* Test for both with two the other way */ nms1[0] = nm2; nms1[1] = nm3; nms2[0] = nm1; nms2[1] = nm3; num_match = single_diff(2, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 3); /* Test when one has only one */ nms1[0] = nm2; nms2[0] = nm1; nms2[1] = nm2; num_match = single_diff(1, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 2); /* Test when the other has only one */ nms1[0] = nm1; nms1[1] = nm2; nms2[0] = nm2; num_match = single_diff(2, nms1, 1, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 2); }
END_TEST START_TEST(test_single_diff_2) { sdiff_t sds_out[3]; /* Test for when they both have two */ nms1[0] = nm1; nms1[1] = nm2; nms2[0] = nm1; nms2[1] = nm3; u8 num_match = single_diff(2, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 1); fail_unless(sds_out[0].pseudorange == 0); fail_unless(sds_out[0].carrier_phase == 0); fail_unless(sds_out[0].doppler == 0); fail_unless(sds_out[0].snr == 14); fail_unless(memcmp(sds_out[0].sat_pos, nm1.sat_pos, sizeof(nm1.sat_pos)) == 0); fail_unless(memcmp(sds_out[0].sat_vel, nm1.sat_vel, sizeof(nm1.sat_vel)) == 0); /* Test for both with two the other way */ nms1[0] = nm1; nms1[1] = nm3; nms2[0] = nm1_2; nms2[1] = nm2; num_match = single_diff(2, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 1); fail_unless(sds_out[0].pseudorange == -100); fail_unless(sds_out[0].carrier_phase == -100); fail_unless(sds_out[0].doppler == -100); fail_unless(sds_out[0].snr == 14); fail_unless(memcmp(sds_out[0].sat_pos, nm1_2.sat_pos, sizeof(nm1_2.sat_pos)) == 0); fail_unless(memcmp(sds_out[0].sat_vel, nm1_2.sat_vel, sizeof(nm1_2.sat_vel)) == 0); /* Test when one has only one */ nms1[0] = nm1_2; nms2[0] = nm1; nms2[1] = nm2; num_match = single_diff(1, nms1, 2, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 1); fail_unless(sds_out[0].pseudorange == 100); fail_unless(sds_out[0].carrier_phase == 100); fail_unless(sds_out[0].doppler == 100); fail_unless(sds_out[0].snr == 14); fail_unless(memcmp(sds_out[0].sat_pos, nm1.sat_pos, sizeof(nm1.sat_pos)) == 0); fail_unless(memcmp(sds_out[0].sat_vel, nm1.sat_vel, sizeof(nm1.sat_vel)) == 0); /* Test when the other has only one */ nms1[0] = nm1; nms1[1] = nm2; nms2[0] = nm1; num_match = single_diff(2, nms1, 1, nms2, sds_out); fail_unless(num_match == 1); fail_unless(sds_out[0].sid.sat == 1); fail_unless(sds_out[0].pseudorange == 0); fail_unless(sds_out[0].carrier_phase == 0); fail_unless(sds_out[0].doppler == 0); fail_unless(sds_out[0].snr == 14); fail_unless(memcmp(sds_out[0].sat_pos, nm1.sat_pos, sizeof(nm1.sat_pos)) == 0); fail_unless(memcmp(sds_out[0].sat_vel, nm1.sat_vel, sizeof(nm1.sat_vel)) == 0); /* Test when they both match */ nms1[0] = nm1_2; nms1[1] = nm2; nms2[0] = nm1; nms2[1] = nm2_2; num_match = single_diff(2, nms1, 2, nms2, sds_out); fail_unless(num_match == 2); fail_unless(sds_out[0].sid.sat == 1); fail_unless(sds_out[0].pseudorange == 100); fail_unless(sds_out[0].carrier_phase == 100); fail_unless(sds_out[0].doppler == 100); fail_unless(sds_out[0].snr == 14); fail_unless(memcmp(sds_out[0].sat_pos, nm1.sat_pos, sizeof(nm1.sat_pos)) == 0); fail_unless(memcmp(sds_out[0].sat_vel, nm1.sat_vel, sizeof(nm1.sat_vel)) == 0); fail_unless(sds_out[1].sid.sat == 2); fail_unless(sds_out[1].pseudorange == -200); fail_unless(sds_out[1].carrier_phase == -200); fail_unless(sds_out[1].doppler == -200); fail_unless(sds_out[1].snr == 24); fail_unless(memcmp(sds_out[1].sat_pos, nm2_2.sat_pos, sizeof(nm2_2.sat_pos)) == 0); fail_unless(memcmp(sds_out[1].sat_vel, nm2_2.sat_vel, sizeof(nm2_2.sat_vel)) == 0); }