39 #include "gtest/gtest.h" 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_;
62 virtual bool IsPrime(
int n)
const {
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;
93 class PrimeTableTest :
public TestWithParam< ::std::tr1::tuple<bool, int> > {
95 virtual void SetUp() {
104 bool force_on_the_fly = ::std::tr1::get<0>(GetParam());
105 int max_precalculated = ::std::tr1::get<1>(GetParam());
106 table_ =
new HybridPrimeTable(force_on_the_fly, max_precalculated);
108 virtual void TearDown() {
112 HybridPrimeTable* table_;
145 EXPECT_EQ(131, table_->GetNextPrime(128));
171 TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
173 #endif // GTEST_HAS_COMBINE TEST(DummyTest, CombineIsNotSupportedOnThisPlatform)
#define EXPECT_TRUE(condition)
#define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator)
#define TEST_P(test_case_name, test_name)
#define EXPECT_FALSE(condition)
internal::CartesianProductHolder2< Generator1, Generator2 > Combine(const Generator1 &g1, const Generator2 &g2)
internal::ParamGenerator< bool > Bool()
internal::ValueArray1< T1 > Values(T1 v1)
#define EXPECT_EQ(expected, actual)