There's no predicting exactly when the stock market will take a dive, but it's a certainty that it will happen eventually. Market crashes are painful, especially for investors who got a bit too euphoric on the way up.

One way to protect yourself -- at least in the long run -- is to buy shares of companies that have the potential to thrive regardless of market conditions. Three of our Motley Fool contributors recommend Brookfield Infrastructure Partners (BIP -0.44%), Berkshire Hathaway (BRK.B 0.11%), and Genomic Health (GHDX). Here's why.

A history of taking advantage of market crashes

Matt DiLallo (Brookfield Infrastructure Partners): Most investors fear market crashes because their existing investments lose money. Brookfield Infrastructure Partners, on the other hand, sees these downturns as an opportunity to buy good businesses at even better prices.

Brookfield Infrastructure has a long history of taking advantage of the market's rough spots. During the financial crisis of 2008, for example, the company helped recapitalize a troubled Australian infrastructure company. Meanwhile, a few years ago, Brookfield took advantage of Brazil's economic and political crisis by buying a leading natural gas pipeline system for an excellent price. Even more recently, the company has benefited from all the volatility in the oil market by snapping up midstream assets at great values. These deals have paid significant dividends for Brookfield over the years, helping it grow its cash flow and dividend at a double-digit compound annual rate over the last decade.

Oil pipelines.

Image source: Getty Images.

The company is already preparing itself for the next market downturn. Brookfield is currently capitalizing on the strong market for infrastructure assets by selling some of its mature businesses. It aims to raise between $1.5 billion and $2 billion from these sales, which will give it the cash necessary to pounce on opportunities that should arise during the next market crash.

While Brookfield's stock price will likely fall along with the market during the next collapse, it should bounce back even more sharply in the ensuing recovery. That's because the company will undoubtedly have taken advantage of the situation by acquiring another good business at an excellent price. That's why it's such a great stock to buy before the market's next crash.

Betting on Buffett

Tim Green (Berkshire Hathaway): When asset prices are high and capital is abundant, Warren Buffett's Berkshire Hathaway is left twiddling its thumbs. Berkshire has built up a massive pile of cash, over $100 billion, due to a dearth of reasonably priced investment opportunities. Buffett's last big deal, the acquisition of Precision Castparts, closed more than three years ago.

Buffett's reluctance to pay unreasonable prices during times like these is part of what makes him one of the most successful investors in history. So does his willingness to commit capital when the sky appears to be falling. Market crashes tend to punish stocks across the board, creating opportunities to buy assets that have been unduly beaten down. That's when Buffett shines, and this time around he'll have a tremendous amount of firepower at his disposal.

Shares of Berkshire will likely take a hit during the next market crash, along with most stocks, and earnings from the company's various businesses could decline if that market collapse is coupled with a recession. But Berkshire will almost certainly come out the other side stronger, buoyed by deals that Berkshire is uniquely positioned to make.

If there's any stock to own leading up to a market crash, it's Berkshire Hathaway.

Profitable, growing, and changing an industry

Maxx Chatsko (Genomic Health): Investors seeking growth, profitability, and a massive market opportunity should give Genomic Health a close look. The genetic testing leader turned in a solid performance in the first quarter of 2019, but its shares fell anyway. Looking beyond Wall Street's knee-jerk reaction, investors will see that the business grew revenue 17%, expects full-year 2019 revenue to climb by double digits, generated operating income equivalent to half of last year's total, and exited March with $206 million in cash.

That strength, and the fact that the genetic testing market is growing hand over fist, provides confidence that Genomic Health can keep the momentum going no matter what the economy is doing. It all has to do with the business model.

Genomic Health generates revenue primarily from sales of its Oncotype IQ tests, which provide genomic information to inform cancer treatment for patients. That's not a market that will shrivel up during the next recession. The platform has been tapped over 1 million times by clinicians and has multiple products covered by health insurance programs covering more than 60 million individuals.

Given that the company is expanding into new markets in Europe and continues to reap the rewards of positive clinical study results, investors should expect the volume of tests sold to continue climbing higher in the coming quarters and years. Considering most peers aren't profitable or growing at double-digit clips, Genomic Health is a clear industry leader worth a closer look.