> On March 7, 2019, 6:41 p.m., Joseph Wu wrote:
> > Hum... I wonder if it is worthwhile to make this a normal function call 
> > instead.
> > ```
> > <template T>
> > bool metricsEqual(string metric, T value) {
> >   JSON::Object metrics = Metrics();
> >   if (metrics.count(metric) != 1) {
> >     return false;
> >   }
> >   
> >   return metrics.at<JSON::Number>(metric)->as<T>() == value;
> > }
> > ```
> > With usage like:
> > ```
> > ASSERT_TRUE(metricsEqual("metric/foo", 1));
> > ```

Good point! That also allows getting rid of the annoying `ASSERT()` inside a 
statement called `EXPECT_[...]`.


> On March 7, 2019, 6:41 p.m., Joseph Wu wrote:
> > src/tests/utils.hpp
> > Lines 40 (patched)
> > <https://reviews.apache.org/r/70156/diff/1/?file=2129554#file2129554line40>
> >
> >     Is it necessary to make this a `do { ... } while (0);` instead of just 
> > enclosing this in a `{ ... }`?

The advantage of the `do-while` construct is that the compiler will give you an 
error if you forget the semicolon after `EXPECT_METRICS_EQ();`, apart from this 
I think the two are more or less equivalent.


> On March 7, 2019, 6:41 p.m., Joseph Wu wrote:
> > src/tests/utils.hpp
> > Lines 41 (patched)
> > <https://reviews.apache.org/r/70156/diff/1/?file=2129554#file2129554line41>
> >
> >     I can imagine a name conflict if the test is particularly metric heavy. 
> >  i.e. if the test defines another `metrics` local variable.

That's fine, the macro is introducing a new scope.


- Benno


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/70156/#review213530
-----------------------------------------------------------


On March 7, 2019, 4:59 p.m., Benno Evers wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/70156/
> -----------------------------------------------------------
> 
> (Updated March 7, 2019, 4:59 p.m.)
> 
> 
> Review request for mesos, Gastón Kleiman, Greg Mann, and Joseph Wu.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Added helper to test for metrics values.
> 
> 
> Diffs
> -----
> 
>   src/tests/utils.hpp b2f22cd4db223d167aa35109cd8de6df82ed1f4d 
> 
> 
> Diff: https://reviews.apache.org/r/70156/diff/1/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Benno Evers
> 
>

Reply via email to