52 HybridPrimeTable(
bool force_on_the_fly,
int max_precalculated)
54 precalc_impl_(force_on_the_fly ? NULL :
56 max_precalculated_(max_precalculated) {}
57 virtual ~HybridPrimeTable() {
58 delete on_the_fly_impl_;
63 if (precalc_impl_ != NULL && n < max_precalculated_)
64 return precalc_impl_->IsPrime(n);
66 return on_the_fly_impl_->IsPrime(n);
71 if (precalc_impl_ != NULL && p < max_precalculated_)
72 next_prime = precalc_impl_->GetNextPrime(p);
74 return next_prime != -1 ? next_prime : on_the_fly_impl_->GetNextPrime(p);
80 int max_precalculated_;
83 using ::testing::TestWithParam;
84 using ::testing::Bool;
85 using ::testing::Values;
86 using ::testing::Combine;
93 class PrimeTableTest :
public TestWithParam< ::testing::tuple<bool, int> > {
95 virtual void SetUp() {
104 bool force_on_the_fly = ::testing::get<0>(GetParam());
105 int max_precalculated = ::testing::get<1>(GetParam());
106 table_ =
new HybridPrimeTable(force_on_the_fly, max_precalculated);
145 EXPECT_EQ(131, table_->GetNextPrime(128));
161 Combine(
Bool(), Values(1, 10)));
171 TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
173 #endif // GTEST_HAS_COMBINE