Skip to content

Commit 1a79290

Browse files
committed
C++: Add failing tests with 'CPathT'.
1 parent 5f05417 commit 1a79290

2 files changed

Lines changed: 267 additions & 85 deletions

File tree

cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,107 @@ void test_CComSafeArray() {
602602
sink(c[0L]); // $ ir
603603
}
604604
}
605+
606+
template <typename StringType>
607+
struct CPathT {
608+
typedef StringType PCXSTR; // simplified
609+
CPathT(PCXSTR pszPath);
610+
CPathT(const CPathT<StringType>& path);
611+
CPathT() throw();
612+
613+
void AddBackslash();
614+
BOOL AddExtension(PCXSTR pszExtension);
615+
BOOL Append(PCXSTR pszMore);
616+
void BuildRoot(int iDrive);
617+
void Canonicalize();
618+
void Combine(PCXSTR pszDir, PCXSTR pszFile);
619+
CPathT<StringType> CommonPrefix(PCXSTR pszOther);
620+
BOOL CompactPathEx(UINT nMaxChars, DWORD dwFlags);
621+
BOOL FileExists() const;
622+
int FindExtension() const;
623+
int FindFileName() const;
624+
int GetDriveNumber() const;
625+
StringType GetExtension() const;
626+
BOOL IsDirectory() const;
627+
BOOL IsFileSpec() const;
628+
BOOL IsPrefix(PCXSTR pszPrefix) const;
629+
BOOL IsRelative() const;
630+
BOOL IsRoot() const;
631+
BOOL IsSameRoot(PCXSTR pszOther) const;
632+
BOOL IsUNC() const;
633+
BOOL IsUNCServer() const;
634+
BOOL IsUNCServerShare() const;
635+
BOOL MakePretty();
636+
BOOL MatchSpec(PCXSTR pszSpec) const;
637+
void QuoteSpaces();
638+
BOOL RelativePathTo(
639+
PCXSTR pszFrom,
640+
DWORD dwAttrFrom,
641+
PCXSTR pszTo,
642+
DWORD dwAttrTo);
643+
void RemoveArgs();
644+
void RemoveBackslash();
645+
void RemoveBlanks();
646+
void RemoveExtension();
647+
BOOL RemoveFileSpec();
648+
BOOL RenameExtension(PCXSTR pszExtension);
649+
int SkipRoot() const;
650+
void StripPath();
651+
BOOL StripToRoot();
652+
void UnquoteSpaces();
653+
operator const StringType&() const throw();
654+
operator PCXSTR() const throw();
655+
operator StringType&() throw();
656+
CPathT<StringType>& operator+=(PCXSTR pszMore);
657+
658+
StringType m_strPath;
659+
};
660+
661+
using CPath = CPathT<char*>;
662+
663+
void test_CPathT() {
664+
char* x = indirect_source<char>();
665+
CPath p(x);
666+
sink(static_cast<char*>(p)); // $ MISSING: ir
667+
sink(p.m_strPath); // $ MISSING: ir
668+
669+
CPath p2(p);
670+
sink(p2.m_strPath); // $ MISSING: ir
671+
672+
{
673+
CPath p;
674+
p.AddExtension(x);
675+
sink(p.m_strPath); // $ MISSING: ir
676+
}
677+
{
678+
CPath p;
679+
p.Append(x);
680+
sink(p.m_strPath); // $ MISSING: ir
681+
682+
CPath p2;
683+
p2 += p;
684+
sink(p.m_strPath); // $ MISSING: ir
685+
686+
CPath p3;
687+
p3 += x;
688+
sink(p.m_strPath); // $ MISSING: ir
689+
}
690+
691+
{
692+
CPath p;
693+
p.Combine(x, nullptr);
694+
sink(p.m_strPath); // $ MISSING: ir
695+
}
696+
{
697+
CPath p;
698+
p.Combine(nullptr, x);
699+
sink(p.m_strPath); // $ MISSING: ir
700+
}
701+
702+
{
703+
CPath p;
704+
auto p2 = p.CommonPrefix(x);
705+
sink(p2.m_strPath); // $ MISSING: ir
706+
sink(p2.GetExtension()); // $ MISSING: ir
707+
}
708+
}

0 commit comments

Comments
 (0)