Yes, it's ok (assuming strTest is a valid pointer and i is a valid index). Since strTest is a CString*, strTest[i] is a CString. And there is a free operator== overload that accepts a const CString& as param1 and an LPCTSTR as param2 and then does what you'd expect.
The MSDN documentation is here. The second overload is the one that matters:
BOOL operator ==( const CString& s1, LPCTSTR s2 );
(the documentation is out of date and the signature I see when I trace into the actual code is different, but the effect is the same)
MarkRansom alerted me to the fact that your code compares strTest[i] to a character rather than to a string. That's still ok, because there is also an operator== overload that takes CString/char. It's not listed in the documentation I linked to, but here's what the actual code looks like in the VS2012 version:
friend bool operator==(
_In_ const CStringT& str1,
_In_ XCHAR ch2) throw()
{
return( (str1.GetLength() == 1) && (str1[0] == ch2) );
}
Since it's not listed in the outdated documentation, this function presumably did not always exist. However, CString has an implicit constructor that takes a TCHAR. I assume that in VC++ versions that predate the above, a CString would be implicitly constructed from _T('\n') and then used in a call to the CString/CString overload of operator==.