chore: Enable unit-tests in CI (#2129)

* chore: Enable unit-tests in CI

* Update helio
This commit is contained in:
Shahar Mike 2023-11-06 12:44:02 +02:00 committed by GitHub
parent f68e1ef7e3
commit 1f4b1e4c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 34 deletions

View file

@ -98,7 +98,6 @@ jobs:
${SCCACHE_PATH} --show-stats | tee $GITHUB_STEP_SUMMARY ${SCCACHE_PATH} --show-stats | tee $GITHUB_STEP_SUMMARY
- name: C++ Unit Tests - name: C++ Unit Tests
if: ${{ false }}
run: | run: |
cd ${GITHUB_WORKSPACE}/build cd ${GITHUB_WORKSPACE}/build
echo Run ctest -V -L DFLY echo Run ctest -V -L DFLY

2
helio

@ -1 +1 @@
Subproject commit 1fea6effc72919649c815afb04e9c7829b0240ab Subproject commit 1b3f13d94a5342fe9c4db67a7e05404c602b8a17

View file

@ -6,15 +6,29 @@
#include <absl/strings/match.h> #include <absl/strings/match.h>
#include "base/logging.h"
namespace facade { namespace facade {
using namespace testing; using namespace testing;
using namespace std; using namespace std;
bool RespMatcher::MatchAndExplain(const RespExpr& e, MatchResultListener* listener) const { bool RespMatcher::MatchAndExplain(RespExpr e, MatchResultListener* listener) const {
if (e.type != type_) { if (e.type != type_) {
*listener << "\nWrong type: " << RespExpr::TypeName(e.type); if (e.type == RespExpr::STRING && type_ == RespExpr::DOUBLE) {
return false; // Doubles are encoded as strings, unless RESP3 is selected. So parse string and try to
// compare it.
double d = 0;
if (!absl::SimpleAtod(e.GetString(), &d)) {
*listener << "\nCan't parse as double: " << e.GetString();
return false;
}
e.type = RespExpr::DOUBLE;
e.u = d;
} else {
*listener << "\nWrong type: " << RespExpr::TypeName(e.type);
return false;
}
} }
if (type_ == RespExpr::STRING || type_ == RespExpr::ERROR) { if (type_ == RespExpr::STRING || type_ == RespExpr::ERROR) {
@ -37,7 +51,7 @@ bool RespMatcher::MatchAndExplain(const RespExpr& e, MatchResultListener* listen
} }
} else if (type_ == RespExpr::DOUBLE) { } else if (type_ == RespExpr::DOUBLE) {
auto actual = get<double>(e.u); auto actual = get<double>(e.u);
if (exp_double_ != actual) { if (abs(exp_double_ - actual) > 0.0001) {
*listener << "\nActual : " << actual << " expected: " << exp_double_; *listener << "\nActual : " << actual << " expected: " << exp_double_;
return false; return false;
} }

View file

@ -26,7 +26,7 @@ class RespMatcher {
} }
using is_gtest_matcher = void; using is_gtest_matcher = void;
bool MatchAndExplain(const RespExpr& e, testing::MatchResultListener*) const; bool MatchAndExplain(RespExpr e, testing::MatchResultListener*) const;
void DescribeTo(std::ostream* os) const; void DescribeTo(std::ostream* os) const;

View file

@ -790,56 +790,51 @@ TEST_F(ZSetFamilyTest, GeoSearch) {
EXPECT_THAT( EXPECT_THAT(
resp, resp,
RespArray(ElementsAre( RespArray(ElementsAre(
RespArray(ElementsAre("Berlin", "0.00017343178521311378", "3673983950397063", RespArray(ElementsAre("Berlin", DoubleArg(0.00017343178521311378), "3673983950397063",
RespArray(ElementsAre("13.405002057552338", "52.51999907056681")))), RespArray(ElementsAre(DoubleArg(13.4050), DoubleArg(52.5200))))),
RespArray( RespArray(ElementsAre("Dublin", DoubleArg(487.5619030644293), "3678981558208417",
ElementsAre("Dublin", "487.5619030644293", "3678981558208417", RespArray(ElementsAre(DoubleArg(6.2603), DoubleArg(53.3498))))))));
RespArray(ElementsAre("6.260299980640411", "53.34980087538425")))))));
resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYBOX", "1000", "1000", resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYBOX", "1000", "1000",
"KM", "WITHCOORD", "WITHDIST"}); "KM", "WITHCOORD", "WITHDIST"});
EXPECT_THAT( EXPECT_THAT(
resp, resp,
RespArray(ElementsAre( RespArray(ElementsAre(
RespArray(ElementsAre("Vienna", "523.6926930553866", RespArray(ElementsAre("Vienna", DoubleArg(523.6926930553866),
RespArray(ElementsAre("16.373799741268158", "48.20820011474228")))), RespArray(ElementsAre(DoubleArg(16.3738), DoubleArg(48.2082))))),
RespArray(ElementsAre("Berlin", "0.00017343178521311378", RespArray(ElementsAre("Berlin", DoubleArg(0.00017343178521311378),
RespArray(ElementsAre("13.405002057552338", "52.51999907056681")))), RespArray(ElementsAre(DoubleArg(13.4050), DoubleArg(52.5200))))),
RespArray( RespArray(ElementsAre("Dublin", DoubleArg(487.5619030644293),
ElementsAre("Dublin", "487.5619030644293", RespArray(ElementsAre(DoubleArg(6.2603), DoubleArg(53.3498))))))));
RespArray(ElementsAre("6.260299980640411", "53.34980087538425")))))));
resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYRADIUS", "500", "KM", resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYRADIUS", "500", "KM",
"COUNT", "3", "WITHCOORD", "WITHDIST"}); "COUNT", "3", "WITHCOORD", "WITHDIST"});
EXPECT_THAT( EXPECT_THAT(
resp, resp,
RespArray(ElementsAre( RespArray(ElementsAre(
RespArray(ElementsAre("Berlin", "0.00017343178521311378", RespArray(ElementsAre("Berlin", DoubleArg(0.00017343178521311378),
RespArray(ElementsAre("13.405002057552338", "52.51999907056681")))), RespArray(ElementsAre(DoubleArg(13.4050), DoubleArg(52.5200))))),
RespArray( RespArray(ElementsAre("Dublin", DoubleArg(487.5619030644293),
ElementsAre("Dublin", "487.5619030644293", RespArray(ElementsAre(DoubleArg(6.2603), DoubleArg(53.3498))))))));
RespArray(ElementsAre("6.260299980640411", "53.34980087538425")))))));
resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYRADIUS", "500", "KM", resp = Run({"GEOSEARCH", "Europe", "FROMLONLAT", "13.4050", "52.5200", "BYRADIUS", "500", "KM",
"DESC", "WITHCOORD", "WITHDIST"}); "DESC", "WITHCOORD", "WITHDIST"});
EXPECT_THAT( EXPECT_THAT(
resp, resp,
RespArray(ElementsAre( RespArray(ElementsAre(
RespArray(ElementsAre("Dublin", "487.5619030644293", RespArray(ElementsAre("Dublin", DoubleArg(487.5619030644293),
RespArray(ElementsAre("6.260299980640411", "53.34980087538425")))), RespArray(ElementsAre(DoubleArg(6.2603), DoubleArg(53.3498))))),
RespArray( RespArray(ElementsAre("Berlin", DoubleArg(0.00017343178521311378),
ElementsAre("Berlin", "0.00017343178521311378", RespArray(ElementsAre(DoubleArg(13.4050), DoubleArg(52.5200))))))));
RespArray(ElementsAre("13.405002057552338", "52.51999907056681")))))));
resp = Run({"GEOSEARCH", "Europe", "FROMMEMBER", "Madrid", "BYRADIUS", "700", "KM", "WITHCOORD", resp = Run({"GEOSEARCH", "Europe", "FROMMEMBER", "Madrid", "BYRADIUS", "700", "KM", "WITHCOORD",
"WITHDIST"}); "WITHDIST"});
EXPECT_THAT( EXPECT_THAT(
resp, resp,
RespArray(ElementsAre( RespArray(ElementsAre(
RespArray(ElementsAre( RespArray(ElementsAre("Madrid", "0",
"Madrid", "0", RespArray(ElementsAre("3.7038007378578186", "40.416799319406216")))), RespArray(ElementsAre(DoubleArg(3.7038), DoubleArg(40.4168))))),
RespArray( RespArray(ElementsAre("Lisbon", DoubleArg(502.20769462704084),
ElementsAre("Lisbon", "502.20769462704084", RespArray(ElementsAre(DoubleArg(9.1427), DoubleArg(38.7369))))))));
RespArray(ElementsAre("9.142698347568512", "38.736900197448534")))))));
} }
} // namespace dfly } // namespace dfly