| 49 | } |
| 50 | |
| 51 | void test() |
| 52 | { |
| 53 | geode::CachedValue< Value > cache; |
| 54 | geode::OpenGeodeBasicException::test( |
| 55 | nb_computed == 0, "Wrong number of computations" ); |
| 56 | geode::OpenGeodeBasicException::test( |
| 57 | cache( compute_value, 12., 15 ).test() == 27, "Wrong result" ); |
| 58 | geode::OpenGeodeBasicException::test( |
| 59 | nb_computed == 1, "Wrong number of computations" ); |
| 60 | geode::OpenGeodeBasicException::test( |
| 61 | cache( compute_value, 12., 15 ).test() == 27, "Wrong result" ); |
| 62 | geode::OpenGeodeBasicException::test( |
| 63 | cache( compute_value, 1., 5 ).test() == 27, "Wrong result" ); |
| 64 | geode::OpenGeodeBasicException::test( |
| 65 | nb_computed == 1, "Wrong number of computations" ); |
| 66 | cache.reset(); |
| 67 | geode::OpenGeodeBasicException::test( |
| 68 | cache( compute_value, 2., 5 ).test() == 7, "Wrong result" ); |
| 69 | geode::OpenGeodeBasicException::test( |
| 70 | nb_computed == 2, "Wrong number of computations" ); |
| 71 | } |
| 72 | |
| 73 | OPENGEODE_TEST( "cached-value" ) |