From 4826b18be3f24cee9e365eac76926411f2226b59 Mon Sep 17 00:00:00 2001 From: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:30:39 -0500 Subject: [PATCH] update tests --- .../native/cpp/PhotonPoseEstimatorTest.cpp | 1 - .../targeting/MultiTargetPNPResultTest.cpp | 52 ++++++-------- .../native/cpp/targeting/PNPResultTest.cpp | 72 ------------------- .../targeting/PhotonPipelineResultTest.cpp | 17 +++-- 4 files changed, 31 insertions(+), 111 deletions(-) delete mode 100644 photon-targeting/src/test/native/cpp/targeting/PNPResultTest.cpp diff --git a/photon-lib/src/test/native/cpp/PhotonPoseEstimatorTest.cpp b/photon-lib/src/test/native/cpp/PhotonPoseEstimatorTest.cpp index 6c78f9c0fc..d0a0b25b3a 100644 --- a/photon-lib/src/test/native/cpp/PhotonPoseEstimatorTest.cpp +++ b/photon-lib/src/test/native/cpp/PhotonPoseEstimatorTest.cpp @@ -38,7 +38,6 @@ #include "photon/PhotonCamera.h" #include "photon/PhotonPoseEstimator.h" #include "photon/targeting/MultiTargetPNPResult.h" -#include "photon/targeting/PNPResult.h" #include "photon/targeting/PhotonPipelineResult.h" #include "photon/targeting/PhotonTrackedTarget.h" diff --git a/photon-targeting/src/test/native/cpp/targeting/MultiTargetPNPResultTest.cpp b/photon-targeting/src/test/native/cpp/targeting/MultiTargetPNPResultTest.cpp index ffda261ca4..d7ca33b7d5 100644 --- a/photon-targeting/src/test/native/cpp/targeting/MultiTargetPNPResultTest.cpp +++ b/photon-targeting/src/test/native/cpp/targeting/MultiTargetPNPResultTest.cpp @@ -20,27 +20,39 @@ #include "photon/targeting/MultiTargetPNPResult.h" TEST(MultiTargetPNPResultTest, Equality) { - photon::MultiTargetPNPResult a; - photon::MultiTargetPNPResult b; - - EXPECT_EQ(a, b); - - photon::PNPResult pnpRes{ + photon::MultiTargetPNPResult a{ frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), 0.1, frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; + 0.1, + 0, - photon::MultiTargetPNPResult a1{pnpRes, {1, 2, 3, 4}}; - photon::MultiTargetPNPResult b1{pnpRes, {1, 2, 3, 4}}; + {1, 2, 3, 4}}; + photon::MultiTargetPNPResult b{ + frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), + frc::Rotation3d(1_rad, 2_rad, 3_rad)), + 0.1, + frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), + frc::Rotation3d(1_rad, 2_rad, 3_rad)), + 0.1, + 0, + {1, 2, 3, 4}}; - EXPECT_EQ(a1, b1); + EXPECT_EQ(a, b); } TEST(MultiTargetPNPResultTest, Roundtrip) { - photon::MultiTargetPNPResult result; + photon::MultiTargetPNPResult result{ + frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), + frc::Rotation3d(1_rad, 2_rad, 3_rad)), + 0.1, + frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), + frc::Rotation3d(1_rad, 2_rad, 3_rad)), + 0.1, + 0, + {1, 2, 3, 4}}; google::protobuf::Arena arena; google::protobuf::Message* proto = @@ -51,22 +63,4 @@ TEST(MultiTargetPNPResultTest, Roundtrip) { wpi::Protobuf::Unpack(*proto); EXPECT_EQ(result, unpacked_data); - - photon::PNPResult pnpRes{ - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - - photon::MultiTargetPNPResult result1{pnpRes, {1, 2, 3, 4}}; - - proto = wpi::Protobuf::New(&arena); - wpi::Protobuf::Pack(proto, result1); - - photon::MultiTargetPNPResult unpacked_data1 = - wpi::Protobuf::Unpack(*proto); - - EXPECT_EQ(result1, unpacked_data1); } diff --git a/photon-targeting/src/test/native/cpp/targeting/PNPResultTest.cpp b/photon-targeting/src/test/native/cpp/targeting/PNPResultTest.cpp deleted file mode 100644 index c4313396ae..0000000000 --- a/photon-targeting/src/test/native/cpp/targeting/PNPResultTest.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) Photon Vision. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gtest/gtest.h" -#include "photon.pb.h" -#include "photon/targeting/PNPResult.h" - -TEST(PNPResultTest, Equality) { - photon::PNPResult a; - photon::PNPResult b; - - EXPECT_EQ(a, b); - - photon::PNPResult a1{frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - photon::PNPResult b1{frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - - EXPECT_EQ(a1, b1); -} - -TEST(PNPResultTest, Roundtrip) { - photon::PNPResult result; - - google::protobuf::Arena arena; - google::protobuf::Message* proto = - wpi::Protobuf::New(&arena); - wpi::Protobuf::Pack(proto, result); - - photon::PNPResult unpacked_data = - wpi::Protobuf::Unpack(*proto); - - EXPECT_EQ(result, unpacked_data); - - photon::PNPResult result1{ - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, - frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), - frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - - proto = wpi::Protobuf::New(&arena); - wpi::Protobuf::Pack(proto, result1); - - photon::PNPResult unpacked_data2 = - wpi::Protobuf::Unpack(*proto); - - EXPECT_EQ(result1, unpacked_data2); -} diff --git a/photon-targeting/src/test/native/cpp/targeting/PhotonPipelineResultTest.cpp b/photon-targeting/src/test/native/cpp/targeting/PhotonPipelineResultTest.cpp index 73a4efcfdb..4f5092d006 100644 --- a/photon-targeting/src/test/native/cpp/targeting/PhotonPipelineResultTest.cpp +++ b/photon-targeting/src/test/native/cpp/targeting/PhotonPipelineResultTest.cpp @@ -61,15 +61,15 @@ TEST(PhotonPipelineResultTest, Equality) { EXPECT_EQ(a1, b1); - photon::PNPResult pnpRes{ + photon::MultiTargetPNPResult multitagRes{ frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), 0.1, frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - - photon::MultiTargetPNPResult multitagRes{pnpRes, {1, 2, 3, 4}}; + 0.1, + 0, + {1, 2, 3, 4}}; photon::PhotonPipelineResult a2{12_ms, targets, multitagRes}; photon::PhotonPipelineResult b2{12_ms, targets, multitagRes}; @@ -77,7 +77,6 @@ TEST(PhotonPipelineResultTest, Equality) { EXPECT_EQ(a2, b2); } -// TODO TEST(PhotonPipelineResultTest, Roundtrip) { photon::PhotonPipelineResult result{12_ms, {}}; @@ -130,15 +129,15 @@ TEST(PhotonPipelineResultTest, Roundtrip) { EXPECT_EQ(result2, unpacked_data2); - photon::PNPResult pnpRes{ + photon::MultiTargetPNPResult multitagRes{ frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), 0.1, frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m), frc::Rotation3d(1_rad, 2_rad, 3_rad)), - 0.1, 0}; - - photon::MultiTargetPNPResult multitagRes{pnpRes, {1, 2, 3, 4}}; + 0.1, + 0, + {1, 2, 3, 4}}; photon::PhotonPipelineResult result3{12_ms, targets, multitagRes};