Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 029c013

Browse files
committed
C++: Add failing tests with 'CSimpleArray'.
1 parent c61395b commit 029c013

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,50 @@ void test_CPathT() {
706706
sink(p2.GetExtension()); // $ ir
707707
}
708708
}
709+
710+
template <class T>
711+
struct CSimpleArray {
712+
CSimpleArray(const CSimpleArray<T>& src);
713+
CSimpleArray();
714+
~CSimpleArray();
715+
716+
BOOL Add(const T& t);
717+
int Find(const T& t) const;
718+
T* GetData() const;
719+
int GetSize() const;
720+
BOOL Remove(const T& t);
721+
void RemoveAll();
722+
BOOL RemoveAt(int nIndex);
723+
724+
BOOL SetAtIndex(
725+
int nIndex,
726+
const T& t);
727+
728+
T& operator[](int nindex);
729+
CSimpleArray<T> & operator=(const CSimpleArray<T>& src);
730+
};
731+
732+
void test_CSimpleArray() {
733+
int x = source<int>();
734+
{
735+
CSimpleArray<int> a;
736+
a.Add(x);
737+
sink(a[0]); // $ MISSING: ir
738+
a.Add(0);
739+
sink(a[0]); // $ MISSING: ir
740+
741+
CSimpleArray<int> a2;
742+
sink(a2[0]);
743+
a2 = a;
744+
sink(a2[0]); // $ MISSING: ir
745+
}
746+
{
747+
CSimpleArray<int> a;
748+
a.Add(x);
749+
sink(a.GetData()); // $ MISSING: ir
750+
751+
CSimpleArray<int> a2;
752+
int pos = a2.Find(x);
753+
sink(a2[pos]); // $ MISSING: ir
754+
}
755+
}

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,52 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
800800
| atl.cpp:704:17:704:28 | call to CommonPrefix | atl.cpp:705:10:705:11 | p2 | |
801801
| atl.cpp:704:17:704:28 | call to CommonPrefix | atl.cpp:706:10:706:11 | p2 | |
802802
| atl.cpp:705:10:705:11 | p2 [post update] | atl.cpp:706:10:706:11 | p2 | |
803+
| atl.cpp:733:11:733:21 | call to source | atl.cpp:736:11:736:11 | x | |
804+
| atl.cpp:733:11:733:21 | call to source | atl.cpp:748:11:748:11 | x | |
805+
| atl.cpp:733:11:733:21 | call to source | atl.cpp:752:23:752:23 | x | |
806+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:736:5:736:5 | a | |
807+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:737:10:737:10 | a | |
808+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:738:5:738:5 | a | |
809+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:739:10:739:10 | a | |
810+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:743:10:743:10 | a | |
811+
| atl.cpp:735:23:735:23 | call to CSimpleArray | atl.cpp:745:3:745:3 | a | |
812+
| atl.cpp:736:5:736:5 | ref arg a | atl.cpp:737:10:737:10 | a | |
813+
| atl.cpp:736:5:736:5 | ref arg a | atl.cpp:738:5:738:5 | a | |
814+
| atl.cpp:736:5:736:5 | ref arg a | atl.cpp:739:10:739:10 | a | |
815+
| atl.cpp:736:5:736:5 | ref arg a | atl.cpp:743:10:743:10 | a | |
816+
| atl.cpp:736:5:736:5 | ref arg a | atl.cpp:745:3:745:3 | a | |
817+
| atl.cpp:737:10:737:10 | ref arg a | atl.cpp:738:5:738:5 | a | |
818+
| atl.cpp:737:10:737:10 | ref arg a | atl.cpp:739:10:739:10 | a | |
819+
| atl.cpp:737:10:737:10 | ref arg a | atl.cpp:743:10:743:10 | a | |
820+
| atl.cpp:737:10:737:10 | ref arg a | atl.cpp:745:3:745:3 | a | |
821+
| atl.cpp:738:5:738:5 | ref arg a | atl.cpp:739:10:739:10 | a | |
822+
| atl.cpp:738:5:738:5 | ref arg a | atl.cpp:743:10:743:10 | a | |
823+
| atl.cpp:738:5:738:5 | ref arg a | atl.cpp:745:3:745:3 | a | |
824+
| atl.cpp:739:10:739:10 | ref arg a | atl.cpp:743:10:743:10 | a | |
825+
| atl.cpp:739:10:739:10 | ref arg a | atl.cpp:745:3:745:3 | a | |
826+
| atl.cpp:741:23:741:24 | call to CSimpleArray | atl.cpp:742:10:742:11 | a2 | |
827+
| atl.cpp:741:23:741:24 | call to CSimpleArray | atl.cpp:743:5:743:6 | a2 | |
828+
| atl.cpp:741:23:741:24 | call to CSimpleArray | atl.cpp:744:10:744:11 | a2 | |
829+
| atl.cpp:741:23:741:24 | call to CSimpleArray | atl.cpp:745:3:745:3 | a2 | |
830+
| atl.cpp:742:10:742:11 | ref arg a2 | atl.cpp:743:5:743:6 | a2 | |
831+
| atl.cpp:742:10:742:11 | ref arg a2 | atl.cpp:744:10:744:11 | a2 | |
832+
| atl.cpp:742:10:742:11 | ref arg a2 | atl.cpp:745:3:745:3 | a2 | |
833+
| atl.cpp:743:5:743:6 | ref arg a2 | atl.cpp:744:10:744:11 | a2 | |
834+
| atl.cpp:743:5:743:6 | ref arg a2 | atl.cpp:745:3:745:3 | a2 | |
835+
| atl.cpp:743:10:743:10 | a | atl.cpp:743:5:743:6 | ref arg a2 | TAINT |
836+
| atl.cpp:743:10:743:10 | a | atl.cpp:743:8:743:8 | call to operator= | TAINT |
837+
| atl.cpp:744:10:744:11 | ref arg a2 | atl.cpp:745:3:745:3 | a2 | |
838+
| atl.cpp:747:23:747:23 | call to CSimpleArray | atl.cpp:748:5:748:5 | a | |
839+
| atl.cpp:747:23:747:23 | call to CSimpleArray | atl.cpp:749:10:749:10 | a | |
840+
| atl.cpp:747:23:747:23 | call to CSimpleArray | atl.cpp:754:3:754:3 | a | |
841+
| atl.cpp:748:5:748:5 | ref arg a | atl.cpp:749:10:749:10 | a | |
842+
| atl.cpp:748:5:748:5 | ref arg a | atl.cpp:754:3:754:3 | a | |
843+
| atl.cpp:749:10:749:10 | ref arg a | atl.cpp:754:3:754:3 | a | |
844+
| atl.cpp:751:23:751:24 | call to CSimpleArray | atl.cpp:752:15:752:16 | a2 | |
845+
| atl.cpp:751:23:751:24 | call to CSimpleArray | atl.cpp:753:10:753:11 | a2 | |
846+
| atl.cpp:751:23:751:24 | call to CSimpleArray | atl.cpp:754:3:754:3 | a2 | |
847+
| atl.cpp:752:18:752:21 | call to Find | atl.cpp:753:13:753:15 | pos | |
848+
| atl.cpp:753:10:753:11 | ref arg a2 | atl.cpp:754:3:754:3 | a2 | |
803849
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
804850
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
805851
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |

0 commit comments

Comments
 (0)