### Question:
MicrometerRegistry implements Registry { @Override public Gauge gauge(Id id) { AtomicDouble value = new AtomicDouble(Double.NaN); io.micrometer.core.instrument.Gauge gauge = io.micrometer.core.instrument.Gauge .builder(id.name(), value, AtomicDouble::get) .tags(convert(id.tags())) .register(impl); return new MicrometerGauge(id, value::set, gauge); } MicrometerRegistry(MeterRegistry impl); @Override Clock clock(); @Override Id createId(String name); @Override Id createId(String name, Iterable<Tag> tags); @Override void register(Meter meter); @Override ConcurrentMap<Id, Object> state(); @Override Counter counter(Id id); @Override DistributionSummary distributionSummary(Id id); @Override Timer timer(Id id); @Override Gauge gauge(Id id); @Override Gauge maxGauge(Id id); @Override Meter get(Id id); @Override Iterator<Meter> iterator();  }### Answer:
@Test public void gaugeSet() { Gauge g = registry.gauge("foo"); Assertions.assertTrue(Double.isNaN(g.value())); g.set(42.0); Assertions.assertEquals(42.0, g.value(), 1e-12); g.set(20.0); Assertions.assertEquals(20.0, g.value(), 1e-12); }
@Test public void gaugeMeasure() { Gauge g = registry.gauge("foo"); g.set(42.0); int i = 0; for (Measurement m : g.measure()) { ++i; Assertions.assertEquals("foo", m.id().name()); Assertions.assertEquals(42.0, m.value(), 1e-12); } Assertions.assertEquals(1, i); }